Skip to content

Commit ee2d444

Browse files
committed
---
yaml --- r: 271979 b: refs/heads/master c: 85a1209 h: refs/heads/master i: 271977: 8d569a4 271975: 6d204b8
1 parent e5b7134 commit ee2d444

File tree

2 files changed

+20
-24
lines changed

2 files changed

+20
-24
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: bfb832e7c886a720e0aa847ffd8500621a3152d5
2+
refs/heads/master: 85a12095708850031cf9962e2bbd8cb9f4920d9f
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
44
refs/heads/try: 49312a405e14a449b98fe0056b12a40ac128be4a
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105

trunk/src/librustc_resolve/resolve_imports.rs

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl<'a> NameResolution<'a> {
168168

169169
// Returns Some(the resolution of the name), or None if the resolution depends
170170
// on whether more globs can define the name.
171-
fn try_result(&self, allow_private_imports: bool)
171+
fn try_result(&self, ns: Namespace, allow_private_imports: bool)
172172
-> Option<ResolveResult<&'a NameBinding<'a>>> {
173173
match self.binding {
174174
Some(binding) if !binding.defined_with(DefModifiers::GLOB_IMPORTED) =>
@@ -189,7 +189,18 @@ impl<'a> NameResolution<'a> {
189189
return None;
190190
}
191191

192-
return Indeterminate;
192+
let target_module = match directive.target_module.get() {
193+
Some(target_module) => target_module,
194+
None => return Some(Indeterminate),
195+
};
196+
let name = match directive.subclass {
197+
SingleImport { source, target, .. } if source == target => target,
198+
_ => return Some(Indeterminate),
199+
};
200+
match target_module.resolve_name(name, ns, false) {
201+
Failed(_) => {}
202+
_ => return Some(Indeterminate),
203+
}
193204
}
194205
}
195206

@@ -224,7 +235,7 @@ impl<'a> ::ModuleS<'a> {
224235
};
225236

226237
let resolution = resolutions.get(&(name, ns)).cloned().unwrap_or_default();
227-
if let Some(result) = resolution.try_result(allow_private_imports) {
238+
if let Some(result) = resolution.try_result(ns, allow_private_imports) {
228239
// If the resolution doesn't depend on glob definability, check privacy and return.
229240
return result.and_then(|binding| {
230241
let allowed = allow_private_imports || !binding.is_import() || binding.is_public();
@@ -483,27 +494,12 @@ impl<'a, 'b:'a, 'tcx:'b> ImportResolver<'a, 'b, 'tcx> {
483494
};
484495

485496
// We need to resolve both namespaces for this to succeed.
486-
let module_ = self.resolver.current_module;
487-
let (value_result, type_result) = {
488-
let mut resolve_in_ns = |ns, determined: bool| {
489-
// Temporarily count the directive as determined so that the resolution fails
490-
// (as opposed to being indeterminate) when it can only be defined by the directive.
491-
if !determined {
492-
module_.resolutions.borrow_mut().get_mut(&(target, ns)).unwrap()
493-
.single_imports.directive_failed();
494-
}
495-
let result =
496-
self.resolver.resolve_name_in_module(target_module, source, ns, false, true);
497-
if !determined {
498-
module_.resolutions.borrow_mut().get_mut(&(target, ns)).unwrap()
499-
.single_imports.add_directive(directive);
500-
}
501-
result
502-
};
503-
(resolve_in_ns(ValueNS, value_determined.get()),
504-
resolve_in_ns(TypeNS, type_determined.get()))
505-
};
497+
let value_result =
498+
self.resolver.resolve_name_in_module(target_module, source, ValueNS, false, true);
499+
let type_result =
500+
self.resolver.resolve_name_in_module(target_module, source, TypeNS, false, true);
506501

502+
let module_ = self.resolver.current_module;
507503
for &(ns, result, determined) in &[(ValueNS, &value_result, value_determined),
508504
(TypeNS, &type_result, type_determined)] {
509505
if determined.get() { continue }

0 commit comments

Comments
 (0)