Skip to content

update ambiguous_glob_imported_trait lint explanation and example. - #160354

Open
LorrensP-2158466 wants to merge 1 commit into
rust-lang:mainfrom
LorrensP-2158466:amb-import-trait-update
Open

update ambiguous_glob_imported_trait lint explanation and example.#160354
LorrensP-2158466 wants to merge 1 commit into
rust-lang:mainfrom
LorrensP-2158466:amb-import-trait-update

Conversation

@LorrensP-2158466

@LorrensP-2158466 LorrensP-2158466 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

In the tracking issue for the ambiguous_glob_imported_trait #152822 someone reported that the explanation is lacking/confusing since #159599.

Explanation and example are extended in this pr.

@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 Aug 1, 2026
@rustbot

rustbot commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

r? @ShoyuVanilla

rustbot has assigned @ShoyuVanilla.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 18 candidates

Comment thread compiler/rustc_lint_defs/src/builtin.rs Outdated
/// usable at all, but this is allowed for backwards compatibility (for now).
///
/// When a trait and a non-trait item with the same name are both glob imported (as in
/// `trait_and_non_trait`), the trait is always considered in scope, so method resolution is

@petrochenkov petrochenkov Aug 2, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The trait is either in scope or not in scope, depending on name resolution internals (it's unpredictable which of the glob imports will be selected in case of conflicts). That's why the lint is reported, not just for consistency.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

As of #159599 the trait is actually in scope so that we can report that lint. That way its independent of which glob import is resolved first. Ideally it is never in scope, but that requires turning this lint into an error.

Or am i missing something?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I mean it's in scope only because we recover it from ambiguities and put it into scope just for the lint.
When the lint is turned into an error it will no longer be in scope.

The current wording looks like there's no actual issue here, and we report just for consistency with the trait-vs-trait cases.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed the phrasing.

@LorrensP-2158466
LorrensP-2158466 force-pushed the amb-import-trait-update branch from 1ea66a6 to b6edc07 Compare August 2, 2026 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants