Commit Graph

308773 Commits

Author SHA1 Message Date
Matthias Krüger
e546800737 Rollup merge of #148224 - jyn514:doc-open, r=Kobzol
bootstrap: `ensure(doc::Std)` no longer opens a browser

In general, the rationale for `--open` is to only open HTML files if they were "explicitly" invoked from the CLI (e.g. `x doc --open library/core`). The existing logic did not do that. Instead it opened the docs unconditionally when a subset of the crates was requested. This is unfortunate for other Steps in bootstrap, which may wish to `ensure()` the standard library docs without opening them.

Change `Std` to check if it was explicitly invoked, rather than assuming it's the case.
2025-10-29 08:07:50 +01:00
Matthias Krüger
9489751d80 Rollup merge of #148131 - tmiasko:deduce-spread-arg, r=wesleywiser
Skip parameter attribute deduction for MIR with `spread_arg`

When a MIR argument is spread at ABI level, deduced attributes are potentially misapplied, since a spread argument can correspond to zero or more arguments at ABI level.

Disable deduction for MIR using spread argument for the time being.
2025-10-29 08:07:50 +01:00
Matthias Krüger
8da95ac135 Rollup merge of #147281 - fee1-dead-contrib:clarify-binop-diag, r=jackh726
Make diagnostics clearer for binop-related errors in foreign crates

Fixes redundant language and bad grammar.
2025-10-29 08:07:49 +01:00
Matthias Krüger
4602127362 Rollup merge of #144444 - dawidl022:contracts/variable-scoping-rebased, r=jackh726
Contract variable declarations

This change adds contract variables that can be declared in the `requires` clause and can be referenced both in `requires` and `ensures`, subject to usual borrow checking rules. This allows any setup common to both the `requires` and `ensures` clauses to only be done once.

