Skip to content

Remove StashKey::AssociatedTypeSuggestion - #162942

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
nnethercote:rm-StashKey-AssociatedTypeSuggestion
Sep 24, 2026
Merged

rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
nnethercote:rm-StashKey-AssociatedTypeSuggestion

Conversation

@nnethercote

Copy link
Copy Markdown
Contributor

Currently it's used in a really hacky way: a diagnostic with an empty message and some suggestions is stashed. Later on it might be retrieved and its suggestions extracted. It uses Level::Allow so that it isn't printed by emit_stashed_diagnostics at shutdown if it hasn't been retrieved.

This isn't a normal stashed diagnostic, more just a case of "save some information that might be useful for diagnostics later". We can record the information more simply and directly.

This commit adds paths_matching_assoc_types fields to Resolver and ResolverGlobalCtxt. These store the spans of the paths of interest. The new subdiagnostic AssocTypeWithSameName is used to construct the relevant suggestions when they are needed. Much nicer. The old approach removed the stashed diagnostic and the new approach doesn't remove the set entry, so a single span could conceivably match more than once, presumably a good thing, though this doesn't show up in the test suite.

r? @davidtwco

@rustbot

rustbot commented Sep 18, 2026

Copy link
Copy Markdown
Collaborator

HIR ty lowering was modified

cc @fmease

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Sep 18, 2026

@davidtwco davidtwco left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of those situations where I think "how did that ever happen" and then learn that apparently I approved the PR that added this two years ago - thanks for fixing it.

View changes since this review

@davidtwco

Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors

rust-bors Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 616089b has been approved by davidtwco

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 23, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 23, 2026
Rollup of 10 pull requests

Successful merges:

 - #161988 (trait solver: Handle reflexive region constraints)
 - #162498 (Avoid ICEs when recovering malformed function parameters)
 - #163181 (revert #162715 due to #163149)
 - #163207 (Update deprecated rustc_hir imports 2)
 - #163216 (Add `inline` attribute to `NonZero::from_str`)
 - #120589 (std::thread::available_parallelism merging linux/android/freebsd version)
 - #162103 (fix(parser): emit targeted diagnostic for fields inside traits)
 - #162340 (When trying to recover from `for<…> dyn …` don't unconditionally treat `dyn` as a keyword)
 - #163094 (Add regression test for first token source file from TokenStream FromStr)
 - #163115 (Point at `'static` obligations from an fn being called)

Failed merges:

 - #162942 (Remove `StashKey::AssociatedTypeSuggestion`)
@rust-bors rust-bors Bot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Sep 23, 2026
@rust-bors

This comment has been minimized.

@rust-bors rust-bors Bot removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 23, 2026
Currently it's used in a really hacky way: a diagnostic with an empty
message and some suggestions is stashed. Later on it might be retrieved
and its suggestions extracted. It uses `Level::Allow` so that it isn't
printed by `emit_stashed_diagnostics` at shutdown if it hasn't been
retrieved.

This isn't a normal stashed diagnostic, more just a case of "save some
information that might be useful for diagnostics later". We can record
the information more simply and directly.

This commit adds `paths_matching_assoc_types` fields to `Resolver` and
`ResolverGlobalCtxt`. These store the spans of the paths of interest.
The new subdiagnostic `AssocTypeWithSameName` is used to construct the
relevant suggestions when they are needed. Much nicer. The old approach
removed the stashed diagnostic and the new approach doesn't remove the
set entry, so a single span could conceivably match more than once,
presumably a good thing, though this doesn't show up in the test suite.
@nnethercote
nnethercote force-pushed the rm-StashKey-AssociatedTypeSuggestion branch from 616089b to 1e185bd Compare September 23, 2026 23:00
@rustbot

rustbot commented Sep 23, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@nnethercote

Copy link
Copy Markdown
Contributor Author

I rebased.

@bors r=davidtwco

@rust-bors

rust-bors Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 1e185bd has been approved by davidtwco

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Sep 23, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Sep 23, 2026
…TypeSuggestion, r=davidtwco

Remove `StashKey::AssociatedTypeSuggestion`

Currently it's used in a really hacky way: a diagnostic with an empty message and some suggestions is stashed. Later on it might be retrieved and its suggestions extracted. It uses `Level::Allow` so that it isn't printed by `emit_stashed_diagnostics` at shutdown if it hasn't been retrieved.

This isn't a normal stashed diagnostic, more just a case of "save some information that might be useful for diagnostics later". We can record the information more simply and directly.

This commit adds `paths_matching_assoc_types` fields to `Resolver` and `ResolverGlobalCtxt`. These store the spans of the paths of interest. The new subdiagnostic `AssocTypeWithSameName` is used to construct the relevant suggestions when they are needed. Much nicer. The old approach removed the stashed diagnostic and the new approach doesn't remove the set entry, so a single span could conceivably match more than once, presumably a good thing, though this doesn't show up in the test suite.

r? @davidtwco
rust-bors Bot pushed a commit that referenced this pull request Sep 24, 2026
Rollup of 8 pull requests

