Skip to content
Merged
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 @@ -2468,7 +2468,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.
Comment thread
fmease marked this conversation as resolved.
TraitCandidate(_, lint) => lint,
_ => false,
};
Expand Down
36 changes: 36 additions & 0 deletions tests/ui/supertrait-shadowing/ambiguous-glob-imported-subtrait.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// issue: <https://github.com/rust-lang/rust/issues/157965>

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

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,20 @@
error: Use of ambiguously glob imported trait `Role`
--> $DIR/ambiguous-glob-imported-subtrait.rs:33: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 #152822 <https://github.com/rust-lang/rust/issues/152822>
note: the lint level is defined here
--> $DIR/ambiguous-glob-imported-subtrait.rs:4:9
|
LL | #![deny(ambiguous_glob_imported_traits)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

Loading