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

38 lines
828 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);
}
struct S;
impl A for S {
2023-10-15 20:22:25 -05:00
type Type = ();
const CONST: usize = 1; //~ NOTE candidate #1
fn foo(&self) {} //~ NOTE candidate #1
}
impl B for S {
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
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
2023-10-15 20:22:25 -05:00
let _ = 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
}