5796 Commits

Author SHA1 Message Date
Mark Rousskov e936dad761 Bump beta stage0 to released 1.95.0
This also re-adds assert_matches features everywhere.
2026-04-18 20:53:28 -04:00
Jana Dönszelmann 63c212e62b make typing_mode getter 2026-04-10 11:42:02 +02:00
Jana Dönszelmann 0e0d12ccb3 introduce TypingModeEqWrapper and make TypingMode !Eq 2026-04-10 11:40:01 +02:00
Jacob Pratt defee2995b Rollup merge of #153888 - MaximilianAzendorf:issue-153583, r=Kivooeo
Avoid stack overflow in FindExprBySpan

Fixes rust-lang/rust#153583.

Deeply nested `?` desugarings can build a very deep HIR expression spine.
When `FindExprBySpan` walks that expression during error reporting, the
recursive `visit_expr` traversal can overflow the stack before rustc emits the
actual diagnostic.

This wraps the recursive expression walk in `ensure_sufficient_stack`, which
lets the compiler report the expected E0277 instead of crashing.

Added a UI regression test for a deeply nested `?` chain.
2026-04-08 23:03:58 -04:00
Jonathan Brouwer faefad7c24 Rollup merge of #154923 - cijiugechu:fix-ice-unsafe-binders-next-solver, r=TaKO8Ki
Fix ICE in next-solver dyn-compatibility check

The next solver treated error-containing dispatchability goals as proven and misclassified the trait as dyn compatible. Short-circuit receivers with type errors so object-method confirmation stays on the normal error path.

Tracking issue: rust-lang/rust#130516
Closes: rust-lang/rust#151311
2026-04-08 14:22:05 +02:00
Jonathan Brouwer 4a3978abad Rollup merge of #154745 - chenyukang:yukang-fix-span-api, r=nnethercote
Replace span_look_ahead with span_followed_by

While reviewing that PR https://github.com/rust-lang/rust/pull/154703#discussion_r3031067780, I found that magic number 100, let's remove it, and seems `span_followed_by` is a better name.
2026-04-08 14:22:01 +02:00
Jacob Pratt a1f95873a8 Rollup merge of #154609 - mejrs:local_on_const, r=fmease
Enable `#[diagnostic::on_const]` for local impls

Previously this attribute only did something if it was on a foreign impl.
2026-04-07 23:05:30 -04:00
yukang ef9b7c2b8f replace span_look_ahead with span_followed_by 2026-04-08 09:34:24 +08:00
cijiugechu 89a4742773 Fix ICE in next-solver dyn-compatibility check
The next solver treated error-containing dispatchability goals as proven and misclassified the trait as dyn compatible. Short-circuit receivers with type errors so object-method confirmation stays on the normal error path.
2026-04-07 23:42:36 +08:00
bors c3bd6289f6 Auto merge of #154758 - WaffleLapkin:aliassss, r=lcnr
`ty::Alias` refactor



This PR changes the following alias-related types from this:

```rust
pub enum AliasTyKind {
    Projection,
    Inherent,
    Opaque,
    Free,
}

pub struct AliasTy<I: Interner> {
    pub args: I::GenericArgs,
    pub def_id: I::DefId,
}

pub enum TyKind<I: Interner> {
    ...
    Alias(AliasTyKind, AliasTy<I>),
}
```
Into this:

```rust
pub enum AliasTyKind<I: Interner> {
    Projection { def_id: I::DefId },
    Inherent { def_id: I::DefId },
    Opaque { def_id: I::DefId },
    Free { def_id: I::DefId },
}

pub struct AliasTy<I: Interner> {
    pub args: I::GenericArgs,
    pub kind: AliasTyKind<I>,
}

pub enum TyKind<I: Interner> {
    ...
    Alias(AliasTy<I>),
}
```

... and then does a thousand other changes to accommodate for this change everywhere.

This brings us closer to being able to have `AliasTyKind`s which don't require a `DefId` (and thus can be more easily created, etc). Although notably we depend on both `AliasTyKind -> DefId` and `DefId -> AliasTyKind` conversions in a bunch of places still.

r? lcnr

----

A lot of these changes were done either by search & replace (via `ast-grep`) or on auto pilot, so I'm not quite sure I didn't mess up somewhere, but at least tests pass...
2026-04-07 12:56:57 +00:00
Waffle Lapkin 6ab50d53e3 ty::Alias review comments 2026-04-07 10:08:12 +02:00
Waffle Lapkin 0f767084b8 ty::Alias refactor: fixup all the compiler code 2026-04-07 10:08:12 +02:00
Jonathan Brouwer f149f4063f Rollup merge of #154875 - TaKO8Ki:regression-test-152936-regions-name, r=jackh726
Avoid duplicate diagnostic args in `RegionOriginNote::WithName`

Fixes rust-lang/rust#152936

This is a follow up to rust-lang/rust#153508.
2026-04-06 20:58:59 +02:00
mejrs 4bc2a55108 Fix diagnostic::on_const label span 2026-04-06 19:01:10 +02:00
mejrs 14ab39c42f on_const doesn't support parent_label 2026-04-06 19:00:54 +02:00
mejrs dfa2e24915 Enable diagnostic::on_const for local impls 2026-04-06 18:58:44 +02:00
Takayuki Maeda 989f4cd126 avoid duplicate diagnostic args in RegionOriginNote::WithName 2026-04-06 21:05:56 +09:00
Jonathan Brouwer cb3b8ff690 Rollup merge of #154858 - mejrs:diagnostic_eval, r=JonathanBrouwer
Change api of formatting diagnostic attribute strings.

As of recently a lot of people are creating new diagnostic attributes, but skipping its methods and doing things like `directive.message.as_ref().map(|e| e.1.format(&args)),` instead, but that skips the `tracing` instrumentation of diagnostic attribute formatting. The first commit forces people to use the right method for that.

The name `OnUnimplementedNote` also hasn't been accurate for some time.
2026-04-06 10:58:16 +02:00
Jacob Pratt 2aa5ef1c5f Rollup merge of #153615 - enthropy7:fix-ice-generics-of-crate-node, r=fee1-dead
fixed generics of crate node ICE

when `note_and_explain_type_err` is called during dyn-compatibility checking, the `body_owner_def_id` can be `CRATE_DEF_ID` because `ObligationCause::dummy()` uses it as a placeholder when there is no real body owner. calling `generics_of `on `CRATE_DEF_ID `caused an ICE because the crate root is a module and modules don't have generics. the fix guards all `generics_of` call sites by checking whether `body_owner_def_id` is `CRATE_DEF_ID` before attempting to look up generics, and skips the type parameter span labeling in that case.

i also added regression test with original ice reproduce

fixes rust-lang/rust#152335
2026-04-05 20:51:06 -04:00
mejrs 7791ac737b Rename OnUnimplementedNote to CustomDiagnostic 2026-04-05 21:43:56 +02:00
mejrs 4c97a924c2 Force all diagnostic attr formatting through eval. 2026-04-05 21:37:24 +02:00
Matthias Krüger dd46057276 Rollup merge of #154653 - mejrs:append_const_msg, r=JonathanBrouwer
Remove rustc_on_unimplemented's append_const_msg

This does nothing because it is unreachable within the compiler. It also doesn't seem that useful since all the traits it was on are `const` now.

Will make pr to rustc-dev-guide docs later.
2026-04-03 20:47:38 +02:00
Matthias Krüger ce74af2b00 Rollup merge of #154675 - chenyukang:yukang-fix-149546-private-field-deref-fresh, r=estebank
Improve shadowed private field diagnostics

Fixes rust-lang/rust#149546

I tried to extend the diagnostic to more scenarios, like method call, type mismatch errors.

r? @estebank
2026-04-03 20:47:37 +02:00
enthropy7 f1a4ae02ed fix ice generics of crate node 2026-04-03 18:18:08 +03:00
yukang ae899cc4e2 Clarify private field autoderef notes 2026-04-03 13:50:04 +08:00
Jonathan Brouwer 1c155950d7 Rollup merge of #154578 - jdonszelmann:rename-probe, r=lcnr,boxyuwu
Rename `probe_ty_var` to `try_resolve_ty_var`

r? @lcnr
2026-04-02 22:13:55 +02:00
Jonathan Brouwer 483dc59aa2 Rollup merge of #154710 - khyperia:rename-ogca, r=BoxyUwU
opaque_generic_const_args -> generic_const_args

This is part of a larger rework/plan of how to move forward with GCA. Please comment here, or message/ping me or @BoxyUwU if you have questions about the future of oGCA/GCA!

For ease of review, the first commit is renaming, and the second commit is removing the opaque parts.

fyi @camelid

r? @BoxyUwU
2026-04-02 22:13:51 +02:00
Jonathan Brouwer 828e302c7b Rollup merge of #153105 - makai410:erase-if-error, r=lcnr
Compute the result of a projection type with region errors

Fixes: rust-lang/rust#152682

With the old trait solver, `type_known_to_meet_bound_modulo_regions()` isn't really operating "modulo regions" if there are any region errors, since `normalize` will just return a type error to the trait solver if given a ty with a region error, which then starts cascading when there are so many assumptions.

So I think it would be good to erase regions if there are any region errors before we normalize the type when collecting predicates for confirmation.

