Commit graph

52760 commits

Author SHA1 Message Date
Boxy
9cc698e8d6 parse array lengths without mgca shenanigans
(cherry picked from commit 01703e30c0)
2026-02-12 09:07:19 -08:00
Vadim Petrochenkov
a096799b4a Partially revert "resolve: Update NameBindingData::vis in place"
(cherry picked from commit 324267ccaa)
2026-02-12 09:07:10 -08:00
Alan Egerton
1087b41a83 Fix missing unused_variables lint when using a match guard
Within a binding pattern match guard, only real reads of a bound local
impact its liveness analysis - not the fake read that is injected.

(cherry picked from commit 5aba6b1635)
2026-02-12 09:06:20 -08:00
lcnr
25c0e0569c prevent incorrect layout error
aliases may be rigid even if they don't reference params. If the alias isn't well-formed, trying to normalize it as part of the input should have already failed

(cherry picked from commit 39a532445a)
2026-02-12 09:06:14 -08:00
Alan Egerton
01268919a5 Fix suppression of unused_assignment in binding of unused_variable
Unused assignments to an unused variable should trigger only the
`unused_variables` lint and not also the `unused_assignments` lint.
This was previously implemented by checking whether the span of the
assignee was within the span of the binding pattern, however that failed
to capture situations was imported from elsewhere (eg from the input
tokenstream of a proc-macro that generates the binding pattern).

By comparing the span of the assignee to those of the variable
introductions instead, a reported stable-to-stable regression is
resolved.

This fix also impacted some other preexisting tests, which had
(undesirably) been triggering both the `unused_variables` and
`unused_assignments` lints on the same initializing assignment; those
tests have therefore now been updated to expect only the former lint.

(cherry picked from commit 22b3f59882)
2026-02-12 09:06:11 -08:00
Guillaume Gomez
34f6f4827d Move remaining doc attribute parsing errors to warnings
(cherry picked from commit c910511cab)
2026-02-05 11:44:34 -08:00
Guillaume Gomez
d8ac42edd1 Make more doc attribute parsing error into future warnings
(cherry picked from commit 6d713489d0)
2026-02-05 11:38:02 -08:00
Guillaume Gomez
9126c7a0b7 Emit a future error warning for duplicate doc attribute
(cherry picked from commit 7dbbab63e2)
2026-02-05 11:36:45 -08:00
Trevor Gross
dcea3c7ea3 Revert "Enable outline-atomics by default on AArch64 Windows platforms"
This reverts commit 1ed1b6e267.

(cherry picked from commit 9fb68d60ef)
2026-02-05 11:36:35 -08:00
Trevor Gross
4afad17828 Revert "Enable outline-atomics by default on AArch64 Android"
This reverts commit c455903978.

(cherry picked from commit 1173034b7b)
2026-02-05 11:36:35 -08:00
Trevor Gross
b5e2de23c2 Revert "Enable outline-atomics by default on AArch64 Fuchsia"
This reverts commit 21525f862d.

(cherry picked from commit a9da102e20)
2026-02-05 11:36:35 -08:00
Trevor Gross
610c87797c Revert "Enable outline-atomics by default on AArch64 OpenBSD"
This reverts commit 66c150c1fa.

(cherry picked from commit 63e16520a2)
2026-02-05 11:36:35 -08:00
Trevor Gross
e9a79f3f76 Revert "Enable outline-atomics by default on AArch64 FreeBSD"
This reverts commit 383053e016.

(cherry picked from commit 54f88be3cd)
2026-02-05 11:36:35 -08:00
mu001999
c226970869 Parse ident with allowing recovery when trying to recover in diagnosing
(cherry picked from commit 3713512217)
2026-02-05 11:36:26 -08:00
Mark Rousskov
5d1cb2526b Replace version placeholders with 1.94 2026-01-19 09:26:42 -05:00
bors
9f6cd6defb Auto merge of #151085 - Keith-Cancel:mgca2, r=BoxyUwU
Fix ICE: When Trying to check visibility of a #[type_const], check RHS instead.

This PR fixes https://github.com/rust-lang/rust/issues/150956 for min_const_generic_args https://github.com/rust-lang/rust/issues/132980. 

The first part of this PR checks in `reachable.rs` if we have a type const use `visit_const_item_rhs(init);` instead of calling `const_eval_poly_to_alloc()`

The second part is I noticed that if `const_eval_poly_to_alloc()` returns a `ErrorHandled::TooGeneric` then switches to `visit_const_item_rhs()`. So further up `const_eval_poly_to_alloc()` call order it eventual gets to `eval_in_interpreter()`. So I added a debug_assert in `eval_in_interpreter()` if we happen to try and run CTFE on a `type_const`.

The other bit is just a test case, and some duplicated code I noticed.

While the PR does get rid of the ICE for a type_const with `pub` visibility. If I try using the const though it will ICE with the following:
```
error: internal compiler error: /home/keith/GitHub/rust_kc/compiler/rustc_const_eval/src/check_consts/qualifs.rs:355:13: expected ConstKind::Param or ConstKind::Value here, found UnevaluatedConst { def: DefId(20:4 ~ colorkit[c783]::TYPE_CONST), args: [] }


thread 'rustc' (819687) panicked at /home/keith/GitHub/rust_kc/compiler/rustc_const_eval/src/check_consts/qualifs.rs:355:13:
```

I suspect it is a similar issue to inherent associated consts. Since if I apply the same fix I had here:
https://github.com/rust-lang/rust/pull/150799#discussion_r2676504639

I then can use the const  internally and in external crates without any issues.
Although, did not include that fix since if it is a similar issue it would need to be addressed elsewhere.

r? @BoxyUwU 
@rustbot label +F-associated_const_equality +F-min_generic_const_args
2026-01-17 09:45:42 +00:00
Keith-Cancel
4c93efae2b Fix ICE: When Trying to check visibility of a #[type_const], check RHS instead.
We want to evaluate the rhs of a type_const.

Also added an early return/guard in eval_in_interpreter which is used in functions like `eval_to_allocation_raw_provider`

Lastly add a debug assert to `thir_body()` if we have gotten there with a type_const something as gone wrong.

Get rid of a call to is_type_const() and instead use a match arm.

Change this is_type_const() check to a debug_assert!()

Change to use an if else statment instead.

Update type_const-pub.rs

Fix formatting.

Noticed that this is the same check as is_type_const() centralize it.

Add test case for pub type_const.
2026-01-16 20:30:58 -08:00
Stuart Cook
2956932345
Rollup merge of #151222 - reflect-references, r=oli-obk
feat: Support references in reflection type info

Tracking issue: https://github.com/rust-lang/rust/issues/146922 `#![feature(type_info)]`

Based on rust-lang/rust#151119 implementation for pointers for consistency

r? oli-obk
2026-01-17 11:47:20 +11:00
Jamie Hill-Daniel
c7031e93c5 feat: Support references in reflection type info 2026-01-17 00:25:29 +00:00
bors
f6a07efc81 Auto merge of #151224 - matthiaskrgr:rollup-SLK4owB, r=matthiaskrgr
Rollup of 4 pull requests

Successful merges:

 - rust-lang/rust#151196 (Ship LLVM (`rust-dev`) in fast try builds again)
 - rust-lang/rust#151198 (Add an additional help note to the ambiguity lint error)
 - rust-lang/rust#151215 (Add missing closing brackets to THIR output.)
 - rust-lang/rust#151218 (compiletest: Add `AuxCrate` struct with docs.)

r? @ghost
2026-01-16 20:33:57 +00:00
Matthias Krüger
cfa8f97999
Rollup merge of #151215 - thir-mismatched-brackets-and-field-names, r=bjorn3
Add missing closing brackets to THIR output.

Closing brackets were missing on AdtDef, the field_types list in FruInfo, and InlineAsmExpr, breaking folding in some editors; Fields were incorrectly (?) indexed in the list for functional update syntax, showing the (implicit, irrelevant) iteration index instead of the field index; also spurious colon after Pat.
2026-01-16 21:04:32 +01:00
Matthias Krüger
64f318e6f2
Rollup merge of #151198 - ambiguity_fix_help, r=petrochenkov
Add an additional help note to the ambiguity lint error

This PR adds an additional help note to the ambiguity lint error output to ask users updating their dependencies. This hopefully helps with cases like rust-lang/rust#149845 where newer crate versions are fixed.

