Commit Graph

5905 Commits

Author SHA1 Message Date
Jonathan Brouwer 241bbc18fc Rollup merge of #156942 - GuillaumeGomez:rm-skip_arg-attrs, r=JonathanBrouwer
Remove unneeded `#[skip_arg]` attributes

@mejrs talked with me about the `Diagnostic` rework that happened recently and suggested that the `skip_arg` might be unneeded. This PR removes all of them, except one. I'll run a perf check to see if it's actually worth keeping around or if we can just remove this attribute altogether (or eventually do the same thing in the proc-macro directly).

cc @JonathanBrouwer

r? ghost
2026-05-27 08:14:28 +02:00
Jonathan Brouwer 903a08c0b0 Rollup merge of #156161 - mejrs:this_formatargs, r=oli-obk
rustc_on_unimplemented: introduce format specifiers

...as printing options for the annotated item.

See also the test and dev guide prose. This only affects rustc_on_unimplemented, not (yet) the other diagnostic attributes. I plan to do that in some later PR.

```rust
#![feature(rustc_attrs)]

#[rustc_on_unimplemented(
    message = "normal: {This}, path: {This:path},  resolved: {This:resolved}"
)]
pub trait Trait<'lifetime, const CONST_GENERIC: usize, A, B> where A: Send {}
```
will do:
```
normal: Trait, path: Trait<'lifetime, CONST_GENERIC, A, B>,  resolved: Trait<'_, 6, u8, _>
```
2026-05-26 13:42:16 +02:00
Guillaume Gomez 9e96efac62 Remove unneeded #[skip_arg] attributes 2026-05-26 12:26:05 +02:00
qaijuang 658e9fb052 fix do_not_recommend span fallback for proc macros 2026-05-20 02:18:16 -04:00
qaijuang 7aa831f47a preserve spans when hiding do_not_recommend impls 2026-05-17 16:12:40 -04:00
bors 281c97c324 Auto merge of #156518 - estebank:match-rustfmt, r=mejrs
[style] rustfmt `match`es with comments in or-patterns

Using https://github.com/rust-lang/rustfmt/pull/6893, I reformatted the whole codebase. The result is that `match`es that *should have* been formatted under normal circumstances but are getting skipped now got their expected format. These match expressions were being entirely skipped because they contain or-patterns with comments in between patterns, causing rustfmt to bail out entirely. The or-patterns with comments themselves remain untouched, but now the match arm bodies and other patterns without comments do get formatted under that PR.

Because the fix in rustfmt isn't landed yet, I reworked some of the or-patterns with comments so that formatting doesn't regress. Tried doing this only in larger blocks that are more likely to regress in the meantime.

