Commit Graph

50999 Commits

Author SHA1 Message Date
Josh Stone
8fd2dc0034 Update #[cfg(bootstrap)] 2025-10-28 13:35:43 -07:00
Josh Stone
f25ca45fd1 Update CURRENT_RUSTC_VERSION post-bump
(cherry picked from commit 813072186c1c305ea62c7270f1514dfab5166af2)
2025-10-28 13:22:00 -07: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
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
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
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
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
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
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
Urgau
94c893ee2e Add coverage scope for controlling paths in code coverage 2025-10-27 12:54:24 +01:00
Jana Dönszelmann
17566221f8 find the right error source when we can't unsize 2025-10-27 12:26:52 +01:00
Stuart Cook
791165cc73 Rollup merge of #148153 - osamakader:fix-duplicate-the, r=JonathanBrouwer
Fix duplicate 'the the' typos in comments

Fix duplicate 'the the' typos in comments
2025-10-27 22:13:23 +11:00
Stuart Cook
2e575e0022 Rollup merge of #147866 - fee1-dead-contrib:constclonebuiltin, r=lcnr
Add built-in `const` impls for `Clone` and `Copy`

cc `@compiler-errors`
2025-10-27 22:13:22 +11:00
Stuart Cook
0bd2437cac Rollup merge of #147478 - Jamesbarford:fix/tuple-private-fields-constructor, r=davidtwco
More intuitive error when using self to instantiate tuple struct with private field

Fixes https://github.com/rust-lang/rust/issues/147343
2025-10-27 22:13:21 +11:00
bors
4b53279854 Auto merge of #148040 - saethlin:trivial-consts, r=oli-obk
Add a fast path for lowering trivial consts

The objective of this PR is to improve compilation performance for crates that define a lot of trivial consts. This is a flamegraph of a build of a library crate that is just 100,000 trivial consts, taken from a nightly compiler:
<img width="842" height="280" alt="2025-10-25-164005_842x280_scrot" src="https://github.com/user-attachments/assets/e5400aaf-03bd-4461-b905-054aa82ca60f" />
My objective is to target all of the cycles in `eval_to_const_value_raw` that are not part of `mir_built`, because if you look at the `mir_built` for a trivial const, we already have the value available.

In this PR, the definition of a trivial const is this:
```rust
const A: usize = 0;
```
Specifically, we look for if the `mir_built` body is a single basic block containing one assign statement and a return terminator, where the assign statement assigns an `Operand::Constant(Const::Val)`. The MIR dumps for these look like:
```
const A: usize = {
    let mut _0: usize;

    bb0: {
        _0 = const 0_usize;
        return;
    }
}
```

The implementation is built around a new query, `trivial_const(LocalDefId) -> Option<(ConstValue, Ty)>` which returns the contents of the `Const::Val` in the `mir_built` if the `LocalDefId` is a trivial const.

Then I added _debug_ assertions to the beginning of `mir_for_ctfe` and `mir_promoted` to prevent trying to get the body of a trivial const, because that would defeat the optimization here. But these are deliberately _debug_ assertions because the consequence of failing the assertion is that compilation is slow, not corrupt. If we made these hard assertions, I'm sure there are obscure scenarios people will run into where the compiler would ICE instead of continuing on compilation, just a bit slower. I'd like to know about those, but I do not think serving up an ICE is worth it.

With the assertions in place, I just added logic around all the places they were hit, to skip over trying to analyze the bodies of trivial consts.

In the future, I'd like to see this work extended by:
* Pushing detection of trivial consts before MIR building
* Including DefKind::Static and DefKind::InlineConst
* Including consts like `_1 = const 0_usize; _0 = &_1`, which would make a lot of promoteds into trivial consts
* Handling less-trivial consts like `const A: usize = B`, which have `Operand::Constant(Const::Unevaluated)`
2025-10-27 11:02:41 +00:00
Jana Dönszelmann
349dbecdab move old solver coercion code to separate function 2025-10-27 12:00:41 +01:00
bors
23fced0fcc Auto merge of #146069 - camsteffen:range-desugar-span, r=SparrowLii
Mark desugared range expression spans with DesugaringKind::RangeExpr

