-
Notifications
You must be signed in to change notification settings - Fork 14k
FCW Lint when using an ambiguously glob imported trait #149058
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
|
Addressed your comments and updated pr title and description. @rustbot ready |
| self.tcx.node_lint(AMBIGUOUS_TRAIT_GLOB_IMPORTS, segment.hir_id, |diag| { | ||
| diag.primary_message(format!("Use of ambiguously glob imported trait `{trait_name}`")) | ||
| .span(segment.ident.span) | ||
| .span_label(import_span, format!("`{trait_name}`imported ambiguously here")) | ||
| .help(format!("Import `{trait_name}` explicitly")); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add some kind of suggestion like:
Consider importing `{trait_name}` directly:
+ use m1::{trait_name};
| //~| WARNING: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
| } | ||
|
|
||
| fn main() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you copy all the tests from #148946 as well?
| pub struct TraitCandidate { | ||
| pub def_id: DefId, | ||
| pub import_ids: SmallVec<[LocalDefId; 1]>, | ||
| // FIXME: explain why this is needed for now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The FIXME still needs to be addressed.
| pick: &probe::Pick<'_>, | ||
| segment: &hir::PathSegment<'tcx>, | ||
| ) { | ||
| if let probe::PickKind::TraitPick(true) = pick.kind { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if let probe::PickKind::TraitPick(true) = pick.kind { | |
| if pick.kind != probe::PickKind::TraitPick(true) { return true } |
Related to #147992.
Report a lint when using an ambiguously glob import trait, this is a FCW because this should not be allowed.
r? @petrochenkov