Check for dyn impls in method resolution

This commit is contained in:
Lukas Wirth 2021-02-08 19:13:54 +01:00
parent 4cc333c889
commit 965d31ce5b
2 changed files with 38 additions and 11 deletions

View file

@ -1106,3 +1106,25 @@ fn main() {
"#,
);
}
#[test]
fn method_on_dyn_impl() {
check_types(
r#"
trait Foo {}
impl Foo for u32 {}
impl dyn Foo {
pub fn dyn_foo(&self) -> u32 {
0
}
}
fn main() {
let f = &42u32 as &dyn Foo<u32>;
f.dyn_foo();
// ^u32
}
"#,
);
}