Skip to content

Commit 4a2a0dc

Browse files
resolve prelude import at build_reduced_graph phase
1 parent 64d7519 commit 4a2a0dc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,22 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
491491
}
492492
// We don't add prelude imports to the globs since they only affect lexical scopes,
493493
// which are not relevant to import resolution.
494-
ImportKind::Glob { is_prelude: true, .. } => {}
494+
ImportKind::Glob { is_prelude: true, .. } => {
495+
// We do resolve the prelude path so it's set before import resolution.
496+
let path_res = self.r.cm().maybe_resolve_path(
497+
&import.module_path,
498+
None,
499+
&import.parent_scope,
500+
Some(import),
501+
);
502+
if let PathResult::Module(
503+
module_or_uniform_root @ ModuleOrUniformRoot::Module(module),
504+
) = path_res
505+
{
506+
import.imported_module.set(Some(module_or_uniform_root));
507+
self.r.prelude = Some(module);
508+
}
509+
}
495510
ImportKind::Glob { .. } => current_module.globs.borrow_mut().push(import),
496511
_ => unreachable!(),
497512
}

0 commit comments

Comments
 (0)