2021-07-31 14:46:23 +00:00
|
|
|
//@ run-pass
|
|
|
|
|
2024-01-22 12:23:50 +00:00
|
|
|
#![feature(trait_upcasting)]
|
|
|
|
|
2021-07-31 14:46:23 +00:00
|
|
|
trait A {
|
2024-02-07 02:42:01 +00:00
|
|
|
fn foo_a(&self); //~ WARN method `foo_a` is never used
|
2021-07-31 14:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
trait B {
|
|
|
|
fn foo_b(&self);
|
|
|
|
}
|
|
|
|
|
|
|
|
trait C: A + B {
|
2024-02-07 02:42:01 +00:00
|
|
|
fn foo_c(&self); //~ WARN method `foo_c` is never used
|
2021-07-31 14:46:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct S(i32);
|
|
|
|
|
|
|
|
impl A for S {
|
|
|
|
fn foo_a(&self) {
|
|
|
|
unreachable!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl B for S {
|
|
|
|
fn foo_b(&self) {
|
|
|
|
assert_eq!(42, self.0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl C for S {
|
|
|
|
fn foo_c(&self) {
|
|
|
|
unreachable!();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn invoke_inner(b: &dyn B) {
|
|
|
|
b.foo_b();
|
|
|
|
}
|
|
|
|
|
|
|
|
fn invoke_outer(c: &dyn C) {
|
|
|
|
invoke_inner(c);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let s = S(42);
|
|
|
|
invoke_outer(&s);
|
|
|
|
}
|