This is a prerequisite to removing `QPath::LangItem` (rust-lang/rust#115178) because otherwise there would be no way to detect a range expression in the HIR.

There are some non-obvious Clippy changes so a Clippy team review would be good.
2025-10-27 02:50:35 +00:00
Ben Kimock
a63035f9bf Explain that the current impl is only silly, not recursive 2025-10-26 22:13:12 -04:00
Ben Kimock
6ba56d227f Move trivial_const to a separate module with a doc comment 2025-10-26 22:09:33 -04:00
bors
b1b464d6f6 Auto merge of #147914 - petrochenkov:oosmc-used, r=fmease
resolve: When suppressing `out_of_scope_macro_calls` suppress `unused_imports` as well

Fixes the example from this comment - https://github.com/rust-lang/rust/issues/147823#issuecomment-3421770900.
Fixes https://github.com/rust-lang/rust/issues/148143.
2025-10-26 23:44:52 +00:00
Osama Abdelkader
2aa314c024 Fix duplicate 'the the' typos in comments
Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
2025-10-27 00:37:43 +03:00
bors
f37aa9955f Auto merge of #147890 - tmiasko:deduce-captures-none, r=cjgillot
Deduce captures(none) for a return place and parameters

Extend attribute deduction to determine whether parameters using
indirect pass mode might have their address captured. Similarly to
the deduction of `readonly` attribute this information facilitates
memcpy optimizations.
2025-10-26 20:37:03 +00:00
Deadbeef
042018df2d respond to review 2025-10-26 19:57:05 +00:00
Deadbeef
744c670812 Add built-in const impls for Clone and Copy 2025-10-26 19:40:59 +00:00
Stuart Cook
3bf838d790 Rollup merge of #148118 - saethlin:nullary-intrinsic-check-bug-msg, r=Noratrieb,dianqk
Improve the ICE message for invalid nullary intrinsic calls

In https://github.com/rust-lang/rust/issues/148104, we found the panic message here rather confusing, and (if I'm reading the tea leaves right) that's because the intended audience for either side of the phrase is very different. I think this is more clear if/when this is encountered by users.

I expect this ICE to be hit in practice by people calling the `size_of` and `align_of` intrinsics, so it's now _kind of_ helpful for those users too.

The original effort to stop backends from needing to support nullary intrinsics added a note to all these const-only intrinsics, but when https://github.com/rust-lang/rust/pull/147793 ported two more the paragraph wasn't added. I've added it.
2025-10-26 22:15:09 +11:00
Ben Kimock
7a0d9c8d5e Improve the ICE message for invalid nullary intrinsic calls 2025-10-25 21:32:27 -04:00
bors
cc63a0abde Auto merge of #148066 - lcnr:remove-perf-hack, r=BoxyUwU
remove a performance hack

This hack seems no longer used 🤔 nalgebra compiles without it.

Let's run perf to see whether it matters.

r? `@BoxyUwU`
2025-10-25 22:23:29 +00:00
James Barford-Evans
7af72e79b9 More intuitive error when using self to instantiate tuple struct with private field 2025-10-25 22:46:15 +01:00
Ben Kimock
775da711c6 Add a fast path for lowering trivial consts 2025-10-25 16:59:53 -04:00
Tomasz Miąsko
2a03a948b9 Deduce captures(none) for a return place and parameters
Extend attribute deduction to determine whether parameters using
indirect pass mode might have their address captured. Similarly to
the deduction of `readonly` attribute this information facilitates
memcpy optimizations.
2025-10-25 22:53:52 +02:00
bors
34f954f9b7 Auto merge of #148100 - matthiaskrgr:rollup-vrd4wy8, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#143361 (Stop passing resolver disambiguator state to AST lowering.)
 - rust-lang/rust#148000 (Improvements to attribute suggestions)
 - rust-lang/rust#148007 (chore: Update to the latest annotate-snippets)
 - rust-lang/rust#148088 (compiletest: Simplify passing arguments to spawned test threads)

r? `@ghost`
`@rustbot` modify labels: rollup
2025-10-25 19:10:39 +00:00
bors
79966ae420 Auto merge of #147493 - cjgillot:single-pin, r=oli-obk
StateTransform: Only load pin field once.

The current implementation starts by transforming all instances of `_1` into `(*_1)`, and then traverses the body again to transform `(*_1)` into `(*(_1.0))`, and again for `Derefer`.

This PR changes the implementation to only traverse the body once. As `_1.0` cannot be not modified inside the body (we just changed its type!), we have no risk of loading from the wrong pointer.
2025-10-25 16:04:41 +00:00
Matthias Krüger
141c91091c Rollup merge of #148007 - Muscraft:annotate-snippets, r=jdonszelmann
chore: Update to the latest annotate-snippets

This PR updates `annotate-snippets` to the latest version and updates the adapter code[^1] so that `AnnotateSnippetEmitter`'s output matches `HumanEmitter`'s output. If anyone would like to see the differences[^2] between `AnnotateSnippetEmitter` and `HumanEmitter`, [I have a branch](https://github.com/Muscraft/rust/tree/annotate-snippets-default-renderer) where `AnnotateSnippetEmitter` is used in place of `HumanEmitter`.

[^1]: A lot of the adapter code changes are based on code for `HumanEmitter`.
[^2]: Some of the test differences will go away when rust-lang/rust#148001 and rust-lang/rust#148004 are merged.
2025-10-25 12:57:39 +02:00
Matthias Krüger
d182d8e874 Rollup merge of #148000 - JonathanBrouwer:wipnew2, r=jdonszelmann
Improvements to attribute suggestions

Changes in commit 1:
- Add `AcceptContext::suggestions`, which retrieves the suggestions for the currently parsing attribute
- This happens to fix a bug in the way `#[macro_export`]. Closes https://github.com/rust-lang/rust/pull/147987

Changes in commit 2:
- Add a check to the suggestions function so the suggestions for attributes in cfg_attr are nicer. Fixes https://github.com/rust-lang/rust/issues/147693

This is also part (but not all) of the changes needed to unblock https://github.com/rust-lang/rust/pull/147945

r? `@jdonszelmann`
2025-10-25 12:57:39 +02:00
Matthias Krüger
cee562c0b2 Rollup merge of #143361 - cjgillot:split-disambig, r=oli-obk
Stop passing resolver disambiguator state to AST lowering.

AST->HIR lowering can use a disjoint set of `DefPathData` as the resolver, so we don't need to pass the disambiguator state.

r? `@oli-obk`
2025-10-25 12:57:38 +02:00
bors
f435972085 Auto merge of #142712 - davidtwco:sized-hierarchy-missing-default-bounds, r=lcnr
hir_analysis: add missing sizedness bounds

Depends on rust-lang/rust#144064

Default sizedness bounds were not being added to `explicit_super_predicates_of` and `explicit_implied_predicates_of` which meant that a trait bound added to a associated type projection would be missing the implied predicate of the default sizedness supertrait of that trait.

An unexpected consequence of this change was that the check for multiple principals was now finding an additional `MetaSized` principal when eagerly expanding trait aliases - which is fixed by skipping `MetaSized` when elaborating trait aliases in lowering `dyn TraitAlias`.
2025-10-24 21:39:28 +00:00
Scott Schafer
354b9779bf chore: Update to the latest annotate-snippets 2025-10-24 12:50:19 -06:00
bors
2aaa62b89d Auto merge of #148018 - tardyp:lto_big_filesize_utf8, r=JonathanBrouwer
fix panic when rustc tries to reduce intermediate filenames len with utf8

The issue cannot be reproduced with the former testcase of creating external crates because rust refuses to use "external crate 28_找出字符串中第一个匹配项的下标" because it is not a valid indentifier (starts with number, and contain non ascii chars)

But still using 28_找出字符串中第一个匹配项的下标.rs as a filename is accepted by previous rustc releases So we consider it valid, and add an integration test for it to catch any regression on other code related to non ascii filenames.

Fix rust-lang/rust#147975
2025-10-24 18:23:10 +00:00
David Wood
82a4049844 hir_analysis: add missing sizedness bounds
Default sizedness bounds were not being added to
`explicit_super_predicates_of` and `explicit_implied_predicates_of`
which meant that a trait bound added to a associated type projection
would be missing the implied predicate of the default sizedness
supertrait of that trait.

An unexpected consequence of this change was that the check for multiple
principals was now finding an additional `MetaSized` principal when
eagerly expanding trait aliases. Instead of special-casing trait aliases
as different from traits and not adding a `MetaSized` supertrait to trait
aliases, filter out `MetaSized` when lowering `dyn Trait`.
2025-10-24 15:28:34 +01:00
Pierre Tardy
c6acffeb78 fix panic when rustc tries to reduce intermediate filenames length with multi byte chars
The issue cannot be reproduced with the former testcase of creating external crates because
rust refuses to use "external crate 28_找出字符串中第一个匹配项的下标"
because it is not a valid indentifier (starts with number, and contain non ascii chars)

But still using 28_找出字符串中第一个匹配项的下标.rs as a filename is accepted by previous rustc releases
So we consider it valid, and add an integration test for it to catch any regression on other code related to non ascii filenames.
2025-10-24 16:20:29 +02:00
lcnr
561e3cede2 gamer 2025-10-24 15:34:45 +02:00
bors
ab925646fa Auto merge of #147950 - durin42:llvm-22-intrinsics-changes, r=nikic
rustc_codegen_llvm: adapt for LLVM 22 change to pass masked intrinsic alignment as an attribute

This was a bit more invasive than I had kind of hoped. An alternate approach would be to add an extra call_intrinsic_with_attrs() that would have the new-in-this-change signature for call_intrinsic, but this felt about equivalent and made it a little easier to audit the relevant callsites of call_intrinsic().

Related LLVM change is llvm/llvm-project#163802.

`@rustbot` label llvm-main
2025-10-24 13:00:14 +00:00
bjorn3
5a8ffa4bef Skip codegen_crate call in check mode 2025-10-24 10:25:13 +00:00
bors
8aab621cd5 Auto merge of #148043 - lqd:revert-146121, r=wesleywiser
Revert "fix: Filter suggestion parts that match existing code"

As requested by `@wesleywiser` in https://github.com/rust-lang/rust/issues/147973#issuecomment-3437393773 this is a revert of https://github.com/rust-lang/rust/pull/146121 due to the handful of diagnostics ICEs that have been since reported, and found in the beta crater run.

This should thus also be backported to beta so the ICEs don't make it to next week's stable.

Works around (after backport)
- https://github.com/rust-lang/rust/issues/146261
- https://github.com/rust-lang/rust/issues/146706
- https://github.com/rust-lang/rust/issues/146834 but I didn't add a test for this allowed-by-default lint
- as well as the crater run regressions from https://github.com/rust-lang/rust/issues/147973 of which I only added the MCVE as a test.

The proper fix would likely be https://github.com/rust-lang/rust/pull/147849 but it's still currently at the MCP stage. In the meantime, this PR would still emit the same overlapping suggestions, but still use a debug-assert...

r? `@wesleywiser`
2025-10-24 09:50:35 +00:00