Commit Graph

2944 Commits

Author SHA1 Message Date
Jacob Pratt bd8d0260ca Rollup merge of #156091 - Bryntet:move-tools, r=JonathanBrouwer
change field `tools` on `AttributeParser` to hold `&'tcx RegisteredTools`

Makes tools actually stored, and not just tool names

this was originally part of rust-lang/rust#155691 but was split out to make that PR smaller.

r? @petrochenkov
cc @JonathanBrouwer
2026-05-03 00:25:34 -04:00
mejrs 4a13f36265 Remove more spans from AttributeKind 2026-05-02 17:41:30 +02:00
Edvin Bryntesson 76fd1b3df3 make tools on AttributeParser hold reference to RegisteredTools 2026-05-02 16:02:34 +02:00
Jonathan Brouwer 7be04ef0a6 Rollup merge of #155948 - SynapLink:fix/pub-visibility-order, r=petrochenkov,mu001999
Fix order-dependent visibility diagnostics

Fixes rust-lang/rust#40066.
Fixes https://github.com/rust-lang/rust/issues/109657.
Delay visibility path diagnostics until module collection has finished, so paths to later non-ancestor modules report E0742 instead of an unresolved path error.
2026-05-01 13:10:34 +02:00
Jacob Pratt 894bdf298e Rollup merge of #155980 - nnethercote:mv-feature-methods, r=TaKO8Ki
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.

r? @TaKO8Ki
2026-04-30 22:28:33 -04:00
Jacob Pratt 654c350837 Rollup merge of #154610 - jakubadamw:issue-13065, r=TaKO8Ki
Suggest public re-exports when a private module makes an import path inaccessible

This is an attempt at solving rust-lang/rust#13065.

When a `use` path fails because it passes through a private module (E0603), and a public re-export of the target item exists elsewhere, the compiler will now suggest importing through that re-export instead.

For example, given:

```rust
mod outer {
    pub use self::inner::MyStruct;
    mod inner {
        pub struct MyStruct;
    }
}

use outer::inner::MyStruct; // error: module `inner` is private
```

the compiler will now suggest use `outer::MyStruct`; - the publicly accessible path - rather than just pointing at the private module definition and leaving the user to figure out the alternative.

When possible, relative paths are suggested, including those using `super` (currently capped at a maximum of one `super` path item).

The newly added test is parametrised by editions because of the change in behaviour around `crate::`-prefixed imports in edition 2018. Perhaps that’s an overkill – I’ll be happy to remove the variations for editions 2021 and 2024.

Closes rust-lang/rust#13065.
2026-04-30 22:28:31 -04:00
Jacob Pratt 248756dc40 Rollup merge of #153566 - JohnTitor:sugg-generic-params-from-outer-item-err, r=wesleywiser
Add suggestion for E0401 on inner const items

Fix rust-lang/rust#68373
r? @estebank
2026-04-30 22:28:30 -04:00
SynapLink f7c62f533e Fix order-dependent visibility diagnostics 2026-04-30 20:51:53 +02: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
Vadim Petrochenkov d28ea81a98 resolve: Extend ambiguous_import_visibilities deprecation lint to glob-vs-glob ambiguities 2026-04-29 22:34:16 +03:00
Jonathan Brouwer 67cf0dee49 Remove most usages of Stage 2026-04-29 07:41:14 +02:00
Jonathan Brouwer e1332f4893 Remove should_emit from stage 2026-04-29 07:41:09 +02:00
mu001999 d93395c3ff Remove the special case of ::self after edition 2018 2026-04-27 14:02:25 +08:00
mu001999 8b584ebcf6 Remove type_ns_only 2026-04-27 14:02:25 +08:00
mu001999 4467940555 Support trailing self in normal paths 2026-04-27 14:02:22 +08:00
mu001999 d5a26d811b Support trailing self in import paths 2026-04-27 10:58:30 +08:00
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