Skip to content

Tweak incorrect assoc item note#152880

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
JohnTitor:tweak-assoc-item-note
Mar 28, 2026
Merged

Tweak incorrect assoc item note#152880
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
JohnTitor:tweak-assoc-item-note

Conversation

@JohnTitor
Copy link
Copy Markdown
Member

@JohnTitor JohnTitor commented Feb 20, 2026

Fix #142797
r? @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 Feb 20, 2026
Copy link
Copy Markdown
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

Sorry about the delay.

View changes since this review

Comment on lines +1179 to +1182
let has_self_assoc_type = if let SelfSource::QPath(ty) = source
&& let hir::TyKind::Path(hir::QPath::Resolved(_, path)) = ty.kind
&& let Res::SelfTyAlias { alias_to: impl_def_id, .. } = path.res
&& let DefKind::Impl { .. } = self.tcx.def_kind(impl_def_id)
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.

While this does nicely detect the scenario in issue #142797, it's not very general. E.g., it obviously doesn't account for:

struct Struct;

trait Trait { type AssocStruct; }
impl Trait for i32 { type AssocStruct = Struct; }

fn main() { let _ = i32::AssocStruct; } //~ ERROR no associated item … found …

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Makes sense, fixed along with the below comment: 5a0eccf

Comment on lines +3 to +4
#![allow(dead_code, unused_variables)]

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.

Suggested change
#![allow(dead_code, unused_variables)]

Compiletest already automatically adds -Aunused to UI tests (unless they're run-{pass,crash}) which implies dead_code and unused_variables.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I always forgot to remove them on copy-pasting from the playground... Fixed in 5a0eccf.

Comment on lines 1193 to 1204
Copy link
Copy Markdown
Member

@fmease fmease Mar 2, 2026

Choose a reason for hiding this comment

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

I'm wondering if we should just unconditionally talk about associated function or constant instead of associated item because that's actually the truth, rustc_hir_typeck::method looks for assoc fns, assoc consts & enum variants, not assoc items in general.

Then we wouldn't need to check for the presence of assoc tys which is rather ad hoc.

  • variant or associated itemvariant, associated function or constant
  • function or associated item, associated itemassociated function or constant

I know it's slightly lengthier but associated item is strictly speaking incorrect. @estebank, I'd also like to hear what you think about this proposal :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fair enough, aligned to your proposal in 5a0eccf. Would like to know Esteban's view as well.

@JohnTitor JohnTitor force-pushed the tweak-assoc-item-note branch from 2fe5590 to 5a0eccf Compare March 8, 2026 04:46
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-bors

This comment has been minimized.

Copy link
Copy Markdown
Member

@fmease fmease left a comment

Choose a reason for hiding this comment

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

Let's try this. r=me
@bors rollup

View changes since this review

@fmease fmease added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 24, 2026
@JohnTitor JohnTitor force-pushed the tweak-assoc-item-note branch from 5a0eccf to f17ed10 Compare March 27, 2026 12:41
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 27, 2026

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Mar 27, 2026

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.

@rust-log-analyzer

This comment has been minimized.

@JohnTitor JohnTitor force-pushed the tweak-assoc-item-note branch from f17ed10 to 104d049 Compare March 28, 2026 01:09
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Mar 28, 2026
@rust-log-analyzer

This comment has been minimized.

@JohnTitor JohnTitor force-pushed the tweak-assoc-item-note branch from 104d049 to 531631c Compare March 28, 2026 07:18
@JohnTitor
Copy link
Copy Markdown
Member Author

@bors r=fmease

Thank you for the review!

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors bot commented Mar 28, 2026

📌 Commit 531631c has been approved by fmease

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 Mar 28, 2026
rust-bors bot pushed a commit that referenced this pull request Mar 28, 2026
Rollup of 11 pull requests

Successful merges:

 - #152880 (Tweak incorrect assoc item note)
 - #153526 (Fix LegacyKeyValueFormat report from docker build: i686)
 - #153613 (interpreter error reporting: remove arguments that are always the same)
 - #154029 (Replace `truncate(0)` with `clear()`)
 - #154125 (Inline and remove `DepGraphData::try_mark_parent_green`.)
 - #154185 (Prevent no_threads RwLock's write() impl from setting mode to -1 when it is locked for reading)
 - #154394 (Normalize rustc path prefix when testing `-Z track-diagnostics`)
 - #154450 (Use the normal arg-parsing machinery for `-Zassert-incr-state`)
 - #154475 (Emit a pre-expansion feature gate warning for `box`'ed struct field patterns)
 - #154500 (EnumSizeOpt: use Allocation::write_scalar instead of manual endianess logic)
 - #154502 (interpret: ensure that untupled arguments are actually tuples)
@rust-bors rust-bors bot merged commit 7881a31 into rust-lang:main Mar 28, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 28, 2026
rust-timer added a commit that referenced this pull request Mar 28, 2026
Rollup merge of #152880 - JohnTitor:tweak-assoc-item-note, r=fmease

Tweak incorrect assoc item note

Fix #142797
r? @fmease
@JohnTitor JohnTitor deleted the tweak-assoc-item-note branch March 28, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-run-make Area: port run-make Makefiles to rmake.rs 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.

Inaccurate diagnostic when using associated type as a value

4 participants