That said, I somehow feel like this is kind of ad-hoc... I'd really appreciate if someone more familiar with this code could take a closer look :3
2026-04-02 22:13:48 +02:00
khyperia 9465366ec4 remove the o from oGCA 2026-04-02 12:06:25 +02:00
khyperia 0e2c554e74 rename opaque_generic_const_args to generic_const_args 2026-04-02 12:04:25 +02:00
yukang ce46df2fca Sort shadowed field notes by source order 2026-04-02 17:42:27 +08:00
Jana Dönszelmann 28b06a67b3 Rename probe_ty_var to try_resolve_ty_var
Co-authored-by: khyperia <953151+khyperia@users.noreply.github.com>
2026-04-02 11:21:02 +02:00
yukang 86f99d2d4d extend note for private field to method call 2026-04-01 20:15:52 +08:00
yukang 257d655314 extend note for private field to more diagnostics 2026-04-01 20:01:06 +08:00
yukang 62db1ebca3 Improve shadowed private field diagnostics 2026-04-01 20:01:06 +08:00
Makai 339fb64d1c skip early return for region-only errors in projection types 2026-04-01 16:40:02 +08:00
yukang 95d5ecf3ab Fix associated bound suggestion span issue 2026-04-01 09:21:45 +08:00
mejrs b6bdfedad6 Avoid needless clone. 2026-03-31 23:34:40 +02:00
mejrs 8c043676a1 Refactor get_standard_error_message 2026-03-31 23:21:46 +02:00
mejrs 70dd3bceca Remove rustc_on_unimplemented's append_const_msg 2026-03-31 20:46:21 +02:00
Trevor Gross 472c531d7a Rollup merge of #154551 - chenyukang:yukang-fix-146204-assert-ne-suggestion-span, r=JohnTitor
Skip suggestions pointing to macro def for assert_eq

Fixes rust-lang/rust#146204

It's better to suggest:
```console
help: consider borrowing here
 --> src/main.rs:3:16
  |
 3|      assert_ne!(&buf, b"----");
  |                 +
```
but i don't want to give a too heuristic but not general enough fix, let suppress them.
2026-03-31 05:08:25 -04:00
Trevor Gross 68d2666fc2 Rollup merge of #153790 - zedddie:transmutation-regression, r=jdonszelmann
Fix regression when dealing with generics/values with unresolved inference

Follow up for rust-lang/rust#151703, fixing regression caused in rollup rust-lang/rust#152825

Forgot to handle generics & unresolved inference variables (as in `get_safe_transmute_error_and_reason`) in my previous PR. This followup checks for them before trying to normalize.

I am not completely sure its right approach to have this check cloned but as `select_transmute_obligation_for_reporting` fn just chooses obligation and doesn't actually return an error, this check shouldn't be removed from `get_safe_transmute_error_and_reasnon`. If there is any better solution, let me kmow.

Fixes: rust-lang/rust#153755

r? @jdonszelmann
2026-03-31 05:08:24 -04:00
Trevor Gross 3479a1d553 Rollup merge of #153574 - TaKO8Ki:self-referential-param-env-normalization-ice, r=lcnr
Avoid ICE when param-env normalization leaves unresolved inference variables

Fixes rust-lang/rust#153354

Because the impl is already ill-formed, those variables are not fully constrained, so zfully_resolve` fails. We previously treated that as an immediate compiler bug with `span_bug!`, which caused an ICE on invalid input.
2026-03-31 05:08:23 -04:00
yukang 6518de37d4 Skip suggestions pointing to extern macro def for assert_eq 2026-03-30 22:58:03 +08:00
Takayuki Maeda d29c489599 add self-referential param-env normalization regression
avoid ICE on invalid param-env normalization

remove 120033 crash test

fix comments

use rustc_no_implicit_bounds

set #![allow(incomplete_features)]
2026-03-30 22:50:31 +09:00
Jacob Pratt 7275f7e2e3 Rollup merge of #154564 - estebank:tweak-wf-errors, r=Kivooeo
Tweak wording of E0275 WF errors

Modify the main error message to read better:

```
error[E0275]: overflow evaluating whether `&'a mut Bar` is well-formed
```
2026-03-30 05:13:18 -04:00
Jacob Pratt a2cc7a9f0a Rollup merge of #154563 - estebank:multiline-binop, r=TaKO8Ki
Point at binop lhs and rhs when expression is multiline

```
error[E0277]: cannot add `()` to `u32`
  --> $DIR/multiline-span-simple.rs:13:18
   |
LL |       foo(1 as u32 +
   |           -------- ^ no implementation for `u32 + ()`
LL |
LL | /         bar(x,
LL | |
LL | |             y),
   | |______________-
```
2026-03-30 05:13:17 -04:00
Esteban Küber 0740609ea3 Point at binop lhs and rhs when expression is multiline
```
error[E0277]: cannot add `()` to `u32`
  --> $DIR/multiline-span-simple.rs:13:18
   |
LL |       foo(1 as u32 +
   |           -------- ^ no implementation for `u32 + ()`
LL |
LL | /         bar(x,
LL | |
LL | |             y),
   | |______________-
```
2026-03-29 21:07:54 +00:00
Esteban Küber dae0c01108 Tweak wording of E0275 WF errors
Modify the main error message to read better:

```
error[E0275]: overflow evaluating whether `&'a mut Bar` is well-formed
```
2026-03-29 18:25:55 +00:00
Ralf Jung d289cc4a38 Rollup merge of #154029 - xtqqczze:clear, r=joboet
Replace `truncate(0)` with `clear()`
2026-03-28 13:15:50 +01:00