From 965d31ce5b8315e39f72e40da283d2f3d1367e87 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 8 Feb 2021 19:13:54 +0100 Subject: Check for dyn impls in method resolution --- crates/hir_ty/src/tests/method_resolution.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crates/hir_ty/src/tests/method_resolution.rs') diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index a6a54e542..80e795fbf 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs @@ -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; + f.dyn_foo(); + // ^u32 +} +"#, + ); +} -- cgit v1.2.3