51056 Commits

Author SHA1 Message Date
Cameron Steffen
a96e21b199 Remove QPath::LangItem from try 2025-10-27 21:19:38 -05:00
Cameron Steffen
bd13c30d98 Remove QPath::LangItem from async 2025-10-27 21:19:38 -05:00
Cameron Steffen
7cbff63411 Remove QPath::LangItem from ranges 2025-10-27 21:19:38 -05:00
Cameron Steffen
9c98533491 Remove QPath::LangItem from contracts 2025-10-27 20:35:55 -05:00
Cameron Steffen
eac2c2523e Remove QPath::LangItem from format_args! 2025-10-27 20:35:55 -05:00
Cameron Steffen
e289f27329 Remove QPath::LangItem from for loops 2025-10-27 20:35:55 -05:00
Cameron Steffen
7e51a763c9 Prefactor LangItem::QPath lowering functions
Get ready to incrementally remove LangItem::QPath.
2025-10-27 19:31:45 -05:00
Cameron Steffen
6f3d0f7796 Introduce qpath lang item utils 2025-10-27 19:31:45 -05: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
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
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