Skip to content

Commit 90820ff

Browse files
resolve prelude import at build_reduced_graph phase
1 parent d9dba3a commit 90820ff

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
@@ -495,7 +495,22 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
495495
}
496496
// We don't add prelude imports to the globs since they only affect lexical scopes,
497497
// which are not relevant to import resolution.
498-
ImportKind::Glob { is_prelude: true, .. } => {}
498+
ImportKind::Glob { is_prelude: true, .. } => {
499+
// We do resolve the prelude path so it's set before import resolution.
500+
let path_res = self.r.cm().maybe_resolve_path(
501+
&import.module_path,
502+
None,
503+
&import.parent_scope,
504+
Some(import),
505+
);
506+
if let PathResult::Module(
507+
module_or_uniform_root @ ModuleOrUniformRoot::Module(module),
508+
) = path_res
509+
{
510+
import.imported_module.set(Some(module_or_uniform_root));
511+
self.r.prelude = Some(module);
512+
}
513+
}
499514
ImportKind::Glob { .. } => current_module.globs.borrow_mut().push(import),
500515
_ => unreachable!(),
501516
}

0 commit comments

Comments
 (0)