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_def/src/resolver.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'crates/hir_def') diff --git a/crates/hir_def/src/resolver.rs b/crates/hir_def/src/resolver.rs index 77ff21739..28b184f7c 100644 --- a/crates/hir_def/src/resolver.rs +++ b/crates/hir_def/src/resolver.rs @@ -342,6 +342,16 @@ impl Resolver { traits.extend(prelude_def_map[prelude.local_id].scope.traits()); } traits.extend(m.def_map[m.module_id].scope.traits()); + + // Add all traits that are in scope because of the containing DefMaps + m.def_map.with_ancestor_maps(db, m.module_id, &mut |def_map, module| { + if let Some(prelude) = def_map.prelude() { + let prelude_def_map = prelude.def_map(db); + traits.extend(prelude_def_map[prelude.local_id].scope.traits()); + } + traits.extend(def_map[module].scope.traits()); + None::<()> + }); } } traits -- cgit v1.2.3