Skip to content

Commit aa1f9e8

Browse files
committed
Formatting librustc_resolve
1 parent 99a672a commit aa1f9e8

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
@@ -26,9 +26,13 @@
2626
#![feature(rustc_private)]
2727
#![feature(staged_api)]
2828

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

3337
extern crate rustc;
3438

@@ -69,7 +73,8 @@ use syntax::ast::{ExprLoop, ExprWhile, ExprMethodCall};
6973
use syntax::ast::{ExprPath, ExprStruct, FnDecl};
7074
use syntax::ast::{ForeignItemFn, ForeignItemStatic, Generics};
7175
use syntax::ast::{Ident, ImplItem, Item, ItemConst, ItemEnum, ItemExternCrate};
72-
use syntax::ast::{ItemFn, ItemForeignMod, ItemImpl, ItemMac, ItemMod, ItemStatic, ItemDefaultImpl};
76+
use syntax::ast::{ItemFn, ItemForeignMod, ItemImpl, ItemMac, ItemMod,
77+
ItemStatic, ItemDefaultImpl};
7378
use syntax::ast::{ItemStruct, ItemTrait, ItemTy, ItemUse};
7479
use syntax::ast::{Local, MethodImplItem, Name, NodeId};
7580
use syntax::ast::{Pat, PatEnum, PatIdent, PatLit, PatQPath};
@@ -195,9 +200,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
195200
fn visit_generics(&mut self, generics: &Generics) {
196201
self.resolve_generics(generics);
197202
}
198-
fn visit_poly_trait_ref(&mut self,
199-
tref: &ast::PolyTraitRef,
200-
m: &ast::TraitBoundModifier) {
203+
fn visit_poly_trait_ref(&mut self, tref: &ast::PolyTraitRef, m: &ast::TraitBoundModifier) {
201204
match self.resolve_trait_reference(tref.trait_ref.ref_id, &tref.trait_ref.path, 0) {
202205
Ok(def) => self.record_def(tref.trait_ref.ref_id, def),
203206
Err(_) => { /* error already reported */ }
@@ -530,11 +533,7 @@ impl NameBindings {
530533
} else {
531534
DefModifiers::empty()
532535
} | DefModifiers::IMPORTABLE;
533-
let module_ = Rc::new(Module::new(parent_link,
534-
def_id,
535-
kind,
536-
external,
537-
is_public));
536+
let module_ = Rc::new(Module::new(parent_link, def_id, kind, external, is_public));
538537
let type_def = self.type_def.borrow().clone();
539538
match type_def {
540539
None => {
@@ -852,7 +851,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
852851
fn new(session: &'a Session,
853852
ast_map: &'a ast_map::Map<'tcx>,
854853
crate_span: Span,
855-
make_glob_map: MakeGlobMap) -> Resolver<'a, 'tcx> {
854+
make_glob_map: MakeGlobMap)
855+
-> Resolver<'a, 'tcx> {
856856
let graph_root = NameBindings::new();
857857

858858
graph_root.define_module(NoParentLink,
@@ -975,9 +975,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
975975
span: Span,
976976
name_search_type: NameSearchType,
977977
lp: LastPrivate)
978-
-> ResolveResult<(Rc<Module>, LastPrivate)> {
979-
fn search_parent_externals(needle: Name, module: &Rc<Module>)
980-
-> Option<Rc<Module>> {
978+
-> ResolveResult<(Rc<Module>, LastPrivate)> {
979+
fn search_parent_externals(needle: Name, module: &Rc<Module>) -> Option<Rc<Module>> {
981980
match module.external_module_children.borrow().get(&needle) {
982981
Some(_) => Some(module.clone()),
983982
None => match module.parent_link {
@@ -1198,7 +1197,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
11981197
module_: Rc<Module>,
11991198
name: Name,
12001199
namespace: Namespace)
1201-
-> ResolveResult<(Target, bool)> {
1200+
-> ResolveResult<(Target, bool)> {
12021201
debug!("(resolving item in lexical scope) resolving `{}` in \
12031202
namespace {:?} in `{}`",
12041203
token::get_name(name),
@@ -1329,7 +1328,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13291328
fn resolve_module_in_lexical_scope(&mut self,
13301329
module_: Rc<Module>,
13311330
name: Name)
1332-
-> ResolveResult<Rc<Module>> {
1331+
-> ResolveResult<Rc<Module>> {
13331332
// If this module is an anonymous module, resolve the item in the
13341333
// lexical scope. Otherwise, resolve the item from the crate root.
13351334
let resolve_result = self.resolve_item_in_lexical_scope(module_, name, TypeNS);
@@ -1370,8 +1369,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13701369
}
13711370

13721371
/// Returns the nearest normal module parent of the given module.
1373-
fn get_nearest_normal_module_parent(&mut self, module_: Rc<Module>)
1374-
-> Option<Rc<Module>> {
1372+
fn get_nearest_normal_module_parent(&mut self, module_: Rc<Module>) -> Option<Rc<Module>> {
13751373
let mut module_ = module_;
13761374
loop {
13771375
match module_.parent_link.clone() {
@@ -1393,8 +1391,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13931391

13941392
/// Returns the nearest normal module parent of the given module, or the
13951393
/// module itself if it is a normal module.
1396-
fn get_nearest_normal_module_parent_or_self(&mut self, module_: Rc<Module>)
1397-
-> Rc<Module> {
1394+
fn get_nearest_normal_module_parent_or_self(&mut self, module_: Rc<Module>) -> Rc<Module> {
13981395
match module_.kind.get() {
13991396
NormalModuleKind => return module_,
14001397
TraitModuleKind |
@@ -1415,7 +1412,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14151412
fn resolve_module_prefix(&mut self,
14161413
module_: Rc<Module>,
14171414
module_path: &[Name])
1418-
-> ResolveResult<ModulePrefixResult> {
1415+
-> ResolveResult<ModulePrefixResult> {
14191416
// Start at the current module if we see `self` or `super`, or at the
14201417
// top of the crate otherwise.
14211418
let mut containing_module;
@@ -1608,8 +1605,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
16081605
// generate a fake "implementation scope" containing all the
16091606
// implementations thus found, for compatibility with old resolve pass.
16101607

1611-
fn with_scope<F>(&mut self, name: Option<Name>, f: F) where
1612-
F: FnOnce(&mut Resolver),
1608+
fn with_scope<F>(&mut self, name: Option<Name>, f: F)
1609+
where F: FnOnce(&mut Resolver)
16131610
{
16141611
let orig_module = self.current_module.clone();
16151612

@@ -1651,11 +1648,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
16511648

16521649
/// Wraps the given definition in the appropriate number of `DefUpvar`
16531650
/// wrappers.
1654-
fn upvarify(&self,
1655-
ribs: &[Rib],
1656-
def_like: DefLike,
1657-
span: Span)
1658-
-> Option<DefLike> {
1651+
fn upvarify(&self, ribs: &[Rib], def_like: DefLike, span: Span) -> Option<DefLike> {
16591652
let mut def = match def_like {
16601653
DlDef(def) => def,
16611654
_ => return Some(def_like)
@@ -1742,11 +1735,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17421735

17431736
/// Searches the current set of local scopes and
17441737
/// applies translations for closures.
1745-
fn search_ribs(&self,
1746-
ribs: &[Rib],
1747-
name: Name,
1748-
span: Span)
1749-
-> Option<DefLike> {
1738+
fn search_ribs(&self, ribs: &[Rib], name: Name, span: Span) -> Option<DefLike> {
17501739
// FIXME #4950: Try caching?
17511740

17521741
for (i, rib) in ribs.iter().enumerate().rev() {
@@ -1915,8 +1904,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19151904
}
19161905
}
19171906

1918-
fn with_type_parameter_rib<F>(&mut self, type_parameters: TypeParameters, f: F) where
1919-
F: FnOnce(&mut Resolver),
1907+
fn with_type_parameter_rib<F>(&mut self, type_parameters: TypeParameters, f: F)
1908+
where F: FnOnce(&mut Resolver)
19201909
{
19211910
match type_parameters {
19221911
HasTypeParameters(generics, space, rib_kind) => {
@@ -1959,16 +1948,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19591948
}
19601949
}
19611950

1962-
fn with_label_rib<F>(&mut self, f: F) where
1963-
F: FnOnce(&mut Resolver),
1951+
fn with_label_rib<F>(&mut self, f: F)
1952+
where F: FnOnce(&mut Resolver)
19641953
{
19651954
self.label_ribs.push(Rib::new(NormalRibKind));
19661955
f(self);
19671956
self.label_ribs.pop();
19681957
}
19691958

1970-
fn with_constant_rib<F>(&mut self, f: F) where
1971-
F: FnOnce(&mut Resolver),
1959+
fn with_constant_rib<F>(&mut self, f: F)
1960+
where F: FnOnce(&mut Resolver)
19721961
{
19731962
self.value_ribs.push(Rib::new(ConstantItemRibKind));
19741963
self.type_ribs.push(Rib::new(ConstantItemRibKind));
@@ -1977,10 +1966,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
19771966
self.value_ribs.pop();
19781967
}
19791968

1980-
fn resolve_function(&mut self,
1981-
rib_kind: RibKind,
1982-
declaration: &FnDecl,
1983-
block: &Block) {
1969+
fn resolve_function(&mut self, rib_kind: RibKind, declaration: &FnDecl, block: &Block) {
19841970
// Create a value rib for the function.
19851971
self.value_ribs.push(Rib::new(rib_kind));
19861972

@@ -2069,10 +2055,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
20692055
result
20702056
}
20712057

2072-
fn with_optional_trait_ref<T, F>(&mut self,
2073-
opt_trait_ref: Option<&TraitRef>,
2074-
f: F)
2075-
-> T
2058+
fn with_optional_trait_ref<T, F>(&mut self, opt_trait_ref: Option<&TraitRef>, f: F) -> T
20762059
where F: FnOnce(&mut Resolver, Option<DefId>) -> T
20772060
{
20782061
let mut new_val = None;
@@ -2203,7 +2186,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
22032186
// user and one 'x' came from the macro.
22042187
fn binding_mode_map(&mut self, pat: &Pat) -> BindingMap {
22052188
let mut result = HashMap::new();
2206-
pat_bindings(&self.def_map, pat, |binding_mode, _id, sp, path1| {
2189+
pat_bindings(&self.def_map,
2190+
pat,
2191+
|binding_mode, _id, sp, path1| {
22072192
let name = mtwt::resolve(path1.node);
22082193
result.insert(name, BindingInfo {
22092194
span: sp,
@@ -2380,7 +2365,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
23802365
// pattern that binds them
23812366
bindings_list: &mut HashMap<Name, NodeId>) {
23822367
let pat_id = pattern.id;
2383-
walk_pat(pattern, |pattern| {
2368+
walk_pat(pattern,
2369+
|pattern| {
23842370
match pattern.node {
23852371
PatIdent(binding_mode, ref path1, _) => {
23862372

@@ -2618,7 +2604,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
26182604
});
26192605
}
26202606

2621-
fn resolve_bare_identifier_pattern(&mut self, name: Name, span: Span)
2607+
fn resolve_bare_identifier_pattern(&mut self,
2608+
name: Name,
2609+
span: Span)
26222610
-> BareIdentifierPatternResolution {
26232611
let module = self.current_module.clone();
26242612
match self.resolve_item_in_lexical_scope(module,
@@ -2686,8 +2674,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
26862674
path: &Path,
26872675
namespace: Namespace,
26882676
check_ribs: bool)
2689-
-> AssocItemResolveResult
2690-
{
2677+
-> AssocItemResolveResult {
26912678
match maybe_qself {
26922679
Some(&ast::QSelf { position: 0, .. }) =>
26932680
return TypecheckRequired,
@@ -2729,7 +2716,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
27292716
path: &Path,
27302717
path_depth: usize,
27312718
namespace: Namespace,
2732-
check_ribs: bool) -> Option<PathResolution> {
2719+
check_ribs: bool)
2720+
-> Option<PathResolution> {
27332721
let span = path.span;
27342722
let segments = &path.segments[..path.segments.len()-path_depth];
27352723

@@ -2928,7 +2916,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
29282916
span: Span,
29292917
segments: &[ast::PathSegment],
29302918
namespace: Namespace)
2931-
-> Option<(Def, LastPrivate)> {
2919+
-> Option<(Def, LastPrivate)> {
29322920
let module_path = segments.init().iter()
29332921
.map(|ps| ps.identifier.name)
29342922
.collect::<Vec<_>>();
@@ -3015,7 +3003,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30153003
fn resolve_item_by_name_in_lexical_scope(&mut self,
30163004
name: Name,
30173005
namespace: Namespace)
3018-
-> Option<(Def, LastPrivate)> {
3006+
-> Option<(Def, LastPrivate)> {
30193007
// Check the items.
30203008
let module = self.current_module.clone();
30213009
match self.resolve_item_in_lexical_scope(module,
@@ -3058,8 +3046,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30583046
}
30593047
}
30603048

3061-
fn with_no_errors<T, F>(&mut self, f: F) -> T where
3062-
F: FnOnce(&mut Resolver) -> T,
3049+
fn with_no_errors<T, F>(&mut self, f: F) -> T
3050+
where F: FnOnce(&mut Resolver) -> T
30633051
{
30643052
self.emit_errors = false;
30653053
let rs = f(self);
@@ -3074,8 +3062,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30743062
}
30753063

30763064
fn find_fallback_in_self_type(&mut self, name: Name) -> FallbackSuggestion {
3077-
fn extract_path_and_node_id(t: &Ty, allow: FallbackChecks)
3078-
-> Option<(Path, NodeId, FallbackChecks)> {
3065+
fn extract_path_and_node_id(t: &Ty,
3066+
allow: FallbackChecks)
3067+
-> Option<(Path, NodeId, FallbackChecks)> {
30793068
match t.node {
30803069
TyPath(None, ref path) => Some((path.clone(), t.id, allow)),
30813070
TyPtr(ref mut_ty) => extract_path_and_node_id(&*mut_ty.ty, OnlyTraitAndStatics),
@@ -3087,8 +3076,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30873076
}
30883077
}
30893078

3090-
fn get_module(this: &mut Resolver, span: Span, name_path: &[ast::Name])
3091-
-> Option<Rc<Module>> {
3079+
fn get_module(this: &mut Resolver,
3080+
span: Span,
3081+
name_path: &[ast::Name])
3082+
-> Option<Rc<Module>> {
30923083
let root = this.current_module.clone();
30933084
let last_name = name_path.last().unwrap();
30943085

@@ -3190,8 +3181,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
31903181
NoSuggestion
31913182
}
31923183

3193-
fn find_best_match_for_name(&mut self, name: &str, max_distance: usize)
3194-
-> Option<String> {
3184+
fn find_best_match_for_name(&mut self, name: &str, max_distance: usize) -> Option<String> {
31953185
let this = &mut *self;
31963186

31973187
let mut maybes: Vec<token::InternedString> = Vec::new();
@@ -3459,9 +3449,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
34593449
debug!("(getting traits containing item) looking for '{}'",
34603450
token::get_name(name));
34613451

3462-
fn add_trait_info(found_traits: &mut Vec<DefId>,
3463-
trait_def_id: DefId,
3464-
name: Name) {
3452+
fn add_trait_info(found_traits: &mut Vec<DefId>, trait_def_id: DefId, name: Name) {
34653453
debug!("(adding trait info) found trait {}:{} for method '{}'",
34663454
trait_def_id.krate,
34673455
trait_def_id.node,
@@ -3548,9 +3536,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
35483536
}
35493537

35503538
fn enforce_default_binding_mode(&mut self,
3551-
pat: &Pat,
3552-
pat_binding_mode: BindingMode,
3553-
descr: &str) {
3539+
pat: &Pat,
3540+
pat_binding_mode: BindingMode,
3541+
descr: &str) {
35543542
match pat_binding_mode {
35553543
BindByValue(_) => {}
35563544
BindByRef(..) => {

0 commit comments

Comments
 (0)