Skip to content

Commit a3f8ae2

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

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,18 @@ 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(ModuleOrUniformRoot::Module(module)) = path_res {
503+
self.r.prelude = Some(module);
504+
}
505+
}
495506
ImportKind::Glob { .. } => current_module.globs.borrow_mut().push(import),
496507
_ => unreachable!(),
497508
}

0 commit comments

Comments
 (0)