r? @petrochenkov
2026-01-16 21:04:32 +01:00
bors
503745e917 Auto merge of #151210 - matthiaskrgr:rollup-JwDAUuv, r=matthiaskrgr
Rollup of 6 pull requests

Successful merges:

 - rust-lang/rust#145354 (Cache derive proc macro expansion with incremental query)
 - rust-lang/rust#151123 (Support primitives in type info reflection)
 - rust-lang/rust#151178 (simplify words initialization using Rc::new_zeroed)
 - rust-lang/rust#151187 (Use `default_field_values` more in `Resolver`)
 - rust-lang/rust#151197 (remove lcnr from compiler review rotation)
 - rust-lang/rust#151203 (Revert `QueryStackFrame` split)

r? @ghost
2026-01-16 16:44:08 +00:00
Alex Celeste
1f691f7dbd Add missing closing brackets to THIR output.
Closing brackets were missing on AdtDef, the field_types list in FruInfo, and InlineAsmExpr, breaking folding in some editors;
Fields were incorrectly (?) indexed in the list for functional update syntax, showing the (implicit, irrelevant) iteration index instead of the field index;
also spurious colon after Pat.
2026-01-16 14:44:58 +00:00
bors
b08c11df4b Auto merge of #151162 - GuillaumeGomez:cleanup-attr-parsing, r=JonathanBrouwer
Clean up `rustc_attr_parsing`

Follow-up of rust-lang/rust#150934.

It removes the `Option<>` wrapping for `SharedContext::target` field and completely removed the `target_id` field. Considering this type contains a closure and never updates its `target_id` field, there is no need to keep it around, it can be used directly in the lint emitter.

r? @JonathanBrouwer
2026-01-16 13:03:57 +00:00
Matthias Krüger
57e950bc98
Rollup merge of #151203 - revert-QueryStackFrame-split, r=oli-obk
Revert `QueryStackFrame` split

PR rust-lang/rust#138672 fixed a query cycle OOM reported in rust-lang/rust#124901. The fix involved delaying computation of some query stack frame elements and was very complex. It involved the addition of two new types, the addition of a generic `I` parameter to eleven(!) other types, a `PhantomData` field, and even required an unsafe transmute of a closure. [This comment](https://github.com/rust-lang/rust/issues/124901#issuecomment-2104852065) had suggested a much simpler fix, but it was ignored. The PR also failed to add a test case.

This PR adds a test case, reverts the complex fix, applies the simpler fix, and does a few other minor cleanups.

r? @oli-obk
2026-01-16 13:57:47 +01:00
Matthias Krüger
771fa1c0f1
Rollup merge of #151187 - const-resolver, r=petrochenkov
Use `default_field_values` more in `Resolver`

Extend more ways of building `FxHashSet`, `FxHashMap`, `UnordSet`, `UnordMap` and `DisambiguatorState` in `const` contexts to allow for more fields in `Resolver` to have a default value. `FxIndexSet`/`FxIndexMap` are still outstanding and not const-buildable.

r? @petrochenkov
2026-01-16 13:57:47 +01:00
Matthias Krüger
4227404a04
Rollup merge of #151178 - ua/fixme, r=Kivooeo
simplify words initialization using Rc::new_zeroed

Now that Rc::new_zeroed is stable, remove the cfg(feature = "nightly") branch and the temporary zeroed array on stable. This avoids copying a potentially large [Word; CHUNK_WORDS] into the Rc.
2026-01-16 13:57:46 +01:00
Matthias Krüger
225ba69ee2
Rollup merge of #151123 - type-info-primitives, r=oli-obk
Support primitives in type info reflection

Tracking issue: rust-lang/rust#146922 `#![feature(type_info)]`

This PR supports {`bool`,`char`,`int`,`uint`,`float`,`str`} primitive types for feature `type_info` reflection.

r? @oli-obk
2026-01-16 13:57:46 +01:00
Matthias Krüger
81cc29a425
Rollup merge of #145354 - cache-proc-derive-macros, r=petrochenkov
Cache derive proc macro expansion with incremental query

This is a revival of https://github.com/rust-lang/rust/pull/129102, originally implemented by @futile. Since it looks like they are not active currently, I'd like to push this work forward.

