Skip to content

Commit a7156f6

Browse files
committed
---
yaml --- r: 274743 b: refs/heads/stable c: d7734ae h: refs/heads/master i: 274741: f5a5dde 274739: 51e43bf 274735: b852af0
1 parent 788ddee commit a7156f6

File tree

2 files changed

+26
-53
lines changed

2 files changed

+26
-53
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
2929
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
3030
refs/tags/homu-tmp: c0221c8897db309a79990367476177b1230bb264
3131
refs/tags/1.0.0-beta: 8cbb92b53468ee2b0c2d3eeb8567005953d40828
32-
refs/heads/stable: 7000e708252bd9e45f28926d8fd38cc9ec054e57
32+
refs/heads/stable: d7734aebeca4d2f230bdec631ffce1416740afa5
3333
refs/tags/1.0.0: 55bd4f8ff2b323f317ae89e254ce87162d52a375
3434
refs/tags/1.1.0: bc3c16f09287e5545c1d3f76b7abd54f2eca868b
3535
refs/tags/1.2.0: f557861f822c34f07270347b94b5280de20a597e

branches/stable/src/librustc_resolve/resolve_imports.rs

Lines changed: 25 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -471,28 +471,19 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
471471
}
472472
}
473473

474-
let value_def_and_priv = {
475-
module_.decrement_outstanding_references_for(target, ValueNS);
476-
477-
// Record what this import resolves to for later uses in documentation,
478-
// this may resolve to either a value or a type, but for documentation
479-
// purposes it's good enough to just favor one over the other.
480-
value_result.success().map(|binding| {
481-
let def = binding.def().unwrap();
482-
let last_private = if binding.is_public() { lp } else { DependsOn(def.def_id()) };
483-
(def, last_private)
484-
})
485-
};
486-
487-
let type_def_and_priv = {
488-
module_.decrement_outstanding_references_for(target, TypeNS);
489-
490-
type_result.success().map(|binding| {
491-
let def = binding.def().unwrap();
492-
let last_private = if binding.is_public() { lp } else { DependsOn(def.def_id()) };
493-
(def, last_private)
494-
})
474+
// Record what this import resolves to for later uses in documentation,
475+
// this may resolve to either a value or a type, but for documentation
476+
// purposes it's good enough to just favor one over the other.
477+
module_.decrement_outstanding_references_for(target, ValueNS);
478+
module_.decrement_outstanding_references_for(target, TypeNS);
479+
480+
let def_and_priv = |binding: &NameBinding| {
481+
let def = binding.def().unwrap();
482+
let last_private = if binding.is_public() { lp } else { DependsOn(def.def_id()) };
483+
(def, last_private)
495484
};
485+
let value_def_and_priv = value_result.success().map(&def_and_priv);
486+
let type_def_and_priv = type_result.success().map(&def_and_priv);
496487

497488
let import_lp = LastImport {
498489
value_priv: value_def_and_priv.map(|(_, p)| p),
@@ -501,22 +492,13 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
501492
type_used: Used,
502493
};
503494

504-
if let Some((def, _)) = value_def_and_priv {
505-
self.resolver.def_map.borrow_mut().insert(directive.id,
506-
PathResolution {
507-
base_def: def,
508-
last_private: import_lp,
509-
depth: 0,
510-
});
511-
}
512-
if let Some((def, _)) = type_def_and_priv {
513-
self.resolver.def_map.borrow_mut().insert(directive.id,
514-
PathResolution {
515-
base_def: def,
516-
last_private: import_lp,
517-
depth: 0,
518-
});
519-
}
495+
let write_path_resolution = |(def, _)| {
496+
let path_resolution =
497+
PathResolution { base_def: def, last_private: import_lp, depth: 0 };
498+
self.resolver.def_map.borrow_mut().insert(directive.id, path_resolution);
499+
};
500+
value_def_and_priv.map(&write_path_resolution);
501+
type_def_and_priv.map(&write_path_resolution);
520502

521503
debug!("(resolving single import) successfully resolved import");
522504
return Success(());
@@ -575,19 +557,6 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
575557
return Success(());
576558
}
577559

578-
fn add_export(&mut self, module: Module<'b>, name: Name, binding: &NameBinding<'b>) {
579-
if !binding.is_public() { return }
580-
let node_id = match module.def_id() {
581-
Some(def_id) => self.resolver.ast_map.as_local_node_id(def_id).unwrap(),
582-
None => return,
583-
};
584-
let export = match binding.def() {
585-
Some(def) => Export { name: name, def_id: def.def_id() },
586-
None => return,
587-
};
588-
self.resolver.export_map.entry(node_id).or_insert(Vec::new()).push(export);
589-
}
590-
591560
fn define(&mut self,
592561
parent: Module<'b>,
593562
name: Name,
@@ -596,8 +565,12 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
596565
let binding = self.resolver.new_name_binding(binding);
597566
if let Err(old_binding) = parent.try_define_child(name, ns, binding) {
598567
self.report_conflict(name, ns, binding, old_binding);
599-
} else if binding.is_public() {
600-
self.add_export(parent, name, binding);
568+
} else if binding.is_public() { // Add to the export map
569+
if let (Some(parent_def_id), Some(def)) = (parent.def_id(), binding.def()) {
570+
let parent_node_id = self.resolver.ast_map.as_local_node_id(parent_def_id).unwrap();
571+
let export = Export { name: name, def_id: def.def_id() };
572+
self.resolver.export_map.entry(parent_node_id).or_insert(Vec::new()).push(export);
573+
}
601574
}
602575
}
603576

0 commit comments

Comments
 (0)