25
25
#![ feature( rustc_private) ]
26
26
#![ feature( staged_api) ]
27
27
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;
31
35
32
36
extern crate rustc;
33
37
@@ -68,7 +72,8 @@ use syntax::ast::{ExprLoop, ExprWhile, ExprMethodCall};
68
72
use syntax:: ast:: { ExprPath , ExprStruct , FnDecl } ;
69
73
use syntax:: ast:: { ForeignItemFn , ForeignItemStatic , Generics } ;
70
74
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 } ;
72
77
use syntax:: ast:: { ItemStruct , ItemTrait , ItemTy , ItemUse } ;
73
78
use syntax:: ast:: { Local , MethodImplItem , Name , NodeId } ;
74
79
use syntax:: ast:: { Pat , PatEnum , PatIdent , PatLit , PatQPath } ;
@@ -194,9 +199,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
194
199
fn visit_generics ( & mut self , generics : & Generics ) {
195
200
self . resolve_generics ( generics) ;
196
201
}
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 ) {
200
203
match self . resolve_trait_reference ( tref. trait_ref . ref_id , & tref. trait_ref . path , 0 ) {
201
204
Ok ( def) => self . record_def ( tref. trait_ref . ref_id , def) ,
202
205
Err ( _) => { /* error already reported */ }
@@ -525,11 +528,7 @@ impl NameBindings {
525
528
sp : Span ) {
526
529
// Merges the module with the existing type def or creates a new one.
527
530
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) ) ;
533
532
let type_def = self . type_def . borrow ( ) . clone ( ) ;
534
533
match type_def {
535
534
None => {
@@ -843,7 +842,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
843
842
fn new ( session : & ' a Session ,
844
843
ast_map : & ' a ast_map:: Map < ' tcx > ,
845
844
crate_span : Span ,
846
- make_glob_map : MakeGlobMap ) -> Resolver < ' a , ' tcx > {
845
+ make_glob_map : MakeGlobMap )
846
+ -> Resolver < ' a , ' tcx > {
847
847
let graph_root = NameBindings :: new ( ) ;
848
848
849
849
graph_root. define_module ( NoParentLink ,
@@ -966,9 +966,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
966
966
span : Span ,
967
967
name_search_type : NameSearchType ,
968
968
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 > > {
972
971
match module. external_module_children . borrow ( ) . get ( & needle) {
973
972
Some ( _) => Some ( module. clone ( ) ) ,
974
973
None => match module. parent_link {
@@ -1189,7 +1188,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1189
1188
module_ : Rc < Module > ,
1190
1189
name : Name ,
1191
1190
namespace : Namespace )
1192
- -> ResolveResult < ( Target , bool ) > {
1191
+ -> ResolveResult < ( Target , bool ) > {
1193
1192
debug ! ( "(resolving item in lexical scope) resolving `{}` in \
1194
1193
namespace {:?} in `{}`",
1195
1194
token:: get_name( name) ,
@@ -1320,7 +1319,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1320
1319
fn resolve_module_in_lexical_scope ( & mut self ,
1321
1320
module_ : Rc < Module > ,
1322
1321
name : Name )
1323
- -> ResolveResult < Rc < Module > > {
1322
+ -> ResolveResult < Rc < Module > > {
1324
1323
// If this module is an anonymous module, resolve the item in the
1325
1324
// lexical scope. Otherwise, resolve the item from the crate root.
1326
1325
let resolve_result = self . resolve_item_in_lexical_scope ( module_, name, TypeNS ) ;
@@ -1361,8 +1360,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1361
1360
}
1362
1361
1363
1362
/// 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 > > {
1366
1364
let mut module_ = module_;
1367
1365
loop {
1368
1366
match module_. parent_link . clone ( ) {
@@ -1384,8 +1382,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1384
1382
1385
1383
/// Returns the nearest normal module parent of the given module, or the
1386
1384
/// 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 > {
1389
1386
match module_. kind . get ( ) {
1390
1387
NormalModuleKind => return module_,
1391
1388
TraitModuleKind |
@@ -1406,7 +1403,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1406
1403
fn resolve_module_prefix ( & mut self ,
1407
1404
module_ : Rc < Module > ,
1408
1405
module_path : & [ Name ] )
1409
- -> ResolveResult < ModulePrefixResult > {
1406
+ -> ResolveResult < ModulePrefixResult > {
1410
1407
// Start at the current module if we see `self` or `super`, or at the
1411
1408
// top of the crate otherwise.
1412
1409
let mut containing_module;
@@ -1599,8 +1596,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1599
1596
// generate a fake "implementation scope" containing all the
1600
1597
// implementations thus found, for compatibility with old resolve pass.
1601
1598
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 )
1604
1601
{
1605
1602
let orig_module = self . current_module . clone ( ) ;
1606
1603
@@ -1642,11 +1639,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1642
1639
1643
1640
/// Wraps the given definition in the appropriate number of `DefUpvar`
1644
1641
/// 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 > {
1650
1643
let mut def = match def_like {
1651
1644
DlDef ( def) => def,
1652
1645
_ => return Some ( def_like)
@@ -1733,11 +1726,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1733
1726
1734
1727
/// Searches the current set of local scopes and
1735
1728
/// 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 > {
1741
1730
// FIXME #4950: Try caching?
1742
1731
1743
1732
for ( i, rib) in ribs. iter ( ) . enumerate ( ) . rev ( ) {
@@ -1906,8 +1895,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1906
1895
}
1907
1896
}
1908
1897
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 )
1911
1900
{
1912
1901
match type_parameters {
1913
1902
HasTypeParameters ( generics, space, rib_kind) => {
@@ -1950,16 +1939,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1950
1939
}
1951
1940
}
1952
1941
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 )
1955
1944
{
1956
1945
self . label_ribs . push ( Rib :: new ( NormalRibKind ) ) ;
1957
1946
f ( self ) ;
1958
1947
self . label_ribs . pop ( ) ;
1959
1948
}
1960
1949
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 )
1963
1952
{
1964
1953
self . value_ribs . push ( Rib :: new ( ConstantItemRibKind ) ) ;
1965
1954
self . type_ribs . push ( Rib :: new ( ConstantItemRibKind ) ) ;
@@ -1968,10 +1957,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1968
1957
self . value_ribs . pop ( ) ;
1969
1958
}
1970
1959
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 ) {
1975
1961
// Create a value rib for the function.
1976
1962
self . value_ribs . push ( Rib :: new ( rib_kind) ) ;
1977
1963
@@ -2060,10 +2046,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2060
2046
result
2061
2047
}
2062
2048
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
2067
2050
where F : FnOnce ( & mut Resolver , Option < DefId > ) -> T
2068
2051
{
2069
2052
let mut new_val = None ;
@@ -2194,7 +2177,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2194
2177
// user and one 'x' came from the macro.
2195
2178
fn binding_mode_map ( & mut self , pat : & Pat ) -> BindingMap {
2196
2179
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| {
2198
2183
let name = mtwt:: resolve ( path1. node ) ;
2199
2184
result. insert ( name, BindingInfo {
2200
2185
span : sp,
@@ -2371,7 +2356,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2371
2356
// pattern that binds them
2372
2357
bindings_list : & mut HashMap < Name , NodeId > ) {
2373
2358
let pat_id = pattern. id ;
2374
- walk_pat ( pattern, |pattern| {
2359
+ walk_pat ( pattern,
2360
+ |pattern| {
2375
2361
match pattern. node {
2376
2362
PatIdent ( binding_mode, ref path1, _) => {
2377
2363
@@ -2609,7 +2595,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2609
2595
} ) ;
2610
2596
}
2611
2597
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 )
2613
2601
-> BareIdentifierPatternResolution {
2614
2602
let module = self . current_module . clone ( ) ;
2615
2603
match self . resolve_item_in_lexical_scope ( module,
@@ -2677,8 +2665,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2677
2665
path : & Path ,
2678
2666
namespace : Namespace ,
2679
2667
check_ribs : bool )
2680
- -> AssocItemResolveResult
2681
- {
2668
+ -> AssocItemResolveResult {
2682
2669
match maybe_qself {
2683
2670
Some ( & ast:: QSelf { position : 0 , .. } ) =>
2684
2671
return TypecheckRequired ,
@@ -2720,7 +2707,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2720
2707
path : & Path ,
2721
2708
path_depth : usize ,
2722
2709
namespace : Namespace ,
2723
- check_ribs : bool ) -> Option < PathResolution > {
2710
+ check_ribs : bool )
2711
+ -> Option < PathResolution > {
2724
2712
let span = path. span ;
2725
2713
let segments = & path. segments [ ..path. segments . len ( ) -path_depth] ;
2726
2714
@@ -2919,7 +2907,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2919
2907
span : Span ,
2920
2908
segments : & [ ast:: PathSegment ] ,
2921
2909
namespace : Namespace )
2922
- -> Option < ( Def , LastPrivate ) > {
2910
+ -> Option < ( Def , LastPrivate ) > {
2923
2911
let module_path = segments. init ( ) . iter ( )
2924
2912
. map ( |ps| ps. identifier . name )
2925
2913
. collect :: < Vec < _ > > ( ) ;
@@ -3006,7 +2994,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3006
2994
fn resolve_item_by_name_in_lexical_scope ( & mut self ,
3007
2995
name : Name ,
3008
2996
namespace : Namespace )
3009
- -> Option < ( Def , LastPrivate ) > {
2997
+ -> Option < ( Def , LastPrivate ) > {
3010
2998
// Check the items.
3011
2999
let module = self . current_module . clone ( ) ;
3012
3000
match self . resolve_item_in_lexical_scope ( module,
@@ -3049,8 +3037,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3049
3037
}
3050
3038
}
3051
3039
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
3054
3042
{
3055
3043
self . emit_errors = false ;
3056
3044
let rs = f ( self ) ;
@@ -3065,8 +3053,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3065
3053
}
3066
3054
3067
3055
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 ) > {
3070
3059
match t. node {
3071
3060
TyPath ( None , ref path) => Some ( ( path. clone ( ) , t. id , allow) ) ,
3072
3061
TyPtr ( ref mut_ty) => extract_path_and_node_id ( & * mut_ty. ty , OnlyTraitAndStatics ) ,
@@ -3078,8 +3067,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3078
3067
}
3079
3068
}
3080
3069
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 > > {
3083
3074
let root = this. current_module . clone ( ) ;
3084
3075
let last_name = name_path. last ( ) . unwrap ( ) ;
3085
3076
@@ -3181,8 +3172,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3181
3172
NoSuggestion
3182
3173
}
3183
3174
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 > {
3186
3176
let this = & mut * self ;
3187
3177
3188
3178
let mut maybes: Vec < token:: InternedString > = Vec :: new ( ) ;
@@ -3450,9 +3440,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3450
3440
debug ! ( "(getting traits containing item) looking for '{}'" ,
3451
3441
token:: get_name( name) ) ;
3452
3442
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 ) {
3456
3444
debug ! ( "(adding trait info) found trait {}:{} for method '{}'" ,
3457
3445
trait_def_id. krate,
3458
3446
trait_def_id. node,
@@ -3539,9 +3527,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3539
3527
}
3540
3528
3541
3529
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 ) {
3545
3533
match pat_binding_mode {
3546
3534
BindByValue ( _) => { }
3547
3535
BindByRef ( ..) => {
0 commit comments