In particular, one future use case would be for [Fulminate](https://dl.acm.org/doi/10.1145/3704879)-like ownership assertions in contracts, that are essentially side-effects, and executing them twice would alter the semantics of the contract.

As of this change, `requires` can now be an arbitrary sequence of statements, with the final expression being of type `bool`. They are executed in sequence as expected, before checking if the final `bool` expression holds.

This PR depends on rust-lang/rust#144438 (which has now been merged).

Contracts tracking issue: https://github.com/rust-lang/rust/issues/128044

**Other changes introduced**:
- Contract macros now wrap the content in braces to produce blocks, meaning there's no need to wrap the content in `{}` when using multiple statements. The change is backwards compatible, in that wrapping the content in `{}` still works as before. The macros also now treat `requires` and `ensures` uniformally, meaning the `requires` closure is built inside the parser, as opposed to in the macro.

**Known limiatations**:
- Contracts with variable declarations are subject to the regular borrow checking rules, and the way contracts are currently lowered limits the usefulness of contract variable declarations. Consider the below example:

  ```rust
  #[requires(let init_x = *x; true)]
  #[ensures(move |_| *x == 2 * init_x)]
  fn double_in_place(x: &mut i32) {
      *x *= 2;
  }
  ```

  We have used the new variable declarations feature to remember the initial value pointed to by `x`, however, moving `x` into the `ensures` does not pass the borrow checker, meaning the above function contract is illegal. Ideally, something like the above should be expressable in contracts.
2025-10-29 08:07:49 +01:00
bors
907705abea Auto merge of #148208 - camsteffen:assign-desugar-span, r=wesleywiser
Remove unused `AssignDesugar` span
2025-10-29 01:59:52 +00:00
bors
044d68c3cb Auto merge of #148182 - saethlin:trivial-consts-recursive, r=eholk
Accept trivial consts based on trivial consts

This is an expansion of https://github.com/rust-lang/rust/pull/148040.

The previous implementation only accepted trivial consts that assign a literal. For example:
```rust
const A: usize = 0;
const B: usize = A;
```
Before this PR, only `A` was a trivial const. Now `B` is too.
2025-10-28 22:52:08 +00:00
Tomasz Miąsko
e9252a42f5 Skip parameter attribute deduction for MIR with spread_arg
When a MIR argument is spread at ABI level, deduced attributes are
potentially misapplied, since a spread argument can correspond to zero
or more arguments at ABI level.

Disable deduction for MIR using spread argument for the time being.
2025-10-28 23:07:04 +01:00
bors
278a90913d Auto merge of #148220 - matthiaskrgr:rollup-wtkkn0t, r=matthiaskrgr
Rollup of 3 pull requests

Successful merges:

 - rust-lang/rust#148173 (Emit delayed bug during wfck for stranded opaque)
 - rust-lang/rust#148177 (Allow codegen backends to indicate which crate types they support)
 - rust-lang/rust#148180 (rustdoc: remove `--emit=unversioned-shared-resources`)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-28 19:43:32 +00:00
Jynn Nelson
706d600232 bootstrap: ensure(doc::Std) no longer opens a browser
In general, the rationale for `--open` is to only open HTML files if
they were "explicitly" invoked from the CLI (e.g. `x doc --open
library/core`). The existing logic did not do that. Instead it opened
the docs unconditionally when a subset of the crates was requested. This
is unfortunate for other Steps in bootstrap, which may wish to `ensure()`
the standard library docs without opening them.

Change `Std` to check if it was explicitly invoked, rather than assuming
it's the case.
2025-10-28 13:24:43 -04:00
Matthias Krüger
71c4c899cd Rollup merge of #148180 - notriddle:unversioned-shared-resources, r=GuillaumeGomez
rustdoc: remove `--emit=unversioned-shared-resources`

This option hasn't done anything for a long time, and can be removed. I've kept a shim in place to avoid breaking docs.rs, but the option no longer does anything.

Using git-blame, I tracked this option down to
f77ebd4ffa, the commit that introduced EmitType in the first place. It was used with SharedResource::Unversioned, which no longer exists since f9e1f6ffdf removed them.

CC https://github.com/rust-lang/rust/pull/146220
Part of https://github.com/rust-lang/rust/issues/83784
2025-10-28 17:49:30 +01:00
Matthias Krüger
6a7bcec8da Rollup merge of #148177 - bjorn3:codegen_backend_crate_types, r=WaffleLapkin
Allow codegen backends to indicate which crate types they support

This way cargo will drop the unsupported crate types for crates that
specify multiple crate types.

This is a prerequisite for https://github.com/rust-lang/miri/pull/4648.
2025-10-28 17:49:29 +01:00
Matthias Krüger
1fe148371a Rollup merge of #148173 - tiif:fix-opaque-ice, r=BoxyUwU
Emit delayed bug during wfck for stranded opaque

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/235

## Problem

The fundamental issue here is ``OpaqueTypeCollector`` operates on ``rustc_middle::Ty``, but ``check_type_wf`` operates on HIR.

Since [check_type_wf](2f7620a5cc/compiler/rustc_hir_analysis/src/check/wfcheck.rs (L2262)) operates on HIR, it can see the stranded opaque and tries to infer it's hidden type. But ``OpaqueTypeCollector`` operates on ``rustc_middle::Ty``, so the ``OpaqueTypeCollector`` can no longer see a stranded opaque, hence its hidden type could not be inferred.

As a result, the tests ICE'ed at 34a8c7368c/compiler/rustc_hir_analysis/src/collect/type_of/opaque.rs (L253)

## Proposed solution

This PR detects stranded opaque types during wf check and emit a delayed bug for it.

## Alternative solution

`@BoxyUwU` and I had considered rewriting ``OpaqueTypeCollector`` to be a HIR visitor instead of a ``rustc_middle::Ty`` visitor, but we believe a HIR-based ``OpaqueTypeCollector`` will not work and might not worth the cost of rewriting.

## Acknowledgement

This PR is a joint effort with `@BoxyUwU` :3
2025-10-28 17:49:29 +01:00
Cameron Steffen
a45c6dd2c0 Remove AssignDesugar span 2025-10-28 11:18:58 -05:00
bjorn3
9fc1378916 Report correct unsupported crate type for the dummy codegen backend 2025-10-28 14:26:01 +00:00
bors
bc1d7273df Auto merge of #146186 - dpaoliello:cc, r=jieyouxu
Update cc-rs to 1.2.39

For my purposes, contains fixes when compiling the Rust compiler for Arm64EC.

Checked the commits since 1.2.16, and I don't see anything else that may affect Rust?

`find-msvc-tools` was also factored out from `cc` to allow updating the use in `rustc_codegen_ssa` (finding the linker when running the Rust compiler) to be separate from the use in `rustc_llvm` (building LLVM as part of the Rust compiler).
2025-10-28 13:25:45 +00:00
tiif
c797724ed5 Add delayed bug for stranded opaque 2025-10-28 13:02:24 +00:00
tiif
eb113533a3 Add test 2025-10-28 13:02:19 +00:00
bors
c9537a94a6 Auto merge of #148202 - Zalathar:rollup-2eriuc3, r=Zalathar
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#144936 (CFI: Fix types that implement Fn, FnMut, or FnOnce)
 - rust-lang/rust#147185 (repr(transparent): do not consider repr(C) types to be 1-ZST)
 - rust-lang/rust#147840 (Rework unsizing coercions in the new solver)
 - rust-lang/rust#147915 (Update target maintainers android.md)
 - rust-lang/rust#148013 (1.91.0 release notes)
 - rust-lang/rust#148044 (compiletest: show output in debug logging)
 - rust-lang/rust#148057 (tests/ui/sanitizer/hwaddress.rs: Run on aarch64 and remove cgu hack)
 - rust-lang/rust#148139 (Add `coverage` scope for controlling paths in code coverage)
 - rust-lang/rust#148154 (Add a mailmap entry)
 - rust-lang/rust#148158 (ci: loongarch64: use medium code model to avoid relocation overflows)
 - rust-lang/rust#148166 (Re-enable macro-stepping test for AArch64)
 - rust-lang/rust#148172 (rustc-dev-guide subtree update)
 - rust-lang/rust#148175 (Fix typos: duplicate words in comments)
 - rust-lang/rust#148186 (rustdoc-search: add an integration test for CCI)

Failed merges:

 - rust-lang/rust#147935 (Add LLVM realtime sanitizer)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-28 09:55:34 +00:00
Stuart Cook
21a1573742 Rollup merge of #148186 - notriddle:test-cci, r=GuillaumeGomez,jieyouxu
rustdoc-search: add an integration test for CCI

Part of https://github.com/rust-lang/rust/issues/130676
2025-10-28 20:39:41 +11:00
Stuart Cook
ff7909bc21 Rollup merge of #148175 - osamakader:fix-typos-duplicate-words, r=lcnr
Fix typos: duplicate words in comments

- Fix 'the the' → 'the' in rustc_const_eval
- Fix 'wether' → 'whether' in compiletest
- Fix 'is is' → 'is' in rustc_ast_pretty (2 instances)
2025-10-28 20:39:40 +11:00
Stuart Cook
86161675ea Rollup merge of #148172 - tshepang:rdg-sync, r=tshepang
rustc-dev-guide subtree update

Subtree update of `rustc-dev-guide` to b9fb8e9708.

Created using https://github.com/rust-lang/josh-sync.

r? ```@ghost```
2025-10-28 20:39:40 +11:00
Stuart Cook
a45371f7fe Rollup merge of #148166 - Jamesbarford:fix/aarch64-reenable-macro-stepping, r=wesleywiser
Re-enable macro-stepping test for AArch64

r? `@ghost`

triaging https://github.com/rust-lang/rust/issues/37225

edit: closes https://github.com/rust-lang/rust/issues/37225
2025-10-28 20:39:39 +11:00
Stuart Cook
d02848e1a4 Rollup merge of #148158 - heiher:loong64-medium, r=jieyouxu
ci: loongarch64: use medium code model to avoid relocation overflows

The LoongArch C/C++ cross toolchain defaults to the `normal` code model, which can cause relocation overflows when linking LLVM after upgrading to verion 22. This change uses the `medium`code model for `loongarch64-linux-gnu` and `loongarch64-linux-musl` builds to avoid these linking errors.
2025-10-28 20:39:38 +11:00
Stuart Cook
b4db48a36a Rollup merge of #148154 - WaffleLapkin:mail-and-ename, r=WaffleLapkin
Add a mailmap entry

I accidentally commited some things with my name/email swapped ^^'
2025-10-28 20:39:38 +11:00
Stuart Cook
a383fe8f20 Rollup merge of #148139 - Urgau:add-coverage-scope, r=Zalathar
Add `coverage` scope for controlling paths in code coverage

This PR adds a `coverage` scope (for `-Zremap-path-scope`) for controlling if the paths that ends up in code coverage output should be remapped or not.

Currently code coverage use the `macro` scope which is not a appropriate scope for them.

Found during the stabilization of `-Zremap-path-scope` https://github.com/rust-lang/rust/pull/147611#issuecomment-3396210043 and was asked to be in a separate PR in https://github.com/rust-lang/rust/pull/147611#issuecomment-3448455252.

r? compiler
2025-10-28 20:39:37 +11:00
Stuart Cook
78526e4720 Rollup merge of #148057 - Enselic:hwasan-fix-v2, r=nagisa
tests/ui/sanitizer/hwaddress.rs: Run on aarch64 and remove cgu hack

To avoid linker errors like

    relocation truncated to fit: R_AARCH64_ADR_PREL_PG_HI21 against `.data.rel.ro..L.hwasan'

we need to have `-C target-feature=+tagged-globals`, which is documented [here](https://doc.rust-lang.org/beta/unstable-book/compiler-flags/sanitizer.html#hwaddresssanitizer).  I learned that [here](https://github.com/llvm/llvm-project/pull/164876#issuecomment-3439034858).

Closes rust-lang/rust#83989

try-job: aarch64-gnu
2025-10-28 20:39:36 +11:00
Stuart Cook
bfa7219a3a Rollup merge of #148044 - jyn514:compiletest-logging, r=Zalathar
compiletest: show output in debug logging

I had a test I was confused by; the root issue is that `error-pattern` runs before normalization, even though `//~ ERROR` runs after normalization. This logging caught the issue immediately.
2025-10-28 20:39:36 +11:00
Stuart Cook
07e505fcf4 Rollup merge of #148013 - Mark-Simulacrum:relnotes, r=Mark-Simulacrum
1.91.0 release notes

This imports https://github.com/rust-lang/rust/issues/147010 into a PR in preparation for the release next week. It also imports a subset of the Cargo release notes (cc ```@rust-lang/cargo).```

r? ```@rust-lang/release```

```@triagebot``` ping relnotes-interest-group
2025-10-28 20:39:35 +11:00
Stuart Cook
b770888039 Rollup merge of #147915 - pirama-arumuga-nainar:patch-1, r=lqd
Update target maintainers android.md
2025-10-28 20:39:34 +11:00
Stuart Cook
1cf3dc6b5a Rollup merge of #147840 - jdonszelmann:unsizing-coercions, r=lcnr
Rework unsizing coercions in the new solver

Replaces https://github.com/rust-lang/rust/pull/141926, contains:

- a commit adding tests that fail before this work
- the two commits from the previous PR
- a commit in which these tests are fixed
- finally, a fixup for an in my opinion rather large regression in diagnostics. It's still not perfect, but better?

I hope this is roughly what you had in mind

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/241 and https://github.com/rust-lang/trait-system-refactor-initiative/issues/238, adding tests for both

r? ````@lcnr````
2025-10-28 20:39:33 +11:00
Stuart Cook
ef8003bbb9 Rollup merge of #147185 - RalfJung:repr-c-not-zst, r=petrochenkov
repr(transparent): do not consider repr(C) types to be 1-ZST

Context: https://github.com/rust-lang/unsafe-code-guidelines/issues/552

This experiments with a [suggestion](https://github.com/rust-lang/rfcs/pull/3845#discussion_r2388463698) by ```@RustyYato``` to stop considering repr(C) types as 1-ZST for the purpose of repr(transparent). If we go with https://github.com/rust-lang/rfcs/pull/3845 (or another approach for fixing repr(C)), they will anyway not be ZST on all targets any more, so this removes a portability hazard. Furthermore, zero-sized repr(C) structs [may have to be treated](https://github.com/rust-lang/unsafe-code-guidelines/issues/552#issuecomment-3250657813) as non-ZST for the win64 ABI (at least that's what gcc/clang do), so allowing them to be ignored in repr(transparent) types is not entirely coherent.

Turns out we already have an FCW for repr(transparent), namely https://github.com/rust-lang/rust/issues/78586. This extends that lint to also check for repr(C).
2025-10-28 20:39:32 +11:00
Stuart Cook
68618a8f92 Rollup merge of #144936 - rcvalle:rust-cfi-fix-144641, r=lcnr
CFI: Fix types that implement Fn, FnMut, or FnOnce

When looking for instances which could either be dynamically called through a vtable or through a concrete trait method, we missed `FnPtrShim`, instead only looking at `Item` and closure-likes. Fixes rust-lang/rust#144641.

cc ```@1c3t3a``` ```@Jakob-Koschel```
2025-10-28 20:39:32 +11:00
bors
df984edf44 Auto merge of #147083 - dianne:non-extended-indices, r=matthewjasper
Do not lifetime-extend array/slice indices

When lowering non-overloaded indexing operations to MIR, this uses the temporary lifetime of the index expression for the index temporary, rather than applying the temporary lifetime of the indexing operation as a whole to the index.

For example, in
```rust
let x = &xs[i];
```
previously, the temporary containing the result of evaluating `i` would live until the end of the block due to the indexing operation being [lifetime-extended](https://doc.rust-lang.org/nightly/reference/destructors.html#temporary-lifetime-extension). Under this PR, the index temporary only lives to the end of the `let` statement because it uses the more precise temporary lifetime of the index expression.

I don't think this will affect semantics in an observable way, but the more precise `StorageDead` placement may slightly improve analysis/codegen performance.

r? mir
2025-10-28 03:02:00 +00:00
Michael Howell
fe3490c562 rustdoc: remove --emit=unversioned-shared-resources
This option hasn't done anything for a long time, and can be
removed. I've kept a shim in place to avoid breaking docs.rs,
but the option no longer does anything.

Using git-blame, I tracked this option down to
f77ebd4ffa, the commit that
introduced EmitType in the first place. It was used with
SharedResource::Unversioned, which no longer exists since
f9e1f6ffdf removed them.

CC https://github.com/rust-lang/rust/pull/146220
Part of https://github.com/rust-lang/rust/issues/83784
2025-10-27 17:28:51 -07:00
pirama-arumuga-nainar
610b82ef0c Update target maintainers android.md 2025-10-27 17:04:42 -07:00
Michael Howell
978fd435ae rustdoc-search: add an integration test for CCI
Part of https://github.com/rust-lang/rust/issues/130676
2025-10-27 11:57:32 -07:00
Ramon de C Valle
20d3d576d5 CFI: Rewrite FnPtrShim when generalizing
When looking for instances which could either be dynamically called
through a vtable or through a concrete trait method, we missed
`FnPtrShim`, instead only looking at `Item` and closure-likes.
2025-10-27 11:32:40 -07:00
Ralf Jung
b9b29c4379 repr(transparent): do not consider repr(C) types to be 1-ZST 2025-10-27 19:25:14 +01:00
Ben Kimock
9cbfbb164e Accept trivial consts based on trivial consts 2025-10-27 13:36:57 -04:00
bors
adaa838976 Auto merge of #148035 - bjorn3:check_skip_codegen_crate, r=madsmtm
Skip codegen_crate call in check mode

This way we don't have to spawn the coordinator thread. Some errors will no longer be emitted with this in check mode. For example the check that `-Ctarget-cpu` is passed on targets that need this.

Suggested by `@saethlin`
2025-10-27 17:24:08 +00:00
Daniel Paoliello
826c925128 Update cc-rs to 1.2.39 2025-10-27 10:10:48 -07:00
Josh Stone
83cb889bc8 Link to i32 for strict_div/rem methods
Co-authored-by: Kevin Reid <kpreid@switchb.org>
2025-10-27 09:45:28 -07:00
bjorn3
b443a59ba8 Allow codegen backends to indicate which crate types they support
This way cargo will drop the unsupported crate types for crates that
specify multiple crate types.
2025-10-27 16:24:33 +00:00
bjorn3
3ce89e257d Use the actual StableCrateId for the incr comp session dir
Previously only --crate-type would be taken into account, not #![crate_type].
2025-10-27 15:56:09 +00:00
Osama Abdelkader
bf6f3035af Fix typos: duplicate words in comments
- Fix 'the the' → 'the' in rustc_const_eval
- Fix 'wether' → 'whether' in compiletest
- Fix 'is is' → 'is' in rustc_ast_pretty (2 instances)

Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
2025-10-27 18:01:04 +03:00
bors
9ea8d67cc6 Auto merge of #148167 - Zalathar:rollup-njf167h, r=Zalathar
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#145939 (const `select_unpredictable`)
 - rust-lang/rust#147478 (More intuitive error when using self to instantiate tuple struct with private field)
 - rust-lang/rust#147866 (Add built-in `const` impls for `Clone` and `Copy`)
 - rust-lang/rust#148153 (Fix duplicate 'the the' typos in comments)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-27 14:12:58 +00:00
Tshepang Mbambo
044bc7a09d Merge pull request #2617 from rust-lang/rustc-pull
Rustc pull update
2025-10-27 15:42:42 +02:00
Tshepang Mbambo
58d2f0317d Merge pull request #2583 from rust-lang/tshepang-patch-4
remove untrue/contentious statement
2025-10-27 15:39:14 +02:00
Tshepang Mbambo
943074fd09 improve and strengthen wording 2025-10-27 15:35:18 +02:00
Urgau
94c893ee2e Add coverage scope for controlling paths in code coverage 2025-10-27 12:54:24 +01:00