Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compiler/rustc_hir_typeck/src/method/probe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2415,7 +2415,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
}
}

let lint_ambiguous = match probes[0].0.kind {
let lint_ambiguous = match child_candidate.kind {
Comment thread
kevin-valerio marked this conversation as resolved.

@fmease fmease Aug 23, 2026

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.

collapse_candidates_to_trait_pick does the same which is most likely also incorrect and should be fixed. However, it'd be advantageous if we could first come up with a snippet that exploits it.

View changes since the review

TraitCandidate(_, lint) => lint,
_ => false,
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
//@ check-fail
//@ normalize-stderr: "error: aborting due to 1 previous error\n\n" -> "error: aborting due to 1 previous error\n"

#![feature(supertrait_item_shadowing)]
#![deny(ambiguous_glob_imported_traits)]
Comment thread
kevin-valerio marked this conversation as resolved.
#![allow(dead_code, unused_imports)]

trait DefaultPolicy {
fn allow_action(&self) -> bool {
false
}
}

mod first_policy {
pub trait Role: crate::DefaultPolicy {
fn allow_action(&self) -> bool {
true
}
}

impl crate::DefaultPolicy for u8 {}
impl Role for u8 {}
}

mod second_policy {
pub trait Role: crate::DefaultPolicy {
fn audit_only(&self) {}
}
}

use first_policy::*;
use second_policy::*;

fn main() {
assert!(0u8.allow_action());
//~^ ERROR Use of ambiguously glob imported trait `Role`
//~| WARN this was previously accepted by the compiler but is being phased out
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
error: Use of ambiguously glob imported trait `Role`
--> $DIR/ambiguous-glob-imported-subtrait.rs:35:17
|
LL | use first_policy::*;
| ------------ `Role` imported ambiguously here
...
LL | assert!(0u8.allow_action());
| ^^^^^^^^^^^^
|
= help: Import `Role` explicitly
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #147992 <https://github.com/rust-lang/rust/issues/147992>
note: the lint level is defined here
--> $DIR/ambiguous-glob-imported-subtrait.rs:5:9
|
LL | #![deny(ambiguous_glob_imported_traits)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error
Loading