The first commit is squashed and rebased work from the original PR, with author attribution to futile. The rest of the commits are some additional comments that I created mostly for myself to understand what happens here. I also did some cleanups based on Vadim's review comments on the original PR, plus I refactored the TLS access a bit using `scoped_tls`.

The biggest issue, as usually, are tests... I tried using `#[rustc_clean(..., loaded_from_disk = "derive_macro_expansion")]`, but the problem is that since this query cannot recover the original key from its hash, and thus its fingerprintstyle is `FingerprintStyle::Opaque`, [this](2fef0a30ae/compiler/rustc_incremental/src/persist/dirty_clean.rs (L388)) crashes when I try to use `loaded_from_disk`. Any suggestions from someone who actually understands the query system would be welcome 😅

TODO: document the new unstable flag

On a no-op change re-check of `octocrab 0.49` (which has a ton of `serde` derive proc macro invocations), this saves ~0.6s out of ~6s (so a ~10% win) on my PC.

r? @petrochenkov
2026-01-16 13:57:45 +01:00
Georg Semmler
d028956f11
Add an additional help note to the ambiguity lint error
This PR adds an additional help note to the ambiguity lint error output
to ask users updating their dependencies. This hopefully helps with
cases like https://github.com/rust-lang/rust/issues/149845 where newer crate versions are fixed.
2026-01-16 13:39:01 +01:00
bors
c40c51f9fd Auto merge of #151193 - matthiaskrgr:rollup-17r4zye, r=matthiaskrgr
Rollup of 2 pull requests

Successful merges:

 - rust-lang/rust#151166 (fix: Do not delay E0107 when there exists an assoc ty with the same name)
 - rust-lang/rust#151185 (Disable `dump-ice-to-disk` on `i686-pc-windows-msvc`)

r? @ghost
2026-01-16 09:47:11 +00:00
Nicholas Nethercote
90e4a42162 Use with_reduced_queries to avoid query cycles.
This changes the error message of `query-cycle-issue-124901.rs`, which
doesn't matter much.
2026-01-16 19:21:35 +11:00
Nicholas Nethercote
48bcaf7ed1 Revert the QueryStackFrameExtra/QueryStackDeferred split.
PR #138672 introduced a complex and invasive split of `QueryStackFrame`
to avoid a query cycle. This commit reverts that change because there is
a much simpler change that fixes the problem, which will be in the next
commit.
2026-01-16 19:18:42 +11:00
Matthias Krüger
0cfe78fa1f
Rollup merge of #151166 - issue-148121, r=tiif
fix: Do not delay E0107 when there exists an assoc ty with the same name

Fixes rust-lang/rust#148121

When we have the following code:

```rust
trait Foo<T> {}

impl Foo<T: Default> for String {}
```

we delay `E0107: wrong number of generic args` to suggest moving `T: Default` bound to the impl block's param declaration.

The delay is determined by whether all the missing generic parameters are mentioned by those *wrong* assoc item constraints.

But this delay is wrong when there exist any *correct* assoc item constraints, i.e. when we have an assoc type whose identifier is same with a missing generic parameter like in the following code:

```rust
pub trait Super<X> {
    type X;
}
pub trait A {}
impl A for dyn Super<X = ()> {}
```
2026-01-16 08:03:59 +01:00
Felix Rath
8fa2f693bb
Implement incremental caching for derive macro expansions 2026-01-16 07:36:36 +01:00
bors
d2015e2359 Auto merge of #151155 - Zalathar:str, r=Nadrieril
THIR patterns: Always use type `str` for string-constant-value nodes

Historically, constants and literals of type `&str` have been represented in THIR patterns as `PatKind::Const` nodes with type `&str`.

That's fine for stable Rust, but `feature(deref_patterns)` also created a need to have string literal patterns of type `str` in some cases, which resulted in a number of additional special cases and inconsistencies in typechecking and in HIR-to-THIR-to-MIR lowering of patterns.

We can avoid several of those special cases by having THIR treat string-constant-values as fundamentally being of type `str`, and then using `PatKind::Deref` to represent the additional `&` layer in the common case where it is needed. This allows bare `str` patterns to require very little special treatment.

