Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 9 additions & 24 deletions compiler/rustc_resolve/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,13 +547,6 @@ impl ModuleKind {
ModuleKind::Def(.., name) => name,
}
}

fn opt_def_id(&self) -> Option<DefId> {
match self {
ModuleKind::Def(_, def_id, _) => Some(*def_id),
_ => None,
}
}
}

/// Combination of a symbol and its macros 2.0 normalized hygiene context.
Expand Down Expand Up @@ -791,7 +784,10 @@ impl<'ra> Module<'ra> {
}

fn opt_def_id(self) -> Option<DefId> {
self.kind.opt_def_id()
match self.kind {
ModuleKind::Def(_, def_id, _) => Some(def_id),
_ => None,
}
}

// `self` resolves to the first module ancestor that `is_normal`.
Expand Down Expand Up @@ -1454,19 +1450,14 @@ impl<'ra> ResolverArenas<'ra> {
&'ra self,
parent: Option<Module<'ra>>,
kind: ModuleKind,
vis: Visibility<DefId>,
expn_id: ExpnId,
span: Span,
no_implicit_prelude: bool,
) -> Module<'ra> {
let self_decl = match kind {
ModuleKind::Def(def_kind, def_id, _) => Some(self.new_def_decl(
Res::Def(def_kind, def_id),
vis,
span,
LocalExpnId::ROOT,
None,
)),
ModuleKind::Def(def_kind, def_id, _) => {
Some(self.new_pub_def_decl(Res::Def(def_kind, def_id), span, LocalExpnId::ROOT))
}
ModuleKind::Block => None,
};
Module(Interned::new_unchecked(self.modules.alloc(ModuleData::new(
Expand Down Expand Up @@ -1648,7 +1639,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let graph_root = arenas.new_module(
None,
ModuleKind::Def(DefKind::Mod, root_def_id, None),
Visibility::Public,
ExpnId::root(),
crate_span,
attr::contains_name(attrs, sym::no_implicit_prelude),
Expand All @@ -1658,7 +1648,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
let empty_module = arenas.new_module(
None,
ModuleKind::Def(DefKind::Mod, root_def_id, None),
Visibility::Public,
ExpnId::root(),
DUMMY_SP,
true,
Expand Down Expand Up @@ -1760,9 +1749,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
span: Span,
no_implicit_prelude: bool,
) -> Module<'ra> {
let vis =
kind.opt_def_id().map_or(Visibility::Public, |def_id| self.tcx.visibility(def_id));
let module = self.arenas.new_module(parent, kind, vis, expn_id, span, no_implicit_prelude);
let module = self.arenas.new_module(parent, kind, expn_id, span, no_implicit_prelude);
self.local_modules.push(module);
if let Some(def_id) = module.opt_def_id() {
self.local_module_map.insert(def_id.expect_local(), module);
Expand All @@ -1778,9 +1765,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
span: Span,
no_implicit_prelude: bool,
) -> Module<'ra> {
let vis =
kind.opt_def_id().map_or(Visibility::Public, |def_id| self.tcx.visibility(def_id));
let module = self.arenas.new_module(parent, kind, vis, expn_id, span, no_implicit_prelude);
let module = self.arenas.new_module(parent, kind, expn_id, span, no_implicit_prelude);
self.extern_module_map.borrow_mut().insert(module.def_id(), module);
module
}
Expand Down
24 changes: 0 additions & 24 deletions tests/ui/use/pub-use-self-super-crate.rs

This file was deleted.

43 changes: 0 additions & 43 deletions tests/ui/use/pub-use-self-super-crate.stderr

This file was deleted.

2 changes: 1 addition & 1 deletion tests/ui/use/use-path-segment-kw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ macro_rules! macro_dollar_crate {

fn outer() {}

pub mod foo {
mod foo {
pub mod bar {
pub mod foobar {
pub mod qux {
Expand Down
Loading