From 28ca37175572403edeb92324d251fbceb4c2487f Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Tue, 25 May 2021 16:08:18 +0200 Subject: Consider trait to be in scope for trait-impl --- crates/hir_ty/src/tests/traits.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'crates/hir_ty/src/tests/traits.rs') diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 6cd8786ea..6ad96bfe3 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs @@ -3630,3 +3630,33 @@ fn test(f: F) { "#]], ); } + +#[test] +fn trait_in_scope_of_trait_impl() { + check_infer( + r#" +mod foo { + pub trait Foo { + fn foo(self); + fn bar(self) -> usize { 0 } + } +} +impl foo::Foo for u32 { + fn foo(self) { + let _x = self.bar(); + } +} + "#, + expect![[r#" + 45..49 'self': Self + 67..71 'self': Self + 82..87 '{ 0 }': usize + 84..85 '0': usize + 131..135 'self': u32 + 137..173 '{ ... }': () + 151..153 '_x': usize + 156..160 'self': u32 + 156..166 'self.bar()': usize + "#]], + ); +} -- cgit v1.2.3