2926 Commits

Author SHA1 Message Date
Jonathan Brouwer 139bcba8f6 Rollup merge of #155822 - mejrs:default_fmt_args, r=JonathanBrouwer
Add default field values to diagnostic FormatArgs

This type has a decent amount of unused fields (and I am planning to add more).
2026-04-26 19:06:32 +02:00
Jonathan Brouwer 37b53a9461 Rollup merge of #155789 - JonathanBrouwer:attribute-ext, r=mejrs
Cleanups to `AttributeExt`

r? @mejrs

- Makes some functions take `ast::Attribute` instead of `impl AttributeExt`
- Remove `deprecation_note` from `AttributeExt`, since the two implementations are basically seperate
2026-04-26 19:06:29 +02:00
mejrs 48fe89f994 add default field values to diagnostic FormatArgs 2026-04-26 14:23:53 +02:00
Jonathan Brouwer 3b59d9d58e Rollup merge of #155783 - qaijuang:issue-150566-cfg-trace-suggestions, r=JonathanBrouwer
Do not suggest internal cfg trace attributes

Fixes rust-lang/rust#150566.
2026-04-25 23:07:53 +02:00
Jonathan Brouwer f113540cec Remove unnecessary uses of AttributeExt 2026-04-25 21:25:43 +02:00
bors 9838411cb7 Auto merge of #155257 - petrochenkov:visatleast, r=adwinwhite
privacy: Assert that compared visibilities are (usually) ordered



And make "greater than" (`>`) the new primary operation for comparing visibilities instead of "is at least" (`>=`).
2026-04-25 16:15:55 +00:00
Qai Juang b17822575c Do not suggest internal cfg trace attributes 2026-04-25 11:47:34 -04:00
bors fb76025f2f Auto merge of #155460 - cjgillot:unmut-resolver-ast, r=oli-obk
Do not modify resolver outputs during lowering



Split from https://github.com/rust-lang/rust/pull/142830

I believe this achieves the same thing as https://github.com/rust-lang/rust/pull/153656 but in a much simpler way. 

This PR forces AST->HIR lowering to stop mutating resolver outputs. Instead, it manages a few override maps that only live during lowering and are dropped afterwards.

r? @petrochenkov 
cc @aerooneqq
2026-04-25 10:01:32 +00:00
Camille Gillot 0705bbac94 Do not modify resolver outputs during lowering
Co-authored-by: Camille Gillot <gillot.camille@gmail.com>
2026-04-24 23:58:52 +00:00
mejrs c2916be8d7 Permit {This} in diagnostic attribute format literals 2026-04-24 19:59:32 +02:00
Vadim Petrochenkov 714df2bf00 privacy: Assert that compared visibilities are (usually) ordered
Also use `greater_than` instead of `is_at_least` for comparing visibilities, which we can do because visibilities are asserted to be ordered now.
2026-04-23 18:22:48 +03:00
Jonathan Brouwer 6f6e6bb485 Rollup merge of #155632 - nnethercote:split-Metadata, r=mejrs
Some metadata cleanups

Details in individual commits.

r? @mejrs
2026-04-22 19:18:32 +02:00
Jonathan Brouwer 5e48418496 Rollup merge of #155587 - oli-obk:feed-visibility-no-hash, r=petrochenkov
Immediately feed visibility on DefId creation

This system was originally introduced in rust-lang/rust#121089

This PR was enabled by refactorings in rust-lang/rust#154945, because after that, the visibility feeding happens directly after the `DefId` creation, so we don't need to go through the intermediate hash table anymore

Should unblock rust-lang/rust#138995
2026-04-22 19:18:29 +02:00
yukang 8d75f0cbfc add on_unmatch_args 2026-04-22 19:28:44 +08:00
Nicholas Nethercote f0ebd66eaa Remove unused tcx params.
They are unused because of the previous commit.
2026-04-22 13:54:57 +10:00
bors f9988fefd3 Auto merge of #155611 - JonathanBrouwer:rollup-hUV99y1, r=JonathanBrouwer
Rollup of 5 pull requests

