resolve: Refactor obtaining Module from its DefId

The `Option<Module>` version is supported for the case where we don't know whether the `DefId` refers to a module or not.
Non-local traits and enums are also correctly found now.
This commit is contained in:
Vadim Petrochenkov 2021-09-12 02:06:27 +03:00
parent a8021888c8
commit ab834e5ea9
6 changed files with 76 additions and 78 deletions

View file

@ -915,8 +915,7 @@ impl<'a> Resolver<'a> {
continue;
}
if let Some(crate_id) = self.crate_loader.maybe_process_path_extern(ident.name) {
let crate_root =
self.get_module(DefId { krate: crate_id, index: CRATE_DEF_INDEX });
let crate_root = self.expect_module(crate_id.as_def_id());
suggestions.extend(self.lookup_import_candidates_from_module(
lookup_ident,
namespace,