Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement RFC 1560 behind #![feature(item_like_imports)] #35894

Merged
merged 18 commits into from
Sep 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
48a435a
Fix test `compile-fail/task-rng-isnt-sendable.rs`.
jseyfried Aug 22, 2016
5dc1196
Refactor away `binding.is_pseudo_public()`.
jseyfried Aug 19, 2016
691d10c
Rename `new_binding` -> `binding`.
jseyfried Aug 20, 2016
87ae68c
Refactor `binding.def()` to return a `Def` instead of an `Option<Def>`.
jseyfried Aug 20, 2016
1e4c817
Improve diagnostics and remove dead code.
jseyfried Aug 20, 2016
95528d1
Refactor away `resolver.current_vis` and add `module.normal_ancestor_…
jseyfried Aug 22, 2016
513e955
Add field `dummy_binding` to `Resolver`.
jseyfried Aug 22, 2016
5ba22c0
Add `item_like_imports` feature.
jseyfried Aug 16, 2016
efc0bea
item_like_imports: Treat private imports like private items.
jseyfried Aug 20, 2016
aad1f3c
item_like_imports: Allow glob imports to be shadowed by items and sin…
jseyfried Aug 18, 2016
c56a5af
item_like_imports: Allow single imports with a given visibility
jseyfried Aug 19, 2016
097b6d6
item_like_imports: Allow glob imports with a given visibility
jseyfried Aug 20, 2016
245a0c5
item_like_imports: Make all visible items glob importable.
jseyfried Aug 20, 2016
f582fa3
item_like_imports: Allow multiple glob imports of the same item.
jseyfried Aug 20, 2016
681a14f
item_like_imports: Allow unused ambiguous glob imports.
jseyfried Aug 20, 2016
32a0cfe
Avoid reporting multiple ambiguity errors for a single use of a name.
jseyfried Aug 22, 2016
4f5616e
Avoid cascading name resolution errors caused by an ambiguous module.
jseyfried Aug 22, 2016
90ce504
Address comments.
jseyfried Aug 29, 2016
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
23 changes: 13 additions & 10 deletions src/librustc_resolve/build_reduced_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ use rustc::hir::def::*;
use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
use rustc::ty::{self, VariantKind};

use std::cell::Cell;

use syntax::ast::Name;
use syntax::attr;
use syntax::parse::token;
Expand Down Expand Up @@ -81,7 +83,6 @@ impl<'b> Resolver<'b> {
/// Constructs the reduced graph for one item.
fn build_reduced_graph_for_item(&mut self, item: &Item) {
let parent = self.current_module;
let parent_vis = self.current_vis;
let name = item.ident.name;
let sp = item.span;
let vis = self.resolve_visibility(&item.vis);
Expand Down Expand Up @@ -177,7 +178,10 @@ impl<'b> Resolver<'b> {
}
}
ViewPathGlob(_) => {
let subclass = GlobImport { is_prelude: is_prelude };
let subclass = GlobImport {
is_prelude: is_prelude,
max_vis: Cell::new(ty::Visibility::PrivateExternal),
};
let span = view_path.span;
self.add_import_directive(module_path, subclass, span, item.id, vis);
}
Expand All @@ -204,7 +208,7 @@ impl<'b> Resolver<'b> {
ItemKind::Mod(..) => {
let parent_link = ModuleParentLink(parent, name);
let def = Def::Mod(self.definitions.local_def_id(item.id));
let module = self.new_module(parent_link, Some(def), false);
let module = self.new_module(parent_link, Some(def), Some(item.id));
module.no_implicit_prelude.set({
parent.no_implicit_prelude.get() ||
attr::contains_name(&item.attrs, "no_implicit_prelude")
Expand All @@ -214,7 +218,6 @@ impl<'b> Resolver<'b> {

// Descend into the module.
self.current_module = module;
self.current_vis = ty::Visibility::Restricted(item.id);
}

ItemKind::ForeignMod(..) => {}
Expand Down Expand Up @@ -243,7 +246,7 @@ impl<'b> Resolver<'b> {
ItemKind::Enum(ref enum_definition, _) => {
let parent_link = ModuleParentLink(parent, name);
let def = Def::Enum(self.definitions.local_def_id(item.id));
let module = self.new_module(parent_link, Some(def), false);
let module = self.new_module(parent_link, Some(def), parent.normal_ancestor_id);
self.define(parent, name, TypeNS, (module, sp, vis));

for variant in &(*enum_definition).variants {
Expand Down Expand Up @@ -285,7 +288,8 @@ impl<'b> Resolver<'b> {
// Add all the items within to a new module.
let parent_link = ModuleParentLink(parent, name);
let def = Def::Trait(def_id);
let module_parent = self.new_module(parent_link, Some(def), false);
let module_parent =
self.new_module(parent_link, Some(def), parent.normal_ancestor_id);
self.define(parent, name, TypeNS, (module_parent, sp, vis));

// Add the names of all the items to the trait info.
Expand All @@ -312,7 +316,6 @@ impl<'b> Resolver<'b> {

visit::walk_item(&mut BuildReducedGraphVisitor { resolver: self }, item);
self.current_module = parent;
self.current_vis = parent_vis;
}

// Constructs the reduced graph for one variant. Variants exist in the
Expand Down Expand Up @@ -363,7 +366,7 @@ impl<'b> Resolver<'b> {
block_id);

let parent_link = BlockParentLink(parent, block_id);
let new_module = self.new_module(parent_link, None, false);
let new_module = self.new_module(parent_link, None, parent.normal_ancestor_id);
self.module_map.insert(block_id, new_module);
self.current_module = new_module; // Descend into the block.
}
Expand Down Expand Up @@ -395,7 +398,7 @@ impl<'b> Resolver<'b> {
debug!("(building reduced graph for external crate) building module {} {:?}",
name, vis);
let parent_link = ModuleParentLink(parent, name);
let module = self.new_module(parent_link, Some(def), true);
let module = self.new_module(parent_link, Some(def), None);
let _ = self.try_define(parent, name, TypeNS, (module, DUMMY_SP, vis));
}
Def::Variant(_, variant_id) => {
Expand Down Expand Up @@ -437,7 +440,7 @@ impl<'b> Resolver<'b> {
}

let parent_link = ModuleParentLink(parent, name);
let module = self.new_module(parent_link, Some(def), true);
let module = self.new_module(parent_link, Some(def), None);
let _ = self.try_define(parent, name, TypeNS, (module, DUMMY_SP, vis));
}
Def::TyAlias(..) | Def::AssociatedTy(..) => {
Expand Down
Loading