Successful merges:

 - rust-lang/rust#155546 (Improve E0308 error message for `impl Trait` return mismatches)
 - rust-lang/rust#152834 (Fix incorrect `let` to `const` suggestion for pattern bindings)
 - rust-lang/rust#155425 (Remove duplicated `Flags` methods.)
 - rust-lang/rust#155547 (Use per-parent disambiguators everywhere)
 - rust-lang/rust#155590 (Remove AttributeLintKind variants - part 5)
2026-04-21 23:34:47 +00:00
Oli Scherer 3070ce9d1b Immediately feed visibility on DefId creation 2026-04-21 22:45:34 +02:00
Oli Scherer af03b49b25 Handle MacCall items directly in the def collector
instead of entangling it with the brg logic
2026-04-21 22:45:03 +02:00
Oli Scherer 209a2a6e33 delegation macros are never handled in the def collector 2026-04-21 22:45:03 +02:00
Oli Scherer 797e68f240 Move variant ctor creation into the brg 2026-04-21 22:45:03 +02:00
Oli Scherer af3e34bf65 Stop creating ctor def ids for unions and move the ctor def id creation into the brg 2026-04-21 22:45:03 +02:00
Jonathan Brouwer aa3335484f Rollup merge of #155547 - aerooneqq:better-disambiguators, r=oli-obk
Use per-parent disambiguators everywhere

