Skip to content

Commit 429fed0

Browse files
address review
1 parent c099423 commit 429fed0

File tree

5 files changed

+21
-19
lines changed

5 files changed

+21
-19
lines changed

compiler/rustc_resolve/src/build_reduced_graph.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use tracing::debug;
3333

3434
use crate::Namespace::{MacroNS, TypeNS, ValueNS};
3535
use crate::def_collector::collect_definitions;
36-
use crate::errors::CannotGlobImportAllCrates;
3736
use crate::imports::{ImportData, ImportKind};
3837
use crate::macros::{MacroRulesBinding, MacroRulesScope, MacroRulesScopeRef};
3938
use crate::{
@@ -659,16 +658,15 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
659658
if !ast::attr::contains_name(&item.attrs, sym::prelude_import) {
660659
let kind = ImportKind::Glob { max_vis: Cell::new(None), id };
661660
self.add_import(prefix, kind, use_tree.span, item, root_span, item.id, vis);
662-
return;
663-
}
664-
// Resolve the prelude import early.
665-
let path_res =
666-
self.r.cm().maybe_resolve_path(&prefix, None, &self.parent_scope, None);
667-
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = path_res {
668-
self.r.prelude = Some(module);
669661
} else {
670-
// Same as in `imports::resolve_glob_import`
671-
self.r.dcx().emit_err(CannotGlobImportAllCrates { span: use_tree.span });
662+
// Resolve the prelude import early.
663+
let path_res =
664+
self.r.cm().maybe_resolve_path(&prefix, None, &self.parent_scope, None);
665+
if let PathResult::Module(ModuleOrUniformRoot::Module(module)) = path_res {
666+
self.r.prelude = Some(module);
667+
} else {
668+
self.r.dcx().span_err(use_tree.span, "cannot resolve a prelude import");
669+
}
672670
}
673671
}
674672
ast::UseTreeKind::Nested { ref items, .. } => {

library/core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@
211211
extern crate self as core;
212212

213213
/* The core prelude, not as all-encompassing as the std prelude */
214+
// The comiler expects the prelude definition to be defined before it's use.
214215
pub mod prelude;
215216

216217
#[prelude_import]

library/std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@
422422
#![default_lib_allocator]
423423

424424
// The Rust prelude
425+
// The comiler expects the prelude definition to be defined before it's use.
425426
pub mod prelude;
426427

427428
// Explicitly import the prelude. The compiler uses this same unstable attribute

tests/ui/resolve/custom-inner-attribute.rs

Lines changed: 0 additions & 9 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@ check-pass
2+
//! This test checks that macro names resolved from the libstd prelude
3+
//! still work even if there's a crate-level custom inner attribute.
4+
5+
#![feature(custom_inner_attributes)]
6+
7+
#![rustfmt::skip]
8+
9+
fn main() {
10+
let _ = todo!();
11+
}

0 commit comments

Comments
 (0)