Skip to content

Commit 72d57cf

Browse files
committed
Formatting librustc_resolve
1 parent da2276e commit 72d57cf

File tree

1 file changed

+59
-71
lines changed

1 file changed

+59
-71
lines changed

src/librustc_resolve/lib.rs

Lines changed: 59 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,13 @@
2525
#![feature(rustc_private)]
2626
#![feature(staged_api)]
2727

28-
#[macro_use] extern crate log;
29-
#[macro_use] extern crate syntax;
30-
#[macro_use] #[no_link] extern crate rustc_bitflags;
28+
#[macro_use]
29+
extern crate log;
30+
#[macro_use]
31+
extern crate syntax;
32+
#[macro_use]
33+
#[no_link]
34+
extern crate rustc_bitflags;
3135

3236
extern crate rustc;
3337

@@ -68,7 +72,8 @@ use syntax::ast::{ExprLoop, ExprWhile, ExprMethodCall};
6872
use syntax::ast::{ExprPath, ExprStruct, FnDecl};
6973
use syntax::ast::{ForeignItemFn, ForeignItemStatic, Generics};
7074
use syntax::ast::{Ident, ImplItem, Item, ItemConst, ItemEnum, ItemExternCrate};
71-
use syntax::ast::{ItemFn, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, ItemDefaultImpl};
75+
use syntax::ast::{ItemFn, ItemForeignMod, ItemImpl, ItemMac, ItemMod,
76+
ItemStatic, ItemDefaultImpl};
7277
use syntax::ast::{ItemStruct, ItemTrait, ItemTy, ItemUse};
7378
use syntax::ast::{Local, MethodImplItem, Name, NodeId};
7479
use syntax::ast::{Pat, PatEnum, PatIdent, PatLit, PatQPath};
@@ -194,9 +199,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
194199
fn visit_generics(&mut self, generics: &Generics) {
195200
self.resolve_generics(generics);
196201
}
197-
fn visit_poly_trait_ref(&mut self,
198-
tref: &ast::PolyTraitRef,
199-
m: &ast::TraitBoundModifier) {
202+
fn visit_poly_trait_ref(&mut self, tref: &ast::PolyTraitRef, m: &ast::TraitBoundModifier) {
200203
match self.resolve_trait_reference(tref.trait_ref.ref_id, &tref.trait_ref.path, 0) {
201204
Ok(def) => self.record_def(tref.trait_ref.ref_id, def),
202205
Err(_) => { /* error already reported */ }
@@ -525,11 +528,7 @@ impl NameBindings {
525528
sp: Span) {
526529
// Merges the module with the existing type def or creates a new one.
527530
let modifiers = if is_public { PUBLIC } else { DefModifiers::empty() } | IMPORTABLE;
528-
let module_ = Rc::new(Module::new(parent_link,
529-
def_id,
530-
kind,
531-
external,
532-
is_public));
531+
let module_ = Rc::new(Module::new(parent_link, def_id, kind, external, is_public));
533532
let type_def = self.type_def.borrow().clone();
534533
match type_def {
535534
None => {
@@ -843,7 +842,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
843842
fn new(session: &'a Session,
844843
ast_map: &'a ast_map::Map<'tcx>,
845844
crate_span: Span,
846-
make_glob_map: MakeGlobMap) -> Resolver<'a, 'tcx> {
845+
make_glob_map: MakeGlobMap)
846+
-> Resolver<'a, 'tcx> {
847847
let graph_root = NameBindings::new();
848848

849849
graph_root.define_module(NoParentLink,
@@ -966,9 +966,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
966966
span: Span,
967967
name_search_type: NameSearchType,
968968
lp: LastPrivate)
969-
-> ResolveResult<(Rc<Module>, LastPrivate)> {
970-
fn search_parent_externals(needle: Name, module: &Rc<Module>)
971-
-> Option<Rc<Module>> {
969+
-> ResolveResult<(Rc<Module>, LastPrivate)> {
970+
fn search_parent_externals(needle: Name, module: &Rc<Module>) -> Option<Rc<Module>> {
972971
match module.external_module_children.borrow().get(&needle) {
973972
Some(_) => Some(module.clone()),
974973
None => match module.parent_link {
@@ -1189,7 +1188,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
11891188
module_: Rc<Module>,
11901189
name: Name,
11911190
namespace: Namespace)
1192-
-> ResolveResult<(Target, bool)> {
1191+
-> ResolveResult<(Target, bool)> {
11931192
debug!("(resolving item in lexical scope) resolving `{}` in \
11941193
namespace {:?} in `{}`",
11951194
token::get_name(name),
@@ -1320,7 +1319,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13201319
fn resolve_module_in_lexical_scope(&mut self,
13211320
module_: Rc<Module>,
13221321
name: Name)
1323-
-> ResolveResult<Rc<Module>> {
1322+
-> ResolveResult<Rc<Module>> {
13241323
// If this module is an anonymous module, resolve the item in the
13251324
// lexical scope. Otherwise, resolve the item from the crate root.
13261325
let resolve_result = self.resolve_item_in_lexical_scope(module_, name, TypeNS);
@@ -1361,8 +1360,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13611360
}
13621361

13631362
/// Returns the nearest normal module parent of the given module.
1364-
fn get_nearest_normal_module_parent(&mut self, module_: Rc<Module>)
1365-
-> Option<Rc<Module>> {
1363+
fn get_nearest_normal_module_parent(&mut self, module_: Rc<Module>) -> Option<Rc<Module>> {
13661364
let mut module_ = module_;
13671365
loop {
13681366
match module_.parent_link.clone() {
@@ -1384,8 +1382,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13841382

13851383
/// Returns the nearest normal module parent of the given module, or the
13861384
/// module itself if it is a normal module.
1387-
fn get_nearest_normal_module_parent_or_self(&mut self, module_: Rc<Module>)
1388-
-> Rc<Module> {
1385+
fn get_nearest_normal_module_parent_or_self(&mut self, module_: Rc<Module>) -> Rc<Module> {
13891386
match module_.kind.get() {
13901387
NormalModuleKind => return module_,
13911388
TraitModuleKind |
@@ -1406,7 +1403,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14061403
fn resolve_module_prefix(&mut self,
14071404
module_: Rc<Module>,
14081405
module_path: &[Name])
1409-
-> ResolveResult<ModulePrefixResult> {
1406+
-> ResolveResult<ModulePrefixResult> {
14101407
// Start at the current module if we see `self` or `super`, or at the
14111408
// top of the crate otherwise.
14121409
let mut containing_module;
@@ -1599,8 +1596,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15991596
// generate a fake "implementation scope" containing all the
16001597
// implementations thus found, for compatibility with old resolve pass.
16011598

1602-
fn with_scope<F>(&mut self, name: Option<Name>, f: F) where
1603-
F: FnOnce(&mut Resolver),
1599+
fn with_scope<F>(&mut self, name: Option<Name>, f: F)
1600+
where F: FnOnce(&mut Resolver)
16041601
{
16051602
let orig_module = self.current_module.clone();
16061603

@@ -1642,11 +1639,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
16421639

16431640
/// Wraps the given definition in the appropriate number of `DefUpvar`
16441641
/// wrappers.
1645-
fn upvarify(&self,
1646-
ribs: &[Rib],
1647-
def_like: DefLike,
1648-
span: Span)
1649-
-> Option<DefLike> {
1642+
fn upvarify(&self, ribs: &[Rib], def_like: DefLike, span: Span) -> Option<DefLike> {
16501643
let mut def = match def_like {
16511644
DlDef(def) => def,
16521645
_ => return Some(def_like)
@@ -1733,11 +1726,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17331726

17341727
/// Searches the current set of local scopes and
17351728
/// applies translations for closures.
1736-
fn search_ribs(&self,
1737-
ribs: &[Rib],
1738-
name: Name,
1739-
span: Span)
1740-
-> Option<DefLike> {
1729+
fn search_ribs(&self, ribs: &[Rib], name: Name, span: Span) -> Option<DefLike> {
17411730
// FIXME #4950: Try caching?
17421731

17431732
for (i, rib) in ribs.iter().enumerate().rev() {
@@ -1906,8 +1895,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19061895
}
19071896
}
19081897

1909-
fn with_type_parameter_rib<F>(&mut self, type_parameters: TypeParameters, f: F) where
1910-
F: FnOnce(&mut Resolver),
1898+
fn with_type_parameter_rib<F>(&mut self, type_parameters: TypeParameters, f: F)
1899+
where F: FnOnce(&mut Resolver)
19111900
{
19121901
match type_parameters {
19131902
HasTypeParameters(generics, space, rib_kind) => {
@@ -1950,16 +1939,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19501939
}
19511940
}
19521941

1953-
fn with_label_rib<F>(&mut self, f: F) where
1954-
F: FnOnce(&mut Resolver),
1942+
fn with_label_rib<F>(&mut self, f: F)
1943+
where F: FnOnce(&mut Resolver)
19551944
{
19561945
self.label_ribs.push(Rib::new(NormalRibKind));
19571946
f(self);
19581947
self.label_ribs.pop();
19591948
}
19601949

1961-
fn with_constant_rib<F>(&mut self, f: F) where
1962-
F: FnOnce(&mut Resolver),
1950+
fn with_constant_rib<F>(&mut self, f: F)
1951+
where F: FnOnce(&mut Resolver)
19631952
{
19641953
self.value_ribs.push(Rib::new(ConstantItemRibKind));
19651954
self.type_ribs.push(Rib::new(ConstantItemRibKind));
@@ -1968,10 +1957,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19681957
self.value_ribs.pop();
19691958
}
19701959

1971-
fn resolve_function(&mut self,
1972-
rib_kind: RibKind,
1973-
declaration: &FnDecl,
1974-
block: &Block) {
1960+
fn resolve_function(&mut self, rib_kind: RibKind, declaration: &FnDecl, block: &Block) {
19751961
// Create a value rib for the function.
19761962
self.value_ribs.push(Rib::new(rib_kind));
19771963

@@ -2060,10 +2046,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
20602046
result
20612047
}
20622048

2063-
fn with_optional_trait_ref<T, F>(&mut self,
2064-
opt_trait_ref: Option<&TraitRef>,
2065-
f: F)
2066-
-> T
2049+
fn with_optional_trait_ref<T, F>(&mut self, opt_trait_ref: Option<&TraitRef>, f: F) -> T
20672050
where F: FnOnce(&mut Resolver, Option<DefId>) -> T
20682051
{
20692052
let mut new_val = None;
@@ -2194,7 +2177,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
21942177
// user and one 'x' came from the macro.
21952178
fn binding_mode_map(&mut self, pat: &Pat) -> BindingMap {
21962179
let mut result = HashMap::new();
2197-
pat_bindings(&self.def_map, pat, |binding_mode, _id, sp, path1| {
2180+
pat_bindings(&self.def_map,
2181+
pat,
2182+
|binding_mode, _id, sp, path1| {
21982183
let name = mtwt::resolve(path1.node);
21992184
result.insert(name, BindingInfo {
22002185
span: sp,
@@ -2371,7 +2356,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
23712356
// pattern that binds them
23722357
bindings_list: &mut HashMap<Name, NodeId>) {
23732358
let pat_id = pattern.id;
2374-
walk_pat(pattern, |pattern| {
2359+
walk_pat(pattern,
2360+
|pattern| {
23752361
match pattern.node {
23762362
PatIdent(binding_mode, ref path1, _) => {
23772363

@@ -2609,7 +2595,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
26092595
});
26102596
}
26112597

2612-
fn resolve_bare_identifier_pattern(&mut self, name: Name, span: Span)
2598+
fn resolve_bare_identifier_pattern(&mut self,
2599+
name: Name,
2600+
span: Span)
26132601
-> BareIdentifierPatternResolution {
26142602
let module = self.current_module.clone();
26152603
match self.resolve_item_in_lexical_scope(module,
@@ -2677,8 +2665,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
26772665
path: &Path,
26782666
namespace: Namespace,
26792667
check_ribs: bool)
2680-
-> AssocItemResolveResult
2681-
{
2668+
-> AssocItemResolveResult {
26822669
match maybe_qself {
26832670
Some(&ast::QSelf { position: 0, .. }) =>
26842671
return TypecheckRequired,
@@ -2720,7 +2707,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
27202707
path: &Path,
27212708
path_depth: usize,
27222709
namespace: Namespace,
2723-
check_ribs: bool) -> Option<PathResolution> {
2710+
check_ribs: bool)
2711+
-> Option<PathResolution> {
27242712
let span = path.span;
27252713
let segments = &path.segments[..path.segments.len()-path_depth];
27262714

@@ -2919,7 +2907,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
29192907
span: Span,
29202908
segments: &[ast::PathSegment],
29212909
namespace: Namespace)
2922-
-> Option<(Def, LastPrivate)> {
2910+
-> Option<(Def, LastPrivate)> {
29232911
let module_path = segments.init().iter()
29242912
.map(|ps| ps.identifier.name)
29252913
.collect::<Vec<_>>();
@@ -3006,7 +2994,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30062994
fn resolve_item_by_name_in_lexical_scope(&mut self,
30072995
name: Name,
30082996
namespace: Namespace)
3009-
-> Option<(Def, LastPrivate)> {
2997+
-> Option<(Def, LastPrivate)> {
30102998
// Check the items.
30112999
let module = self.current_module.clone();
30123000
match self.resolve_item_in_lexical_scope(module,
@@ -3049,8 +3037,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30493037
}
30503038
}
30513039

3052-
fn with_no_errors<T, F>(&mut self, f: F) -> T where
3053-
F: FnOnce(&mut Resolver) -> T,
3040+
fn with_no_errors<T, F>(&mut self, f: F) -> T
3041+
where F: FnOnce(&mut Resolver) -> T
30543042
{
30553043
self.emit_errors = false;
30563044
let rs = f(self);
@@ -3065,8 +3053,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30653053
}
30663054

30673055
fn find_fallback_in_self_type(&mut self, name: Name) -> FallbackSuggestion {
3068-
fn extract_path_and_node_id(t: &Ty, allow: FallbackChecks)
3069-
-> Option<(Path, NodeId, FallbackChecks)> {
3056+
fn extract_path_and_node_id(t: &Ty,
3057+
allow: FallbackChecks)
3058+
-> Option<(Path, NodeId, FallbackChecks)> {
30703059
match t.node {
30713060
TyPath(None, ref path) => Some((path.clone(), t.id, allow)),
30723061
TyPtr(ref mut_ty) => extract_path_and_node_id(&*mut_ty.ty, OnlyTraitAndStatics),
@@ -3078,8 +3067,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30783067
}
30793068
}
30803069

3081-
fn get_module(this: &mut Resolver, span: Span, name_path: &[ast::Name])
3082-
-> Option<Rc<Module>> {
3070+
fn get_module(this: &mut Resolver,
3071+
span: Span,
3072+
name_path: &[ast::Name])
3073+
-> Option<Rc<Module>> {
30833074
let root = this.current_module.clone();
30843075
let last_name = name_path.last().unwrap();
30853076

@@ -3181,8 +3172,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
31813172
NoSuggestion
31823173
}
31833174

3184-
fn find_best_match_for_name(&mut self, name: &str, max_distance: usize)
3185-
-> Option<String> {
3175+
fn find_best_match_for_name(&mut self, name: &str, max_distance: usize) -> Option<String> {
31863176
let this = &mut *self;
31873177

31883178
let mut maybes: Vec<token::InternedString> = Vec::new();
@@ -3450,9 +3440,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
34503440
debug!("(getting traits containing item) looking for '{}'",
34513441
token::get_name(name));
34523442

3453-
fn add_trait_info(found_traits: &mut Vec<DefId>,
3454-
trait_def_id: DefId,
3455-
name: Name) {
3443+
fn add_trait_info(found_traits: &mut Vec<DefId>, trait_def_id: DefId, name: Name) {
34563444
debug!("(adding trait info) found trait {}:{} for method '{}'",
34573445
trait_def_id.krate,
34583446
trait_def_id.node,
@@ -3539,9 +3527,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
35393527
}
35403528

35413529
fn enforce_default_binding_mode(&mut self,
3542-
pat: &Pat,
3543-
pat_binding_mode: BindingMode,
3544-
descr: &str) {
3530+
pat: &Pat,
3531+
pat_binding_mode: BindingMode,
3532+
descr: &str) {
35453533
match pat_binding_mode {
35463534
BindByValue(_) => {}
35473535
BindByRef(..) => {

0 commit comments

Comments
 (0)