From 12f6bdcfd9fe1393887b3be0d0329fcf11492e75 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 9 Mar 2021 18:18:35 +0100 Subject: Check ancestor maps when computing traits in scope --- crates/hir_ty/src/tests/traits.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'crates/hir_ty/src') diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 528092082..e185b1c0a 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs @@ -3173,6 +3173,39 @@ fn f() { ); } +#[test] +fn trait_in_scope_with_inner_item() { + check_infer( + r#" +mod m { + pub trait Tr { + fn method(&self) -> u8 { 0 } + } + + impl Tr for () {} +} + +use m::Tr; + +fn f() { + fn inner() { + ().method(); + //^^^^^^^^^^^ u8 + } +} + "#, + expect![[r#" + 46..50 'self': &Self + 58..63 '{ 0 }': u8 + 60..61 '0': u8 + 115..185 '{ ... } }': () + 132..183 '{ ... }': () + 142..144 '()': () + 142..153 '().method()': u8 + "#]], + ); +} + #[test] fn inner_use_in_block() { check_types( -- cgit v1.2.3