Skip to content

Commit 50ebc13

Browse files
committed
---
yaml --- r: 276810 b: refs/heads/try c: 5ff21f1 h: refs/heads/master
1 parent 7bc7fd9 commit 50ebc13

File tree

4 files changed

+26
-58
lines changed

4 files changed

+26
-58
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 0d1bc02da84db560729e5f6276759001b234bb6c
4+
refs/heads/try: 5ff21f138a1a807205180caf7921256e6dc16790
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_resolve/build_reduced_graph.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -538,13 +538,6 @@ impl<'b, 'tcx:'b> Resolver<'b, 'tcx> {
538538
module_.increment_outstanding_references_for(target, ValueNS, is_public);
539539
module_.increment_outstanding_references_for(target, TypeNS, is_public);
540540
}
541-
GlobImport if !is_prelude => {
542-
// Set the glob flag. This tells us that we don't know the
543-
// module's exports ahead of time.
544-
module_.inc_glob_count(is_public)
545-
}
546-
// Prelude imports are not included in the glob counts since they do not get added to
547-
// `resolved_globs` -- they are handled separately in `resolve_imports`.
548541
GlobImport => {}
549542
}
550543

branches/try/src/librustc_resolve/lib.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -849,13 +849,7 @@ pub struct ModuleS<'a> {
849849
prelude: RefCell<Option<Module<'a>>>,
850850

851851
glob_importers: RefCell<Vec<(Module<'a>, &'a ImportDirective<'a>)>>,
852-
resolved_globs: RefCell<(Vec<Module<'a>> /* public */, Vec<Module<'a>> /* private */)>,
853-
854-
// The number of public glob imports in this module.
855-
public_glob_count: Cell<usize>,
856-
857-
// The number of private glob imports in this module.
858-
private_glob_count: Cell<usize>,
852+
globs: RefCell<Vec<&'a ImportDirective<'a>>>,
859853

860854
// Whether this module is populated. If not populated, any attempt to
861855
// access the children must be preceded with a
@@ -883,19 +877,12 @@ impl<'a> ModuleS<'a> {
883877
module_children: RefCell::new(NodeMap()),
884878
prelude: RefCell::new(None),
885879
glob_importers: RefCell::new(Vec::new()),
886-
resolved_globs: RefCell::new((Vec::new(), Vec::new())),
887-
public_glob_count: Cell::new(0),
888-
private_glob_count: Cell::new(0),
880+
globs: RefCell::new((Vec::new())),
889881
populated: Cell::new(!external),
890882
arenas: arenas
891883
}
892884
}
893885

894-
fn add_import_directive(&self, import_directive: ImportDirective<'a>) {
895-
let import_directive = self.arenas.alloc_import_directive(import_directive);
896-
self.unresolved_imports.borrow_mut().push(import_directive);
897-
}
898-
899886
fn for_each_child<F: FnMut(Name, Namespace, &'a NameBinding<'a>)>(&self, mut f: F) {
900887
for (&(name, ns), name_resolution) in self.resolutions.borrow().iter() {
901888
name_resolution.binding.map(|binding| f(name, ns, binding));
@@ -928,11 +915,6 @@ impl<'a> ModuleS<'a> {
928915
_ => false,
929916
}
930917
}
931-
932-
fn inc_glob_count(&self, is_public: bool) {
933-
let glob_count = if is_public { &self.public_glob_count } else { &self.private_glob_count };
934-
glob_count.set(glob_count.get() + 1);
935-
}
936918
}
937919

938920
impl<'a> fmt::Debug for ModuleS<'a> {

branches/try/src/librustc_resolve/resolve_imports.rs

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -212,29 +212,15 @@ impl<'a> ::ModuleS<'a> {
212212
});
213213
}
214214

215-
let (ref mut public_globs, ref mut private_globs) = *self.resolved_globs.borrow_mut();
216-
217-
// Check if the public globs are determined
218-
if public_globs.len() < self.public_glob_count.get() {
219-
return Indeterminate;
220-
}
221-
for module in public_globs.iter() {
222-
if let Indeterminate = module.resolve_name(name, ns, false) {
223-
return Indeterminate;
224-
}
225-
}
226-
227-
if !allow_private_imports {
228-
return Failed(None);
229-
}
230-
231-
// Check if the private globs are determined
232-
if private_globs.len() < self.private_glob_count.get() {
233-
return Indeterminate;
234-
}
235-
for module in private_globs.iter() {
236-
if let Indeterminate = module.resolve_name(name, ns, false) {
237-
return Indeterminate;
215+
// Check if the globs are determined
216+
for directive in self.globs.borrow().iter() {
217+
if !allow_private_imports && !directive.is_public { continue }
218+
match directive.target_module.get() {
219+
None => return Indeterminate,
220+
Some(target_module) => match target_module.resolve_name(name, ns, false) {
221+
Indeterminate => return Indeterminate,
222+
_ => {}
223+
}
238224
}
239225
}
240226

@@ -259,6 +245,18 @@ impl<'a> ::ModuleS<'a> {
259245
})
260246
}
261247

248+
pub fn add_import_directive(&self, directive: ImportDirective<'a>) {
249+
let directive = self.arenas.alloc_import_directive(directive);
250+
self.unresolved_imports.borrow_mut().push(directive);
251+
if let GlobImport = directive.subclass {
252+
// We don't add prelude imports to the globs since they only affect lexical scopes,
253+
// which are not relevant to import resolution.
254+
if !directive.is_prelude {
255+
self.globs.borrow_mut().push(directive);
256+
}
257+
}
258+
}
259+
262260
pub fn increment_outstanding_references_for(&self, name: Name, ns: Namespace, is_public: bool) {
263261
self.resolutions.borrow_mut().entry((name, ns)).or_insert_with(Default::default)
264262
.increment_outstanding_references(is_public);
@@ -603,12 +601,8 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
603601
return Success(());
604602
}
605603

606-
// Add to target_module's glob_importers and module_'s resolved_globs
604+
// Add to target_module's glob_importers
607605
target_module.glob_importers.borrow_mut().push((module_, directive));
608-
match *module_.resolved_globs.borrow_mut() {
609-
(ref mut public_globs, _) if directive.is_public => public_globs.push(target_module),
610-
(_, ref mut private_globs) => private_globs.push(target_module),
611-
}
612606

613607
for (&(name, ns), resolution) in target_module.resolutions.borrow().iter() {
614608
if let Some(Success(binding)) = resolution.try_result(false) {
@@ -635,8 +629,7 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
635629
// reporting conflicts, reporting the PRIVATE_IN_PUBLIC lint, and reporting unresolved imports.
636630
fn finalize_resolutions(&mut self, module: Module<'b>, report_unresolved_imports: bool) {
637631
// Since import resolution is finished, globs will not define any more names.
638-
module.public_glob_count.set(0); module.private_glob_count.set(0);
639-
*module.resolved_globs.borrow_mut() = (Vec::new(), Vec::new());
632+
*module.globs.borrow_mut() = Vec::new();
640633

641634
let mut reexports = Vec::new();
642635
for (&(name, ns), resolution) in module.resolutions.borrow().iter() {

0 commit comments

Comments
 (0)