/// The privacy of this `use` directive (whether it's `use` or
/// `pub use`.
privacy: Privacy,
- id: node_id,
// The number of outstanding references to this name. When this reaches
// zero, outside modules can count on the targets being correct. Before
// then, all bets are off; future imports could override this name.
-
outstanding_references: uint,
/// The value that this `use` directive names, if there is one.
value_target: Option<Target>,
+ /// The source node of the `use` directive leading to the value target
+ /// being non-none
+ value_id: node_id,
+
/// The type that this `use` directive names, if there is one.
type_target: Option<Target>,
+ /// The source node of the `use` directive leading to the type target
+ /// being non-none
+ type_id: node_id,
}
pub fn ImportResolution(privacy: Privacy,
id: node_id) -> ImportResolution {
ImportResolution {
privacy: privacy,
- id: id,
+ type_id: id,
+ value_id: id,
outstanding_references: 0,
value_target: None,
type_target: None,
ValueNS => return copy self.value_target
}
}
+
+ fn id(&self, namespace: Namespace) -> node_id {
+ match namespace {
+ TypeNS => self.type_id,
+ ValueNS => self.value_id,
+ }
+ }
}
/// The link from a module up to its nearest parent node.
// the source of this name is different now
resolution.privacy = privacy;
- resolution.id = id;
+ resolution.type_id = id;
+ resolution.value_id = id;
}
None => {
debug!("(building import directive) creating new");
containing_module,
target,
source,
- import_directive.span);
+ import_directive);
}
GlobImport => {
let privacy = import_directive.privacy;
containing_module: @mut Module,
target: ident,
source: ident,
- span: span)
+ directive: &ImportDirective)
-> ResolveResult<()> {
debug!("(resolving single import) resolving `%s` = `%s::%s` from \
`%s`",
return UnboundResult;
}
Some(target) => {
- this.used_imports.insert(import_resolution.id);
+ let id = import_resolution.id(namespace);
+ this.used_imports.insert(id);
return BoundResult(target.target_module,
- target.bindings);
+ target.bindings);
}
}
}
match value_result {
BoundResult(target_module, name_bindings) => {
+ debug!("(resolving single import) found value target");
import_resolution.value_target =
Some(Target(target_module, name_bindings));
+ import_resolution.value_id = directive.id;
}
UnboundResult => { /* Continue. */ }
UnknownResult => {
}
match type_result {
BoundResult(target_module, name_bindings) => {
+ debug!("(resolving single import) found type target");
import_resolution.type_target =
Some(Target(target_module, name_bindings));
+ import_resolution.type_id = directive.id;
}
UnboundResult => { /* Continue. */ }
UnknownResult => {
}
}
+ let span = directive.span;
if resolve_fail {
self.session.span_err(span, fmt!("unresolved import: there is no `%s` in `%s`",
*self.session.str_of(source),
Some(target) => {
debug!("(resolving item in lexical scope) using \
import resolution");
- self.used_imports.insert(import_resolution.id);
+ self.used_imports.insert(import_resolution.id(namespace));
return Success(copy target);
}
}
import_resolution.privacy == Public => {
debug!("(resolving name in module) resolved to \
import");
- self.used_imports.insert(import_resolution.id);
+ self.used_imports.insert(import_resolution.id(namespace));
return Success(copy target);
}
Some(_) => {
namespace)) {
(Some(def), Some(Public)) => {
// Found it.
- self.used_imports.insert(import_resolution.id);
+ let id = import_resolution.id(namespace);
+ self.used_imports.insert(id);
return ImportNameDefinition(def);
}
(Some(_), _) | (None, _) => {
&mut found_traits,
trait_def_id, name);
self.used_imports.insert(
- import_resolution.id);
+ import_resolution.type_id);
}
}
_ => {