This PR addressing the following concerns about per-parent disambiguators (rust-lang/rust#153955):

- DisambiguatorState is removed, PerParentDisambiguatorState is now used everywhere,
- Steals were removed from every per-parent disambiguator in resolver,
- It adds `parent` field in `PerParentDisambiguatorState` in `#[cfg(debug_assertions)]` for asserting that per-parent disambiguator corresponds to the same `LocalDefId` which is passed into `create_def`,
- ~Removes `Disambiguator` trait replacing it with `Disambiguator` enum, with this change we no longer expose `next` method (as trait should be public otherwise the warning will be emitted). It may affect perf in a negative way though.~

~Those changes should not fix perf issues that were [reported](https://github.com/rust-lang/rust/pull/153955#issuecomment-4269223191), perf run that was attempted [before](https://github.com/rust-lang/rust/pull/153955#issuecomment-4214516698) showed much better results. Performance can be probably fixed by removing per-parent disambiguators replacing them with a single one as it was before, then it will be passed to AST -> HIR lowering and modified. For delayed owners we can store ~followup disambiguators as it was in the beginning of the rust-lang/rust#153955~ per-parent disambiguators. This solution should save achievements from rust-lang/rust#153955 (removed `DefPathData` variants).
However, I would prefer to keep per-parent disambiguators as it seems a better architectural solution for me.~

r? @petrochenkov
cc @oli-obk
2026-04-21 20:42:52 +02:00
lapla 90c03d8ff4 Flatten nested tuple destructuring 2026-04-22 00:24:19 +09:00
lapla a687f0b658 Fix incorrect let to const suggestion for pattern bindings 2026-04-22 00:24:08 +09:00
aerooneqq 2e6a082513 Use per-parent disambiguators 2026-04-21 18:23:40 +03:00
Jonathan Brouwer 04dfc2b595 Rollup merge of #152611 - CoCo-Japan-pan:fix-148009, r=jackh726
Modify error message of importing inherent associated items when `#[feature(import_trait_associated_functions)]` is enabled

Fixes rust-lang/rust#148009

This PR improves the diagnostic for importing inherent associated items from a struct or union when
`#[feature(import_trait_associated_functions)]` (rust-lang/rust#134691) is enabled.

Previously, this would result in a "not a module" error. This change provides a more specific error message clarifying that only trait associated items can be imported, while inherent associated items remain ineligible for import.

Enums are currently excluded from this change because their variants are valid import targets and require distinct handling.
2026-04-21 16:53:37 +02:00
bors 4fbae3e309 Auto merge of #154945 - oli-obk:merge-visitors-def-collector-brg, r=petrochenkov
Merge BuildReducedGraphVisitor into DefPathVisitor

These two visitors run right after each other on the same immutable AST. There's also a hash map for transferring the TyCtxtFeed created in the def collector to the BRG when it visits the same items. There are possibly more avenues for sharing logic, but I want to keep this PR simple.

only opening for perf runs for now. I'm still investigating how to ensure that future changes don't introduce subtle bugs by forgetting that def collection and reduced graph building are one pass now

Best reviewed commit-by-commit. I took a lot of care for making the individual changes reviewable, but all the `Merge *` commits aren't able to compile libcore until the last one.
2026-04-20 23:10:06 +00:00
Oli Scherer f2c79f3fc6 Handle attributes entirely in the def collector 2026-04-20 13:56:30 +02:00
Oli Scherer c8862c74b2 Avoid matching on the assoc item kind twice 2026-04-20 13:56:30 +02:00
Oli Scherer e61773669a Inline macro calls in assoc item position logic 2026-04-20 13:56:30 +02:00
Oli Scherer 690df236c2 Deduplicate the expansion field between def collection and brg 2026-04-20 13:56:30 +02:00
Oli Scherer 095f11c9ec Inline the now-trivial build_reduced_graph into its sole caller 2026-04-20 13:56:30 +02:00
Oli Scherer 0a714a26a5 Fix use trees 2026-04-20 13:53:15 +02:00
Jonathan Brouwer 1d9b32a5ac Rollup merge of #155346 - GrigorenkoPV:single-use-lifetimes, r=jdonszelmann
`single_use_lifetimes`: respect `anonymous_lifetime_in_impl_trait`

Tracking issue: rust-lang/rust#44752 (for the `single_use_lifetimes` lint; the `anonymous_lifetime_in_impl_trait` feature seems to have no tracking issue).

Closes rust-lang/rust#129255
Closes rust-lang/rust#135550

@rustbot label A-diagnostics A-lifetimes A-lints D-incorrect L-single_use_lifetimes
2026-04-20 13:52:05 +02:00
Oli Scherer 2892564a85 Merge visit_attribute 2026-04-20 13:34:08 +02:00
Oli Scherer d67a570547 Merge visit_expr, visit_pat and visit_ty 2026-04-20 13:34:08 +02:00
Oli Scherer f69d719e1c Merge visit_field_def 2026-04-20 13:34:08 +02:00
Oli Scherer d2f476e57c Merge visit_variant 2026-04-20 13:34:08 +02:00
Oli Scherer 69aedb5ef2 Merge visit_crate 2026-04-20 13:33:48 +02:00
Oli Scherer 51d1e839d0 Merge visit_where_predicate 2026-04-20 13:33:48 +02:00
Oli Scherer 32ae2e5122 Merge visit_generic_param 2026-04-20 13:33:48 +02:00
Oli Scherer 05a49b6caa Merge some simple visitor functions 2026-04-20 13:33:48 +02:00
Oli Scherer b1ec02fc12 Merge visit_assoc_item 2026-04-20 13:33:48 +02:00
Oli Scherer 3df953207d Merge visit_block 2026-04-20 13:33:48 +02:00
Oli Scherer f98355e1ee Merge visit_stmt 2026-04-20 13:33:48 +02:00
Oli Scherer a2cf11a976 Merge visit_foreign_item 2026-04-20 13:33:48 +02:00
Oli Scherer 90d0b41ef1 Merge visit_item 2026-04-20 13:33:48 +02:00
Oli Scherer 393f3e0110 Merge BuildReducedGraphVisitor initialization into DefPathVisitor 2026-04-20 13:33:24 +02:00
Oli Scherer 8a4f0dfb62 Rename DefCollector::resolver to r to match BuildReducedGraphVisitor::r 2026-04-20 13:32:54 +02:00
Vadim Petrochenkov 394c7172f4 resolve: Make sure visibilities of import declarations make sense
That they are all ordered inside the module and not more private than the module itself
The `import_decl_vis` logic is reused when reporting `ambiguous_import_visibilities` lint
Some asserts are hardened
Some relevant tests are added
2026-04-20 13:41:33 +03:00