Existing tests should already do a good job of demonstrating that this implementation change does not affect the stable language.
2026-01-16 06:30:36 +00:00
Nicholas Nethercote
4c2e447027 Rename fatal_cycle as cycle_fatal.
To be consistent with the closely related `cycle_stash` and
`cycle_delay_bug`.
2026-01-16 14:55:03 +11:00
Nicholas Nethercote
9f6e7473d6 Fix a typo. 2026-01-16 14:54:20 +11:00
bors
bcf787a780 Auto merge of #151183 - jhpratt:rollup-GxmJbns, r=jhpratt
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#150607 (Add amdgpu_dispatch_ptr intrinsic)
 - rust-lang/rust#150611 (Unify and deduplicate From<T> float tests)
 - rust-lang/rust#151082 (Silence unused type param error on struct parse error)
 - rust-lang/rust#151159 (Tidying up `tests/ui/issues` 15 tests [8/N])
 - rust-lang/rust#151164 (Stabilise `EULER_GAMMA` and `GOLDEN_RATIO` constants for `f32` and `f64`.)

r? @ghost
2026-01-16 03:11:31 +00:00
Esteban Küber
2b139b786e prelude is already defaulted 2026-01-16 02:38:18 +00:00
Esteban Küber
664e19bc3a Make DisambiguatorState const-buildable 2026-01-16 02:38:18 +00:00
Esteban Küber
dd4d60f701 Provide default field in Resolver for NodeMap fields 2026-01-16 02:38:18 +00:00
Esteban Küber
2766ccfd4e Make UnordSet and UnordMap const Default and use it in Resolver 2026-01-16 02:38:18 +00:00
Esteban Küber
bfd1a9a86f Use default_field_values more in Resolver
Provide `const` functions to get around lack of `const Default` for `FxHash*` types.

Use default field values in `Resolver` more.
2026-01-16 02:38:17 +00:00
Zalathar
e673bf57c2 Also remove pat_ty from TestKind::ScalarEq 2026-01-16 12:21:48 +11:00
Zalathar
066eb6d2ea THIR patterns: Always use type str for string-constant-value nodes 2026-01-16 12:17:48 +11:00
Jacob Pratt
23f6cb5f12
Rollup merge of #151082 - issue-141403, r=Kivooeo
Silence unused type param error on struct parse error

Given

```
#[derive(Clone)]
struct B<T> {
    a: A<(T, u32)> // <- note, comma is missing here
    /// asdf
    b: u32,
}
```

do not emit unnecessary "unused `T`" error.

Fix rust-lang/rust#141403.
2026-01-15 19:35:47 -05:00
Jacob Pratt
6912c676cd
Rollup merge of #150607 - dispatch-ptr-intrinsic, r=workingjubilee
Add amdgpu_dispatch_ptr intrinsic

There is an ongoing discussion in rust-lang/rust#150452 about using address spaces from the Rust language in some way.
As that discussion will likely not conclude soon, this PR adds one rustc_intrinsic with an addrspacecast to unblock getting basic information like launch and workgroup size and make it possible to implement something like `core::gpu`.

Add a rustc intrinsic `amdgpu_dispatch_ptr` to access the kernel dispatch packet on amdgpu.
The HSA kernel dispatch packet contains important information like the launch size and workgroup size.

The Rust intrinsic lowers to the `llvm.amdgcn.dispatch.ptr` LLVM intrinsic, which returns a `ptr addrspace(4)`, plus an addrspacecast to `addrspace(0)`, so it can be returned as a Rust reference.
The returned pointer/reference is valid for the whole program lifetime, and is therefore `'static`.
The return type of the intrinsic (`&'static ()`) does not mention the struct so that rustc does not need to know the exact struct type. An alternative would be to define the struct as lang item or add a generic argument to the function.
Is this ok or is there a better way (also, should it return a pointer instead of a reference)?

Short version:
```rust
#[cfg(target_arch = "amdgpu")]
pub fn amdgpu_dispatch_ptr() -> *const ();
```

Tracking issue: rust-lang/rust#135024
2026-01-15 19:35:46 -05:00
bors
18ae990755 Auto merge of #150925 - dianqk:if-cmp, r=saethlin
Only use SSA locals in SimplifyComparisonIntegral

Fixes https://github.com/rust-lang/rust/issues/150904.

The place may be modified from the comparison statement to the switchInt terminator.

Best reviewed commit by commit.
2026-01-15 23:54:21 +00:00