From 0db8ca6ca2cc400e4cdd95a2cf8867766d376730 Mon Sep 17 00:00:00 2001 From: Jeffrey Seyfried Date: Fri, 29 Jul 2016 17:52:56 +0000 Subject: [PATCH] nit: rename `module_` -> `module` --- src/librustc_resolve/lib.rs | 26 ++++++++++++------------- src/librustc_resolve/resolve_imports.rs | 20 +++++++++---------- 2 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 84ebfad9ff2e9..eb288b627f794 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -1228,9 +1228,9 @@ impl<'a> Resolver<'a> { } } - /// Resolves the given module path from the given root `module_`. + /// Resolves the given module path from the given root `search_module`. fn resolve_module_path_from_root(&mut self, - module_: Module<'a>, + mut search_module: Module<'a>, module_path: &[Name], index: usize, span: Span) @@ -1247,7 +1247,6 @@ impl<'a> Resolver<'a> { } } - let mut search_module = module_; let mut index = index; let module_path_len = module_path.len(); @@ -1444,10 +1443,9 @@ impl<'a> Resolver<'a> { } /// Returns the nearest normal module parent of the given module. - fn get_nearest_normal_module_parent(&self, module_: Module<'a>) -> Option> { - let mut module_ = module_; + fn get_nearest_normal_module_parent(&self, mut module: Module<'a>) -> Option> { loop { - match module_.parent_link { + match module.parent_link { NoParentLink => return None, ModuleParentLink(new_module, _) | BlockParentLink(new_module, _) => { @@ -1455,7 +1453,7 @@ impl<'a> Resolver<'a> { if new_module.is_normal() { return Some(new_module); } - module_ = new_module; + module = new_module; } } } @@ -1463,12 +1461,12 @@ impl<'a> Resolver<'a> { /// Returns the nearest normal module parent of the given module, or the /// module itself if it is a normal module. - fn get_nearest_normal_module_parent_or_self(&self, module_: Module<'a>) -> Module<'a> { - if module_.is_normal() { - return module_; + fn get_nearest_normal_module_parent_or_self(&self, module: Module<'a>) -> Module<'a> { + if module.is_normal() { + return module; } - match self.get_nearest_normal_module_parent(module_) { - None => module_, + match self.get_nearest_normal_module_parent(module) { + None => module, Some(new_module) => new_module, } } @@ -1485,8 +1483,8 @@ impl<'a> Resolver<'a> { "super" => 0, _ => return Success(NoPrefixFound), }; - let module_ = self.current_module; - let mut containing_module = self.get_nearest_normal_module_parent_or_self(module_); + let mut containing_module = + self.get_nearest_normal_module_parent_or_self(self.current_module); // Now loop through all the `super`s we find. while i < module_path.len() && "super" == module_path[i].as_str() { diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index feec81b9fc9ba..a2aab1ff815ac 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -490,14 +490,14 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { let value_result = self.resolve_name_in_module(target_module, source, ValueNS, false, true); let type_result = self.resolve_name_in_module(target_module, source, TypeNS, false, true); - let module_ = self.current_module; + let module = self.current_module; let mut privacy_error = true; for &(ns, result, determined) in &[(ValueNS, &value_result, value_determined), (TypeNS, &type_result, type_determined)] { match *result { Failed(..) if !determined.get() => { determined.set(true); - self.update_resolution(module_, target, ns, |_, resolution| { + self.update_resolution(module, target, ns, |_, resolution| { resolution.single_imports.directive_failed() }); } @@ -506,17 +506,17 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { span_err!(self.session, directive.span, E0253, "{}", &msg); // Do not import this illegal binding. Import a dummy binding and pretend // everything is fine - self.import_dummy_binding(module_, directive); + self.import_dummy_binding(module, directive); return Success(()); } Success(binding) if !self.is_accessible(binding.vis) => {} Success(binding) if !determined.get() => { determined.set(true); let imported_binding = directive.import(binding); - let conflict = self.try_define(module_, target, ns, imported_binding); + let conflict = self.try_define(module, target, ns, imported_binding); if let Err(old_binding) = conflict { let binding = &directive.import(binding); - self.report_conflict(module_, target, ns, binding, old_binding); + self.report_conflict(module, target, ns, binding, old_binding); } privacy_error = false; } @@ -556,7 +556,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { for &(ns, result) in &[(ValueNS, &value_result), (TypeNS, &type_result)] { let binding = match *result { Success(binding) => binding, _ => continue }; self.privacy_errors.push(PrivacyError(directive.span, source, binding)); - let _ = self.try_define(module_, target, ns, directive.import(binding)); + let _ = self.try_define(module, target, ns, directive.import(binding)); } } @@ -615,8 +615,8 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { self.session.span_err(directive.span, "items in traits are not importable."); } - let module_ = self.current_module; - if module_.def_id() == target_module.def_id() { + let module = self.current_module; + if module.def_id() == target_module.def_id() { // This means we are trying to glob import a module into itself, and it is a no-go let msg = "Cannot glob-import a module into itself.".into(); return Failed(Some((directive.span, msg))); @@ -629,7 +629,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { } // Add to target_module's glob_importers - target_module.glob_importers.borrow_mut().push((module_, directive)); + target_module.glob_importers.borrow_mut().push((module, directive)); // Ensure that `resolutions` isn't borrowed during `try_define`, // since it might get updated via a glob cycle. @@ -638,7 +638,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> { }).collect::>(); for ((name, ns), binding) in bindings { if binding.is_importable() && binding.is_pseudo_public() { - let _ = self.try_define(module_, name, ns, directive.import(binding)); + let _ = self.try_define(module, name, ns, directive.import(binding)); } }