(Introduced and) removed a bunch of stray backticks \` likely left after an editor autoclosed the intended closing \`, resulting in <code>\`name\`\`</code> in comments.
2026-05-17 01:27:37 +00:00
Jonathan Brouwer f6faa05477 Rollup merge of #156325 - cijiugechu:generics-transmutefrom, r=BoxyUwU
Don't treat const param default as projection

Avoid treating const param default as associated const projection.

Closes rust-lang/rust#156293
2026-05-13 11:46:41 +02:00
Esteban Küber 701e4942ed Remove a bunch of stray backticks
Thanks VSCode!
2026-05-13 02:40:58 +00:00
Esteban Küber 31e0383ea6 rustfmt matches with comments in or-patterns
Using https://github.com/rust-lang/rustfmt/pull/6893, reformat the codebase. The result is that matches that *would have* been formatted under normal circumstances get their expected format. These match expressions were being entirely skipped because they contain or-patterns with comments in between patterns, causing rustfmt to bail out entirely. The or-patterns with comments themselves remain untouched, but now the match arm bodies and other patterns without comments do get formatted under that PR.

Because the fix in rustfmt isn't landed yet, I reworked some of the or-patterns with comments so that formatting doesn't regress. Tried doing this only in larger blocks that are more likely to regress in the meantime.
2026-05-13 02:35:29 +00:00
bors c8c4c83d57 Auto merge of #156224 - khyperia:unnormalized-migration, r=BoxyUwU
Unnormalized migration: assert_fully_normalized, struct_tail, and `field.ty`



tracking issue: https://github.com/rust-lang/rust/issues/155345 (first checkbox, and partial second checkbox, of that issue)

I'm going a bit slower than expected (less free time than I'd hope, lots of GCA work that I'm doing instead), and figured I'd just submit what I have now rather than building up a big batch of changes. Slow and steady!

r? @lcnr
2026-05-13 00:16:00 +00:00
lcnr 3fb166fb6f tiny PR 2026-05-12 21:58:50 +02:00
khyperia 57b3e84ed4 Unnormalized migration: struct_tail takes fn taking Unnormalized 2026-05-12 20:45:13 +02:00
khyperia 869c941be9 Unnormalized migration: introduce assert_fully_normalized 2026-05-12 20:45:13 +02:00
Jonathan Brouwer 4ce7ac120c Rollup merge of #156287 - cyrgani:unbox-2, r=petrochenkov
move more compiler crates away from `box_patterns`

Part of https://github.com/rust-lang/rust/issues/156110.
2026-05-12 18:53:35 +02:00
Boxy df7bb96831 review 2026-05-11 21:32:42 +02:00
Boxy ae6b75e395 new stuff 2026-05-11 20:48:08 +02:00
Boxy cadc26f0ce produce new region constraints 2026-05-11 20:48:08 +02:00
cyrgani 82ebc72b92 use deref_patterns in rustc_trait_selection 2026-05-10 21:05:37 +00:00
cijiugechu 5148dacbb8 Don't treat const param default as projection 2026-05-08 22:13:42 +08:00
Jana Dönszelmann 644250d8b6 refactor compute_goal_fast_path: turn into a single match 2026-05-08 10:03:55 +02:00
bors 365c0e1d7a Auto merge of #155443 - jdonszelmann:canonical, r=lcnr
Improve caching by introducing `TypingMode::ErasedNotCoherence`



r? @lcnr


This introduces `TypingMode::ErasedNotCoherence`. Most typing modes contain a list of opaque types, which are quite often unused during canonicalization. With this change, any time we try canonicalization, we replace whichever typing mode we're currently in with `ErasedNotcoherence`, attempt to canonicalize, and if that fails *retry* in the original typing mode. If erased mode succeeds, this is beneficial because that way the opaque types don't end up in the cache key, allowing more cache reuse.

This seems to have a small (0.5%) slowdown on most programs, but a dramatic (>60%) speedup in specific cases like the rustc-perf `wg-grammar` benchmark. Some more improvements are expected with "eager normalization", which is work that's under way right now.
2026-05-06 13:55:09 +00:00
Jana Dönszelmann f0c1798a3a prefer assert_not_erased over matching+unreachable 2026-05-06 10:18:21 +02:00
Jana Dönszelmann 8ca4e431ef return ambiguous in fast path, factor out method to check if no opaques in scope 2026-05-06 10:18:21 +02:00
Jana Dönszelmann 9fda7e0c97 Refactor fetch_eligible_assoc_item output 2026-05-06 10:18:21 +02:00
Jana Dönszelmann 7ff71be015 Try to canonicalize with erased opaques, retry when opaques are used. 2026-05-06 10:18:21 +02:00
Jana Dönszelmann 630f0d2bbb type safety for typing mode outside trait solver which can't be erased-not-coherence 2026-05-06 10:18:21 +02:00
Jana Dönszelmann a93f8c0579 Introduce ErasedNotCoherence typing mode 2026-05-06 10:13:29 +02:00
Jacob Pratt 74d6b21eab Rollup merge of #156148 - oli-obk:all_impls, r=lqd
Use `all_impls` instead of handrolling it

just found this while looking at other things
2026-05-05 22:50:25 -04:00
Jacob Pratt b2cc990df0 Rollup merge of #155341 - khyperia:non-type-const, r=BoxyUwU
generic_const_args: allow paths to non type consts

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

Non type consts should be usable in the type system in `feature(generic_const_args)`. These are directly plugged into the constant evaluator, unlike type consts, which are attempted to be reasoned about by the type system.

Inherent associated constants are not supported at this time, due to complications around how generic arguments are represented for them (it's currently a mess). The mess is being cleaned up (e.g. https://github.com/rust-lang/rust/pull/154758), so instead of trying to hack support in before the refactoring is done, let's just wait to be able to implement it more cleanly.

r? @BoxyUwU
2026-05-05 22:50:18 -04:00
mejrs 008ea3a340 rustc_on_unimplemented: introduce format specifiers as printing options for the annotated item. 2026-05-05 18:26:18 +02:00
khyperia cb2c5fc540 generic_const_args: allow paths to non type consts 2026-05-05 17:35:17 +02:00
Oli Scherer 6865172e8c Use all_impls instead of handrolling it 2026-05-05 17:10:25 +02:00
Jonathan Brouwer b503949164 Rollup merge of #156172 - ShoyuVanilla:slowbro, r=lcnr
Implement a new flag `-Zdisable-fast-paths` in trait solving

Discussion: [#t-types/trait-system-refactor > ask for help @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/364551-t-types.2Ftrait-system-refactor/topic/ask.20for.20help/near/583953725)

r? lcnr
2026-05-05 14:25:23 +02:00
Jonathan Brouwer 73e5912d1e Rollup merge of #156058 - qaijuang:issue-151393, r=JohnTitor
Print HRTB binders before fn qualifiers

Fixes rust-lang/rust#151393

This PR updates the custom fn-signature diff used in type mismatch diagnostics to print higher-ranked binders before fn qualifiers.

We might want to update reference also: https://github.com/rust-lang/reference/blob/581920f9109f141b88b860b3e1e8359e3896a150/src/items/external-blocks.md?plain=1#L60
2026-05-05 14:25:23 +02:00
Shoyu Vanilla 4432f6bf82 Implement a new flag -Zdisable-fast-paths in trait solving 2026-05-05 19:46:30 +09:00
Nicholas Nethercote 2cf48841f1 Remove silly FmtPrinter<'tcx, 'tcx> instance.
This doesn't match any of the other uses.
2026-05-04 15:50:46 +10:00
Nicholas Nethercote 67ba480fdb Remove unused 'tcx lifetime from trait Print. 2026-05-04 14:04:55 +10:00
Jonathan Brouwer 43fbdfd2f4 Rollup merge of #153536 - zedddie:const-param-ty-unchecked-gate, r=BoxyUwU
Add `const_param_ty_unchecked` gate

Add `const_param_ty_unchecked` internal feature gate to skip `ConstParamTy_` trait enforcement on type. Provides an escape hatch for writing tests and examples that use const generics without needing to ensure all fields implement `ConstParamTy_`.

r? BoxyUwU
2026-05-03 19:23:52 +02:00
Jacob Pratt c3afa21a40 Rollup merge of #156065 - mejrs:spanculler, r=JonathanBrouwer
Remove unused spans from AttributeKind

Recently I noticed some spans in diagnostic attributes were never used. I went through and checked the other variants too.
2026-05-03 00:25:33 -04:00
Jacob Pratt b7c65513ba Rollup merge of #155940 - mejrs:filter, r=jdonszelmann
refactor rustc_on_unimplemented's filtering

Previously when you had a
```rust
pub struct Directive {
    pub is_rustc_attr: bool,
    pub condition: Option<OnUnimplementedCondition>,
    pub subcommands: ThinVec<Directive>,
    pub message: Option<(Span, FormatString)>,
    ...
}
```
that condition would control the emission of the message, label, notes etc. I've changed that to
```rust
pub struct Directive {
    pub is_rustc_attr: bool,
    pub filters: ThinVec<(Filter, Directive)>,
    pub message: Option<(Span, FormatString)>,
    ...
```

so that the message etc is always emitted, and there's a vec of tuples with (filter, directive) where the filter controls whether that directive is even emitted,  which i think is much clearer. That also makes it easier to not have to do the reverse iteration thing and this makes it so that notes are emitted in declaration order (with nonfiltered options always last).

The rename is because I plan on making it available to other diagnostic attributes at some point (very wip) so `OnUnimplementedCondition` and the like would have to be renamed anyway.
2026-05-03 00:25:32 -04:00
mejrs 061017274d rename "condition" to "filter" 2026-05-02 18:00:10 +02:00
mejrs 4a13f36265 Remove more spans from AttributeKind 2026-05-02 17:41:30 +02:00
Adwin White dbba04e032 use the new routine to eagerly normalize 2026-05-02 16:11:12 +08:00
Adwin White e82c3c80ef add a new normalization routine that can handle ambiguity 2026-05-02 16:11:12 +08:00
Guillaume Gomez e95df7d6d5 Rollup merge of #155749 - ShoyuVanilla:leakcheck-vis, r=lcnr
`-Znext-solver` Ignore region constraints from the nested goals in leakcheck

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/251
Fixes https://github.com/rust-lang/rust/issues/140577
Fixes https://github.com/rust-lang/rust/issues/153596
2026-05-02 04:12:05 +02:00
Qai Juang 5dfe7842b5 diagnostics: print HRTB binders before fn qualifiers 2026-05-01 13:53:43 -04:00
Shoyu Vanilla e43a1b5b44 -Znext-solver Ignore region constraints from the nested goals in leakcheck 2026-05-02 00:11:43 +09:00
Nicholas Nethercote 6d79bc6f01 Move feature* methods from parse mod to errors mod.
As the FIXME comment says, these no longer use `ParseSess` and so the
`parse` mod is not a good place for them. The `errors` mod is a better
home.
2026-04-30 12:02:33 +10:00
Jonathan Brouwer a0ef691e5a Rollup merge of #155861 - oli-obk:effect-bound-suggestions, r=jdonszelmann
Suggest `[const] Trait` bounds in more places

Right now we have some special logic in the const checker for emitting `[const] Trait` suggestions, but I'm trying to handle that similarly to how it is handled for normal `Trait` clauses. This is just a small step in how it will look on the UX side, which should make my follow-up PRs affect tests less and just be a refactoring
2026-04-29 23:51:35 +02:00
Shoyu Vanilla (Flint) dce5b97c52 Rollup merge of #155648 - ShoyuVanilla:maybe-stalled-on-couroutines, r=lcnr
`-Znext-solver` Propagate `stalled_on_coroutines` as a field in `Certainty::Maybe`

..instead of collecting them with a `ProofTreeVisitor`

Fixes https://github.com/rust-lang/trait-system-refactor-initiative/issues/270
2026-04-29 10:40:46 +09:00