Successful merges:

 - #162976 (fix quadratic naming of duplicate sidebar links)
 - #163222 (Enable EII tests for cg_gcc)
 - #162942 (Remove `StashKey::AssociatedTypeSuggestion`)
 - #163096 (Don't suggest `std::` rustfix paths in `#![no_std]` crates)
 - #163110 (Mark `std::os::wasip2` with correct doc-cfgs, mark as unstable)
 - #163185 (properly decrement available_depth on cycles and provisional cache hits)
 - #163214 (revert r14 register names for arm)
 - #163226 (miri subtree update)
rust-bors Bot pushed a commit that referenced this pull request Sep 24, 2026
Rollup of 8 pull requests

Successful merges:

 - #162976 (fix quadratic naming of duplicate sidebar links)
 - #163222 (Enable EII tests for cg_gcc)
 - #162942 (Remove `StashKey::AssociatedTypeSuggestion`)
 - #163096 (Don't suggest `std::` rustfix paths in `#![no_std]` crates)
 - #163110 (Mark `std::os::wasip2` with correct doc-cfgs, mark as unstable)
 - #163185 (properly decrement available_depth on cycles and provisional cache hits)
 - #163214 (revert r14 register names for arm)
 - #163226 (miri subtree update)
rust-bors Bot pushed a commit that referenced this pull request Sep 24, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - #162976 (fix quadratic naming of duplicate sidebar links)
 - #161275 (Refactor `core::cmp::{smallest, largest}` & add `mir-opt` test)
 - #163143 (cg_llvm: Use fewer FFI calls to check the target CPU's features)
 - #163188 (Adjust for Arm64EC name mangling when checking for exported symbols)
 - #163211 (`rustc_builtin_macros` cleanup, part 6)
 - #161386 (Don't merge distinct impl candidates)
 - #162942 (Remove `StashKey::AssociatedTypeSuggestion`)
 - #163096 (Don't suggest `std::` rustfix paths in `#![no_std]` crates)
 - #163110 (Mark `std::os::wasip2` with correct doc-cfgs, mark as unstable)
 - #163185 (properly decrement available_depth on cycles and provisional cache hits)
 - #163214 (revert r14 register names for arm)
 - #163226 (miri subtree update)
 - #163228 (Add regression test for trait predicate with escaping bounds)
 - #163234 (`rustc_dump_symbol_name`: add demangling information as a note instead)
@rust-bors
rust-bors Bot merged commit ebdddb5 into rust-lang:main Sep 24, 2026
13 checks passed
@rustbot rustbot added this to the 1.100.0 milestone Sep 24, 2026
rust-bors Bot pushed a commit that referenced this pull request Sep 24, 2026
Rollup merge of #162942 - nnethercote:rm-StashKey-AssociatedTypeSuggestion, r=davidtwco

Remove `StashKey::AssociatedTypeSuggestion`

Currently it's used in a really hacky way: a diagnostic with an empty message and some suggestions is stashed. Later on it might be retrieved and its suggestions extracted. It uses `Level::Allow` so that it isn't printed by `emit_stashed_diagnostics` at shutdown if it hasn't been retrieved.

This isn't a normal stashed diagnostic, more just a case of "save some information that might be useful for diagnostics later". We can record the information more simply and directly.

This commit adds `paths_matching_assoc_types` fields to `Resolver` and `ResolverGlobalCtxt`. These store the spans of the paths of interest. The new subdiagnostic `AssocTypeWithSameName` is used to construct the relevant suggestions when they are needed. Much nicer. The old approach removed the stashed diagnostic and the new approach doesn't remove the set entry, so a single span could conceivably match more than once, presumably a good thing, though this doesn't show up in the test suite.

r? @davidtwco
@nnethercote
nnethercote deleted the rm-StashKey-AssociatedTypeSuggestion branch September 24, 2026 21:59
pull Bot pushed a commit to xtqqczze/rust-lang-miri that referenced this pull request Sep 25, 2026
…uwer

Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#162976 (fix quadratic naming of duplicate sidebar links)
 - rust-lang/rust#161275 (Refactor `core::cmp::{smallest, largest}` & add `mir-opt` test)
 - rust-lang/rust#163143 (cg_llvm: Use fewer FFI calls to check the target CPU's features)
 - rust-lang/rust#163188 (Adjust for Arm64EC name mangling when checking for exported symbols)
 - rust-lang/rust#163211 (`rustc_builtin_macros` cleanup, part 6)
 - rust-lang/rust#161386 (Don't merge distinct impl candidates)
 - rust-lang/rust#162942 (Remove `StashKey::AssociatedTypeSuggestion`)
 - rust-lang/rust#163096 (Don't suggest `std::` rustfix paths in `#![no_std]` crates)
 - rust-lang/rust#163110 (Mark `std::os::wasip2` with correct doc-cfgs, mark as unstable)
 - rust-lang/rust#163185 (properly decrement available_depth on cycles and provisional cache hits)
 - rust-lang/rust#163214 (revert r14 register names for arm)
 - rust-lang/rust#163226 (miri subtree update)
 - rust-lang/rust#163228 (Add regression test for trait predicate with escaping bounds)
 - rust-lang/rust#163234 (`rustc_dump_symbol_name`: add demangling information as a note instead)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants