name);
return Indeterminate;
}
- Success((binding, used_proxy)) => {
+ Success(binding) => {
// Check to see whether there are type bindings, and, if
// so, whether there is a module within.
if let Some(module_def) = binding.module() {
// Keep track of the closest private module used
// when resolving this import chain.
- if !used_proxy && !search_module.is_public {
+ if !binding.is_public() {
if let Some(did) = search_module.def_id() {
closest_private = LastMod(DependsOn(did));
}
debug!("(resolving module path for import) indeterminate; bailing");
return Indeterminate;
}
- Success((binding, _)) => match binding.module() {
+ Success(binding) => match binding.module() {
Some(containing_module) => {
search_module = containing_module;
start_index = 1;
name: Name,
namespace: Namespace,
record_used: bool)
- -> ResolveResult<(&'a NameBinding<'a>, bool)> {
+ -> ResolveResult<&'a NameBinding<'a>> {
debug!("(resolving item in lexical scope) resolving `{}` in namespace {:?} in `{}`",
name,
namespace,
debug!("(resolving item in lexical scope) indeterminate higher scope; bailing");
return Indeterminate;
}
- Success((binding, used_reexport)) => {
+ Success(binding) => {
// We found the module.
debug!("(resolving item in lexical scope) found name in module, done");
- return Success((binding, used_reexport));
+ return Success(binding);
}
}
/// Attempts to resolve the supplied name in the given module for the
/// given namespace. If successful, returns the binding corresponding to
/// the name.
- ///
- /// The boolean returned on success is an indicator of whether this lookup
- /// passed through a public re-export proxy.
fn resolve_name_in_module(&mut self,
module_: Module<'a>,
name: Name,
namespace: Namespace,
allow_private_imports: bool,
record_used: bool)
- -> ResolveResult<(&'a NameBinding<'a>, bool)> {
+ -> ResolveResult<&'a NameBinding<'a>> {
debug!("(resolving name in module) resolving `{}` in `{}`",
name,
module_to_string(&*module_));
self.used_crates.insert(krate);
}
}
- return Success((binding, false));
+ return Success(binding);
}
// Check the list of resolved imports.
if record_used {
self.record_import_use(name, namespace, &import_resolution);
}
- return Success((binding, true));
+ return Success(binding);
}
}
Some(..) | None => {} // Continue.
-> BareIdentifierPatternResolution {
let module = self.current_module;
match self.resolve_item_in_lexical_scope(module, name, ValueNS, true) {
- Success((binding, _)) => {
+ Success(binding) => {
debug!("(resolve bare identifier pattern) succeeded in finding {} at {:?}",
name,
binding);
let module = self.current_module;
let name = identifier.unhygienic_name;
match self.resolve_item_in_lexical_scope(module, name, namespace, record_used) {
- Success((binding, _)) => binding.def().map(LocalDef::from_def),
+ Success(binding) => binding.def().map(LocalDef::from_def),
Failed(Some((span, msg))) => {
resolve_error(self, span, ResolutionError::FailedToResolve(&*msg));
None
let name = segments.last().unwrap().identifier.name;
let result = self.resolve_name_in_module(containing_module, name, namespace, false, true);
let def = match result {
- Success((binding, _)) => {
+ Success(binding) => {
let (def, lp) = binding.def_and_lp();
(def, last_private.or(lp))
}
let name = segments.last().unwrap().identifier.name;
match self.resolve_name_in_module(containing_module, name, namespace, false, true) {
- Success((binding, _)) => {
+ Success(binding) => {
let (def, lp) = binding.def_and_lp();
Some((def, last_private.or(lp)))
}
}
if let AnonymousModuleRibKind(module) = self.get_ribs(namespace)[i].kind {
- if let Success((binding, _)) = self.resolve_name_in_module(module,
- ident.unhygienic_name,
- namespace,
- true,
- true) {
+ if let Success(binding) = self.resolve_name_in_module(module,
+ ident.unhygienic_name,
+ namespace,
+ true,
+ true) {
if let Some(def) = binding.def() {
return Some(LocalDef::from_def(def));
}
}
/// Resolves the name in the namespace of the module because it is being imported by
- /// importing_module. Returns the name bindings defining the name
- /// and whether or not the name was imported.
+ /// importing_module. Returns the name bindings defining the name.
fn resolve_name_in_module(&mut self,
module: Module<'b>, // Module containing the name
name: Name,
ns: Namespace,
importing_module: Module<'b>) // Module importing the name
- -> (ResolveResult<&'b NameBinding<'b>>, bool) {
+ -> ResolveResult<&'b NameBinding<'b>> {
build_reduced_graph::populate_module_if_necessary(self.resolver, module);
if let Some(name_binding) = module.get_child(name, ns) {
if name_binding.is_extern_crate() {
self.resolver.used_crates.insert(krate);
}
}
- return (Success(name_binding), false)
+ return Success(name_binding);
}
// If there is an unresolved glob at this point in the containing module, bail out.
// We don't know enough to be able to resolve the name.
if module.pub_glob_count.get() > 0 {
- return (Indeterminate, false);
+ return Indeterminate;
}
match module.import_resolutions.borrow().get(&(name, ns)) {
// The containing module definitely doesn't have an exported import with the
// name in question. We can therefore accurately report that names are unbound.
- None => (Failed(None), false),
+ None => Failed(None),
// The name is an import which has been fully resolved, so we just follow it.
Some(resolution) if resolution.outstanding_references == 0 => {
// Import resolutions must be declared with "pub" in order to be exported.
if !resolution.is_public {
- return (Failed(None), false);
+ return Failed(None);
}
if let Some(binding) = resolution.binding {
self.resolver.record_import_use(name, ns, &resolution);
- (Success(binding), true)
+ Success(binding)
} else {
- (Failed(None), false)
+ Failed(None)
}
}
// In this case we continue as if we resolved the import and let
// check_for_conflicts_between_imports_and_items handle the conflict
Some(_) => match (importing_module.def_id(), module.def_id()) {
- (Some(id1), Some(id2)) if id1 == id2 => (Failed(None), false),
- _ => (Indeterminate, false)
+ (Some(id1), Some(id2)) if id1 == id2 => Failed(None),
+ _ => Indeterminate
},
}
}
};
// We need to resolve both namespaces for this to succeed.
- let (value_result, value_used_reexport) =
+ let value_result =
self.resolve_name_in_module(target_module, source, ValueNS, module_);
- let (type_result, type_used_reexport) =
+ let type_result =
self.resolve_name_in_module(target_module, source, TypeNS, module_);
match (&value_result, &type_result) {
- (&Success(name_binding), _) if !value_used_reexport &&
+ (&Success(name_binding), _) if !name_binding.is_import() &&
directive.is_public &&
!name_binding.is_public() => {
let msg = format!("`{}` is private, and cannot be reexported", source);
.emit();
}
- (_, &Success(name_binding)) if !type_used_reexport && directive.is_public => {
+ (_, &Success(name_binding)) if !name_binding.is_import() && directive.is_public => {
if !name_binding.is_public() {
let msg = format!("`{}` is private, and cannot be reexported", source);
let note_msg =
_ => (),
}
- let mut value_used_public = false;
- let mut type_used_public = false;
-
// We've successfully resolved the import. Write the results in.
let mut import_resolutions = module_.import_resolutions.borrow_mut();
{
- let mut check_and_write_import = |namespace, result, used_public: &mut bool| {
+ let mut check_and_write_import = |namespace, result| {
let result: &ResolveResult<&NameBinding> = result;
let import_resolution = import_resolutions.get_mut(&(target, namespace)).unwrap();
import_resolution.is_public = directive.is_public;
self.add_export(module_, target, &import_resolution);
- *used_public = name_binding.is_public();
}
Failed(_) => {
// Continue.
directive.span,
(target, namespace));
};
- check_and_write_import(ValueNS, &value_result, &mut value_used_public);
- check_and_write_import(TypeNS, &type_result, &mut type_used_public);
+ check_and_write_import(ValueNS, &value_result);
+ check_and_write_import(TypeNS, &type_result);
}
if let (&Failed(_), &Failed(_)) = (&value_result, &type_result) {
return Failed(Some((directive.span, msg)));
}
- let value_used_public = value_used_reexport || value_used_public;
- let type_used_public = type_used_reexport || type_used_public;
-
let value_def_and_priv = {
let import_resolution_value = import_resolutions.get_mut(&(target, ValueNS)).unwrap();
assert!(import_resolution_value.outstanding_references >= 1);
// purposes it's good enough to just favor one over the other.
import_resolution_value.binding.as_ref().map(|binding| {
let def = binding.def().unwrap();
- let last_private = if value_used_public { lp } else { DependsOn(def.def_id()) };
+ let last_private = if binding.is_public() { lp } else { DependsOn(def.def_id()) };
(def, last_private)
})
};
import_resolution_type.binding.as_ref().map(|binding| {
let def = binding.def().unwrap();
- let last_private = if type_used_public { lp } else { DependsOn(def.def_id()) };
+ let last_private = if binding.is_public() { lp } else { DependsOn(def.def_id()) };
(def, last_private)
})
};