Skip to content

Commit f117549

Browse files
committed
rustc: De-indent portions of middle::resolve
It's a little prettier to look at now
1 parent c1e3e2d commit f117549

File tree

1 file changed

+26
-56
lines changed

1 file changed

+26
-56
lines changed

src/librustc/middle/resolve.rs

Lines changed: 26 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5408,8 +5408,7 @@ impl Resolver {
54085408
}
54095409
}
54105410

5411-
fn search_for_traits_containing_method(&mut self, name: Ident)
5412-
-> ~[DefId] {
5411+
fn search_for_traits_containing_method(&mut self, name: Ident) -> ~[DefId] {
54135412
debug!("(searching for traits containing method) looking for '{}'",
54145413
self.session.str_of(name));
54155414

@@ -5438,70 +5437,41 @@ impl Resolver {
54385437
self.populate_module_if_necessary(search_module);
54395438

54405439
let children = search_module.children.borrow();
5441-
for (_, &child_name_bindings) in children.get().iter() {
5442-
match child_name_bindings.def_for_namespace(TypeNS) {
5443-
Some(def) => {
5444-
match def {
5445-
DefTrait(trait_def_id) => {
5446-
if candidate_traits.contains(&trait_def_id) {
5447-
self.add_trait_info(
5448-
&mut found_traits,
5449-
trait_def_id, name);
5450-
}
5451-
}
5452-
_ => {
5453-
// Continue.
5454-
}
5455-
}
5456-
}
5457-
None => {
5458-
// Continue.
5459-
}
5440+
for (_, &child_names) in children.get().iter() {
5441+
let def = match child_names.def_for_namespace(TypeNS) {
5442+
Some(def) => def,
5443+
None => continue
5444+
};
5445+
let trait_def_id = match def {
5446+
DefTrait(trait_def_id) => trait_def_id,
5447+
_ => continue,
5448+
};
5449+
if candidate_traits.contains(&trait_def_id) {
5450+
self.add_trait_info(&mut found_traits, trait_def_id,
5451+
name);
54605452
}
54615453
}
54625454

54635455
// Look for imports.
54645456
let import_resolutions = search_module.import_resolutions
54655457
.borrow();
5466-
for (_, &import_resolution) in import_resolutions.get()
5467-
.iter() {
5468-
match import_resolution.target_for_namespace(TypeNS) {
5469-
None => {
5470-
// Continue.
5471-
}
5472-
Some(target) => {
5473-
match target.bindings.def_for_namespace(TypeNS) {
5474-
Some(def) => {
5475-
match def {
5476-
DefTrait(trait_def_id) => {
5477-
if candidate_traits.contains(&trait_def_id) {
5478-
self.add_trait_info(
5479-
&mut found_traits,
5480-
trait_def_id, name);
5481-
self.used_imports.insert(
5482-
import_resolution.type_id
5483-
.get());
5484-
}
5485-
}
5486-
_ => {
5487-
// Continue.
5488-
}
5489-
}
5490-
}
5491-
None => {
5492-
// Continue.
5493-
}
5494-
}
5495-
}
5458+
for (_, &import) in import_resolutions.get().iter() {
5459+
let target = match import.target_for_namespace(TypeNS) {
5460+
None => continue,
5461+
Some(target) => target,
5462+
};
5463+
let did = match target.bindings.def_for_namespace(TypeNS) {
5464+
Some(DefTrait(trait_def_id)) => trait_def_id,
5465+
Some(..) | None => continue,
5466+
};
5467+
if candidate_traits.contains(&did) {
5468+
self.add_trait_info(&mut found_traits, did, name);
5469+
self.used_imports.insert(import.type_id.get());
54965470
}
54975471
}
54985472

5499-
// Move to the next parent.
55005473
match search_module.parent_link {
5501-
NoParentLink | ModuleParentLink(..) => {
5502-
// Done.
5503-
break;
5504-
}
5474+
NoParentLink | ModuleParentLink(..) => break,
55055475
BlockParentLink(parent_module, _) => {
55065476
search_module = parent_module;
55075477
}

0 commit comments

Comments
 (0)