Skip to content

Commit

Permalink
nit: rename module_ -> module
Browse files Browse the repository at this point in the history
  • Loading branch information
jseyfried committed Aug 1, 2016
1 parent 6372a6d commit 0db8ca6
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 24 deletions.
26 changes: 12 additions & 14 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -1247,7 +1247,6 @@ impl<'a> Resolver<'a> {
}
}

let mut search_module = module_;
let mut index = index;
let module_path_len = module_path.len();

Expand Down Expand Up @@ -1444,31 +1443,30 @@ 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<Module<'a>> {
let mut module_ = module_;
fn get_nearest_normal_module_parent(&self, mut module: Module<'a>) -> Option<Module<'a>> {
loop {
match module_.parent_link {
match module.parent_link {
NoParentLink => return None,
ModuleParentLink(new_module, _) |
BlockParentLink(new_module, _) => {
let new_module = new_module;
if new_module.is_normal() {
return Some(new_module);
}
module_ = new_module;
module = new_module;
}
}
}
}

/// 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,
}
}
Expand All @@ -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() {
Expand Down
20 changes: 10 additions & 10 deletions src/librustc_resolve/resolve_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
});
}
Expand All @@ -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;
}
Expand Down Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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)));
Expand All @@ -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.
Expand All @@ -638,7 +638,7 @@ impl<'a, 'b:'a> ImportResolver<'a, 'b> {
}).collect::<Vec<_>>();
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));
}
}

Expand Down

0 comments on commit 0db8ca6

Please sign in to comment.