diff options
Diffstat (limited to 'src/librustc/middle/resolve.rs')
| -rw-r--r-- | src/librustc/middle/resolve.rs | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 30a513407a5..8d1fc3cad07 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -790,7 +790,7 @@ impl PrimitiveTypeTable { } -fn namespace_error_to_str(ns: NamespaceError) -> &'static str { +fn namespace_error_to_string(ns: NamespaceError) -> &'static str { match ns { NoError => "", ModuleError | TypeError => "type or module", @@ -1071,14 +1071,14 @@ impl<'a> Resolver<'a> { let ns = ns.unwrap(); self.resolve_error(sp, format!("duplicate definition of {} `{}`", - namespace_error_to_str(duplicate_type), + namespace_error_to_string(duplicate_type), token::get_ident(name)).as_slice()); { let r = child.span_for_namespace(ns); for sp in r.iter() { self.session.span_note(*sp, format!("first definition of {} `{}` here", - namespace_error_to_str(duplicate_type), + namespace_error_to_string(duplicate_type), token::get_ident(name)).as_slice()); } } @@ -1508,7 +1508,7 @@ impl<'a> Resolver<'a> { false, true)); debug!("(build reduced graph for item) found extern `{}`", - self.module_to_str(&*external_module)); + self.module_to_string(&*external_module)); parent.module().external_module_children.borrow_mut() .insert(name.name, external_module.clone()); self.build_reduced_graph_for_external_crate(external_module); @@ -1862,7 +1862,7 @@ impl<'a> Resolver<'a> { /// Builds the reduced graph rooted at the given external module. fn populate_external_module(&mut self, module: Rc<Module>) { debug!("(populating external module) attempting to populate {}", - self.module_to_str(&*module)); + self.module_to_string(&*module)); let def_id = match module.def_id.get() { None => { @@ -1930,7 +1930,7 @@ impl<'a> Resolver<'a> { SingleImport(target, _) => { debug!("(building import directive) building import \ directive: {}::{}", - self.idents_to_str(module_.imports.borrow().last().unwrap() + self.idents_to_string(module_.imports.borrow().last().unwrap() .module_path.as_slice()), token::get_ident(target)); @@ -2003,7 +2003,7 @@ impl<'a> Resolver<'a> { /// submodules. fn resolve_imports_for_module_subtree(&mut self, module_: Rc<Module>) { debug!("(resolving imports for module subtree) resolving {}", - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); let orig_module = replace(&mut self.current_module, module_.clone()); self.resolve_imports_for_module(module_.clone()); self.current_module = orig_module; @@ -2030,7 +2030,7 @@ impl<'a> Resolver<'a> { if module.all_imports_resolved() { debug!("(resolving imports for module) all imports resolved for \ {}", - self.module_to_str(&*module)); + self.module_to_string(&*module)); return; } @@ -2047,7 +2047,7 @@ impl<'a> Resolver<'a> { None => (import_directive.span, String::new()) }; let msg = format!("unresolved import `{}`{}", - self.import_path_to_str( + self.import_path_to_string( import_directive.module_path .as_slice(), import_directive.subclass), @@ -2063,7 +2063,7 @@ impl<'a> Resolver<'a> { } } - fn idents_to_str(&self, idents: &[Ident]) -> String { + fn idents_to_string(&self, idents: &[Ident]) -> String { let mut first = true; let mut result = String::new(); for ident in idents.iter() { @@ -2077,15 +2077,15 @@ impl<'a> Resolver<'a> { result } - fn path_idents_to_str(&self, path: &Path) -> String { + fn path_idents_to_string(&self, path: &Path) -> String { let identifiers: Vec<ast::Ident> = path.segments .iter() .map(|seg| seg.identifier) .collect(); - self.idents_to_str(identifiers.as_slice()) + self.idents_to_string(identifiers.as_slice()) } - fn import_directive_subclass_to_str(&mut self, + fn import_directive_subclass_to_string(&mut self, subclass: ImportDirectiveSubclass) -> String { match subclass { @@ -2096,16 +2096,16 @@ impl<'a> Resolver<'a> { } } - fn import_path_to_str(&mut self, + fn import_path_to_string(&mut self, idents: &[Ident], subclass: ImportDirectiveSubclass) -> String { if idents.is_empty() { - self.import_directive_subclass_to_str(subclass) + self.import_directive_subclass_to_string(subclass) } else { (format!("{}::{}", - self.idents_to_str(idents), - self.import_directive_subclass_to_str( + self.idents_to_string(idents), + self.import_directive_subclass_to_string( subclass))).to_string() } } @@ -2124,8 +2124,8 @@ impl<'a> Resolver<'a> { debug!("(resolving import for module) resolving import `{}::...` in \ `{}`", - self.idents_to_str(module_path.as_slice()), - self.module_to_str(&*module_)); + self.idents_to_string(module_path.as_slice()), + self.module_to_string(&*module_)); // First, resolve the module path for the directive, if necessary. let container = if module_path.len() == 0 { @@ -2231,9 +2231,9 @@ impl<'a> Resolver<'a> { debug!("(resolving single import) resolving `{}` = `{}::{}` from \ `{}` id {}, last private {:?}", token::get_ident(target), - self.module_to_str(&*containing_module), + self.module_to_string(&*containing_module), token::get_ident(source), - self.module_to_str(module_), + self.module_to_string(module_), directive.id, lp); @@ -2420,7 +2420,7 @@ impl<'a> Resolver<'a> { if value_result.is_unbound() && type_result.is_unbound() { let msg = format!("There is no `{}` in `{}`", token::get_ident(source), - self.module_to_str(&*containing_module)); + self.module_to_string(&*containing_module)); return Failed(Some((directive.span, msg))); } let value_used_public = value_used_reexport || value_used_public; @@ -2494,7 +2494,7 @@ impl<'a> Resolver<'a> { debug!("(resolving glob import) writing module resolution \ {:?} into `{}`", target_import_resolution.type_target.is_none(), - self.module_to_str(module_)); + self.module_to_string(module_)); if !target_import_resolution.is_public { debug!("(resolving glob import) nevermind, just kidding"); @@ -2590,9 +2590,9 @@ impl<'a> Resolver<'a> { debug!("(resolving glob import) writing resolution `{}` in `{}` \ to `{}`", - token::get_name(name).get().to_str(), - self.module_to_str(&*containing_module), - self.module_to_str(module_)); + token::get_name(name).get().to_string(), + self.module_to_string(&*containing_module), + self.module_to_string(module_)); // Merge the child item into the import resolution. if name_bindings.defined_in_public_namespace(ValueNS) { @@ -2652,7 +2652,7 @@ impl<'a> Resolver<'a> { false) { Failed(None) => { let segment_name = token::get_ident(name); - let module_name = self.module_to_str(&*search_module); + let module_name = self.module_to_string(&*search_module); let mut span = span; let msg = if "???" == module_name.as_slice() { span.hi = span.lo + Pos::from_uint(segment_name.get().len()); @@ -2660,10 +2660,10 @@ impl<'a> Resolver<'a> { match search_parent_externals(name.name, &self.current_module) { Some(module) => { - let path_str = self.idents_to_str(module_path); - let target_mod_str = self.module_to_str(&*module); + let path_str = self.idents_to_string(module_path); + let target_mod_str = self.module_to_string(&*module); let current_mod_str = - self.module_to_str(&*self.current_module); + self.module_to_string(&*self.current_module); let prefix = if target_mod_str == current_mod_str { "self::".to_string() @@ -2771,8 +2771,8 @@ impl<'a> Resolver<'a> { debug!("(resolving module path for import) processing `{}` rooted at \ `{}`", - self.idents_to_str(module_path), - self.module_to_str(&*module_)); + self.idents_to_string(module_path), + self.module_to_string(&*module_)); // Resolve the module prefix, if any. let module_prefix_result = self.resolve_module_prefix(module_.clone(), @@ -2783,7 +2783,7 @@ impl<'a> Resolver<'a> { let last_private; match module_prefix_result { Failed(None) => { - let mpath = self.idents_to_str(module_path); + let mpath = self.idents_to_string(module_path); let mpath = mpath.as_slice(); match mpath.rfind(':') { Some(idx) => { @@ -2865,7 +2865,7 @@ impl<'a> Resolver<'a> { namespace {:?} in `{}`", token::get_ident(name), namespace, - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); // The current module node is handled specially. First, check for // its immediate children. @@ -3098,7 +3098,7 @@ impl<'a> Resolver<'a> { break } debug!("(resolving module prefix) resolving `super` at {}", - self.module_to_str(&*containing_module)); + self.module_to_string(&*containing_module)); match self.get_nearest_normal_module_parent(containing_module) { None => return Failed(None), Some(new_module) => { @@ -3109,7 +3109,7 @@ impl<'a> Resolver<'a> { } debug!("(resolving module prefix) finished resolving prefix at {}", - self.module_to_str(&*containing_module)); + self.module_to_string(&*containing_module)); return Success(PrefixFound(containing_module, i)); } @@ -3129,7 +3129,7 @@ impl<'a> Resolver<'a> { -> ResolveResult<(Target, bool)> { debug!("(resolving name in module) resolving `{}` in `{}`", token::get_name(name).get(), - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); // First, check the direct children of the module. self.populate_module_if_necessary(&module_); @@ -3262,19 +3262,19 @@ impl<'a> Resolver<'a> { // OK. Continue. debug!("(recording exports for module subtree) recording \ exports for local module `{}`", - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); } None => { // Record exports for the root module. debug!("(recording exports for module subtree) recording \ exports for root module `{}`", - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); } Some(_) => { // Bail out. debug!("(recording exports for module subtree) not recording \ exports for `{}`", - self.module_to_str(&*module_)); + self.module_to_string(&*module_)); return; } } @@ -3390,7 +3390,7 @@ impl<'a> Resolver<'a> { None => { debug!("!!! (with scope) didn't find `{}` in `{}`", token::get_ident(name), - self.module_to_str(&*orig_module)); + self.module_to_string(&*orig_module)); } Some(name_bindings) => { match (*name_bindings).get_module_if_available() { @@ -3398,7 +3398,7 @@ impl<'a> Resolver<'a> { debug!("!!! (with scope) didn't find module \ for `{}` in `{}`", token::get_ident(name), - self.module_to_str(&*orig_module)); + self.module_to_string(&*orig_module)); } Some(module_) => { self.current_module = module_; @@ -3892,7 +3892,7 @@ impl<'a> Resolver<'a> { reference_type: TraitReferenceType) { match self.resolve_path(id, &trait_reference.path, TypeNS, true) { None => { - let path_str = self.path_idents_to_str(&trait_reference.path); + let path_str = self.path_idents_to_string(&trait_reference.path); let usage_str = match reference_type { TraitBoundingTypeParameter => "bound type parameter with", TraitImplementation => "implement", @@ -3911,7 +3911,7 @@ impl<'a> Resolver<'a> { (def, _) => { self.resolve_error(trait_reference.path.span, format!("`{}` is not a trait", - self.path_idents_to_str( + self.path_idents_to_string( &trait_reference.path))); // If it's a typedef, give a note @@ -3959,7 +3959,7 @@ impl<'a> Resolver<'a> { .identifier), def); debug!("(resolving struct) writing resolution for `{}` (id {})", - this.path_idents_to_str(path), + this.path_idents_to_string(path), path_id); this.record_def(path_id, (def, lp)); } @@ -4071,7 +4071,7 @@ impl<'a> Resolver<'a> { let method_name = method.ident.name; if self.method_map.borrow().find(&(method_name, did)).is_none() { - let path_str = self.path_idents_to_str(&trait_ref.path); + let path_str = self.path_idents_to_string(&trait_ref.path); self.resolve_error(method.span, format!("method `{}` is not a member of trait `{}`", token::get_name(method_name), @@ -4281,13 +4281,13 @@ impl<'a> Resolver<'a> { // Write the result into the def map. debug!("(resolving type) writing resolution for `{}` \ (id {})", - self.path_idents_to_str(path), + self.path_idents_to_string(path), path_id); self.record_def(path_id, def); } None => { let msg = format!("use of undeclared type name `{}`", - self.path_idents_to_str(path)); + self.path_idents_to_string(path)); self.resolve_error(ty.span, msg.as_slice()); } } @@ -4488,7 +4488,7 @@ impl<'a> Resolver<'a> { debug!("(resolving pattern) didn't find struct \ def: {:?}", result); let msg = format!("`{}` does not name a structure", - self.path_idents_to_str(path)); + self.path_idents_to_string(path)); self.resolve_error(path.span, msg.as_slice()); } } @@ -4718,7 +4718,7 @@ impl<'a> Resolver<'a> { Some((span, msg)) => (span, msg), None => { let msg = format!("Use of undeclared module `{}`", - self.idents_to_str( + self.idents_to_string( module_path_idents.as_slice())); (path.span, msg) } @@ -4794,7 +4794,7 @@ impl<'a> Resolver<'a> { Some((span, msg)) => (span, msg), None => { let msg = format!("Use of undeclared module `::{}`", - self.idents_to_str( + self.idents_to_string( module_path_idents.as_slice())); (path.span, msg) } @@ -4999,7 +4999,7 @@ impl<'a> Resolver<'a> { match get_module(self, path.span, ident_path.as_slice()) { Some(module) => match module.children.borrow().find(&name) { Some(binding) => { - let p_str = self.path_idents_to_str(&path); + let p_str = self.path_idents_to_string(&path); match binding.def_for_namespace(ValueNS) { Some(DefStaticMethod(_, provenance, _)) => { match provenance { @@ -5021,7 +5021,7 @@ impl<'a> Resolver<'a> { let method_map = self.method_map.borrow(); match self.current_trait_ref { Some((did, ref trait_ref)) => { - let path_str = self.path_idents_to_str(&trait_ref.path); + let path_str = self.path_idents_to_string(&trait_ref.path); match method_map.find(&(name, did)) { Some(&SelfStatic) => return StaticTraitMethod(path_str), @@ -5094,7 +5094,7 @@ impl<'a> Resolver<'a> { Some(def) => { // Write the result into the def map. debug!("(resolving expr) resolved `{}`", - self.path_idents_to_str(path)); + self.path_idents_to_string(path)); // First-class methods are not supported yet; error // out here. @@ -5114,7 +5114,7 @@ impl<'a> Resolver<'a> { self.record_def(expr.id, def); } None => { - let wrong_name = self.path_idents_to_str(path); + let wrong_name = self.path_idents_to_string(path); // Be helpful if the name refers to a struct // (The pattern matching def_tys where the id is in self.structs // matches on regular structs while excluding tuple- and enum-like @@ -5210,7 +5210,7 @@ impl<'a> Resolver<'a> { debug!("(resolving expression) didn't find struct \ def: {:?}", result); let msg = format!("`{}` does not name a structure", - self.path_idents_to_str(path)); + self.path_idents_to_string(path)); self.resolve_error(path.span, msg.as_slice()); } } @@ -5510,7 +5510,7 @@ impl<'a> Resolver<'a> { // /// A somewhat inefficient routine to obtain the name of a module. - fn module_to_str(&self, module: &Module) -> String { + fn module_to_string(&self, module: &Module) -> String { let mut idents = Vec::new(); fn collect_mod(idents: &mut Vec<ast::Ident>, module: &Module) { @@ -5531,14 +5531,14 @@ impl<'a> Resolver<'a> { if idents.len() == 0 { return "???".to_string(); } - self.idents_to_str(idents.move_iter().rev() + self.idents_to_string(idents.move_iter().rev() .collect::<Vec<ast::Ident>>() .as_slice()) } #[allow(dead_code)] // useful for debugging fn dump_module(&mut self, module_: Rc<Module>) { - debug!("Dump of module `{}`:", self.module_to_str(&*module_)); + debug!("Dump of module `{}`:", self.module_to_string(&*module_)); debug!("Children:"); self.populate_module_if_necessary(&module_); |
