rust/tests/ui/methods/disambiguate-multiple-blanket-impl.rs

39 lines
904 B
Rust
Raw Normal View History

trait A {
2023-10-15 20:22:25 -05:00
type Type;
const CONST: usize;
fn foo(&self);
}
trait B {
2023-10-15 20:22:25 -05:00
type Type;
const CONST: usize;
fn foo(&self);
}
#[derive(Debug)]
struct S;
impl<T: std::fmt::Debug> A for T {
2023-10-15 20:22:25 -05:00
type Type = ();
const CONST: usize = 1; //~ NOTE candidate #1
fn foo(&self) {} //~ NOTE candidate #1
}
impl<T: std::fmt::Debug> B for T {
2023-10-15 20:22:25 -05:00
type Type = ();
const CONST: usize = 2; //~ NOTE candidate #2
fn foo(&self) {} //~ NOTE candidate #2
}
fn main() {
let s = S;
S::foo(&s); //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `foo` found
2023-10-16 13:25:11 -05:00
//~| HELP use fully-qualified syntax to disambiguate
2023-10-15 20:22:25 -05:00
S::CONST; //~ ERROR multiple applicable items in scope
//~^ NOTE multiple `CONST` found
2023-10-16 13:25:11 -05:00
//~| HELP use fully-qualified syntax to disambiguate
2023-10-15 20:22:25 -05:00
let _: S::Type; //~ ERROR ambiguous associated type
2023-10-16 13:25:11 -05:00
//~^ HELP use fully-qualified syntax
}