26
26
#![ feature( rustc_private) ]
27
27
#![ feature( staged_api) ]
28
28
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;
32
36
33
37
extern crate rustc;
34
38
@@ -69,7 +73,8 @@ use syntax::ast::{ExprLoop, ExprWhile, ExprMethodCall};
69
73
use syntax:: ast:: { ExprPath , ExprStruct , FnDecl } ;
70
74
use syntax:: ast:: { ForeignItemFn , ForeignItemStatic , Generics } ;
71
75
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 } ;
73
78
use syntax:: ast:: { ItemStruct , ItemTrait , ItemTy , ItemUse } ;
74
79
use syntax:: ast:: { Local , MethodImplItem , Name , NodeId } ;
75
80
use syntax:: ast:: { Pat , PatEnum , PatIdent , PatLit , PatQPath } ;
@@ -195,9 +200,7 @@ impl<'a, 'v, 'tcx> Visitor<'v> for Resolver<'a, 'tcx> {
195
200
fn visit_generics ( & mut self , generics : & Generics ) {
196
201
self . resolve_generics ( generics) ;
197
202
}
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 ) {
201
204
match self . resolve_trait_reference ( tref. trait_ref . ref_id , & tref. trait_ref . path , 0 ) {
202
205
Ok ( def) => self . record_def ( tref. trait_ref . ref_id , def) ,
203
206
Err ( _) => { /* error already reported */ }
@@ -530,11 +533,7 @@ impl NameBindings {
530
533
} else {
531
534
DefModifiers :: empty ( )
532
535
} | 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) ) ;
538
537
let type_def = self . type_def . borrow ( ) . clone ( ) ;
539
538
match type_def {
540
539
None => {
@@ -852,7 +851,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
852
851
fn new ( session : & ' a Session ,
853
852
ast_map : & ' a ast_map:: Map < ' tcx > ,
854
853
crate_span : Span ,
855
- make_glob_map : MakeGlobMap ) -> Resolver < ' a , ' tcx > {
854
+ make_glob_map : MakeGlobMap )
855
+ -> Resolver < ' a , ' tcx > {
856
856
let graph_root = NameBindings :: new ( ) ;
857
857
858
858
graph_root. define_module ( NoParentLink ,
@@ -975,9 +975,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
975
975
span : Span ,
976
976
name_search_type : NameSearchType ,
977
977
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 > > {
981
980
match module. external_module_children . borrow ( ) . get ( & needle) {
982
981
Some ( _) => Some ( module. clone ( ) ) ,
983
982
None => match module. parent_link {
@@ -1198,7 +1197,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1198
1197
module_ : Rc < Module > ,
1199
1198
name : Name ,
1200
1199
namespace : Namespace )
1201
- -> ResolveResult < ( Target , bool ) > {
1200
+ -> ResolveResult < ( Target , bool ) > {
1202
1201
debug ! ( "(resolving item in lexical scope) resolving `{}` in \
1203
1202
namespace {:?} in `{}`",
1204
1203
token:: get_name( name) ,
@@ -1329,7 +1328,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1329
1328
fn resolve_module_in_lexical_scope ( & mut self ,
1330
1329
module_ : Rc < Module > ,
1331
1330
name : Name )
1332
- -> ResolveResult < Rc < Module > > {
1331
+ -> ResolveResult < Rc < Module > > {
1333
1332
// If this module is an anonymous module, resolve the item in the
1334
1333
// lexical scope. Otherwise, resolve the item from the crate root.
1335
1334
let resolve_result = self . resolve_item_in_lexical_scope ( module_, name, TypeNS ) ;
@@ -1370,8 +1369,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1370
1369
}
1371
1370
1372
1371
/// 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 > > {
1375
1373
let mut module_ = module_;
1376
1374
loop {
1377
1375
match module_. parent_link . clone ( ) {
@@ -1393,8 +1391,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1393
1391
1394
1392
/// Returns the nearest normal module parent of the given module, or the
1395
1393
/// 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 > {
1398
1395
match module_. kind . get ( ) {
1399
1396
NormalModuleKind => return module_,
1400
1397
TraitModuleKind |
@@ -1415,7 +1412,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1415
1412
fn resolve_module_prefix ( & mut self ,
1416
1413
module_ : Rc < Module > ,
1417
1414
module_path : & [ Name ] )
1418
- -> ResolveResult < ModulePrefixResult > {
1415
+ -> ResolveResult < ModulePrefixResult > {
1419
1416
// Start at the current module if we see `self` or `super`, or at the
1420
1417
// top of the crate otherwise.
1421
1418
let mut containing_module;
@@ -1608,8 +1605,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1608
1605
// generate a fake "implementation scope" containing all the
1609
1606
// implementations thus found, for compatibility with old resolve pass.
1610
1607
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 )
1613
1610
{
1614
1611
let orig_module = self . current_module . clone ( ) ;
1615
1612
@@ -1651,11 +1648,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1651
1648
1652
1649
/// Wraps the given definition in the appropriate number of `DefUpvar`
1653
1650
/// 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 > {
1659
1652
let mut def = match def_like {
1660
1653
DlDef ( def) => def,
1661
1654
_ => return Some ( def_like)
@@ -1742,11 +1735,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1742
1735
1743
1736
/// Searches the current set of local scopes and
1744
1737
/// 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 > {
1750
1739
// FIXME #4950: Try caching?
1751
1740
1752
1741
for ( i, rib) in ribs. iter ( ) . enumerate ( ) . rev ( ) {
@@ -1915,8 +1904,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1915
1904
}
1916
1905
}
1917
1906
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 )
1920
1909
{
1921
1910
match type_parameters {
1922
1911
HasTypeParameters ( generics, space, rib_kind) => {
@@ -1959,16 +1948,16 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1959
1948
}
1960
1949
}
1961
1950
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 )
1964
1953
{
1965
1954
self . label_ribs . push ( Rib :: new ( NormalRibKind ) ) ;
1966
1955
f ( self ) ;
1967
1956
self . label_ribs . pop ( ) ;
1968
1957
}
1969
1958
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 )
1972
1961
{
1973
1962
self . value_ribs . push ( Rib :: new ( ConstantItemRibKind ) ) ;
1974
1963
self . type_ribs . push ( Rib :: new ( ConstantItemRibKind ) ) ;
@@ -1977,10 +1966,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1977
1966
self . value_ribs . pop ( ) ;
1978
1967
}
1979
1968
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 ) {
1984
1970
// Create a value rib for the function.
1985
1971
self . value_ribs . push ( Rib :: new ( rib_kind) ) ;
1986
1972
@@ -2069,10 +2055,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2069
2055
result
2070
2056
}
2071
2057
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
2076
2059
where F : FnOnce ( & mut Resolver , Option < DefId > ) -> T
2077
2060
{
2078
2061
let mut new_val = None ;
@@ -2203,7 +2186,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2203
2186
// user and one 'x' came from the macro.
2204
2187
fn binding_mode_map ( & mut self , pat : & Pat ) -> BindingMap {
2205
2188
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| {
2207
2192
let name = mtwt:: resolve ( path1. node ) ;
2208
2193
result. insert ( name, BindingInfo {
2209
2194
span : sp,
@@ -2380,7 +2365,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2380
2365
// pattern that binds them
2381
2366
bindings_list : & mut HashMap < Name , NodeId > ) {
2382
2367
let pat_id = pattern. id ;
2383
- walk_pat ( pattern, |pattern| {
2368
+ walk_pat ( pattern,
2369
+ |pattern| {
2384
2370
match pattern. node {
2385
2371
PatIdent ( binding_mode, ref path1, _) => {
2386
2372
@@ -2618,7 +2604,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2618
2604
} ) ;
2619
2605
}
2620
2606
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 )
2622
2610
-> BareIdentifierPatternResolution {
2623
2611
let module = self . current_module . clone ( ) ;
2624
2612
match self . resolve_item_in_lexical_scope ( module,
@@ -2686,8 +2674,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2686
2674
path : & Path ,
2687
2675
namespace : Namespace ,
2688
2676
check_ribs : bool )
2689
- -> AssocItemResolveResult
2690
- {
2677
+ -> AssocItemResolveResult {
2691
2678
match maybe_qself {
2692
2679
Some ( & ast:: QSelf { position : 0 , .. } ) =>
2693
2680
return TypecheckRequired ,
@@ -2729,7 +2716,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2729
2716
path : & Path ,
2730
2717
path_depth : usize ,
2731
2718
namespace : Namespace ,
2732
- check_ribs : bool ) -> Option < PathResolution > {
2719
+ check_ribs : bool )
2720
+ -> Option < PathResolution > {
2733
2721
let span = path. span ;
2734
2722
let segments = & path. segments [ ..path. segments . len ( ) -path_depth] ;
2735
2723
@@ -2928,7 +2916,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2928
2916
span : Span ,
2929
2917
segments : & [ ast:: PathSegment ] ,
2930
2918
namespace : Namespace )
2931
- -> Option < ( Def , LastPrivate ) > {
2919
+ -> Option < ( Def , LastPrivate ) > {
2932
2920
let module_path = segments. init ( ) . iter ( )
2933
2921
. map ( |ps| ps. identifier . name )
2934
2922
. collect :: < Vec < _ > > ( ) ;
@@ -3015,7 +3003,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3015
3003
fn resolve_item_by_name_in_lexical_scope ( & mut self ,
3016
3004
name : Name ,
3017
3005
namespace : Namespace )
3018
- -> Option < ( Def , LastPrivate ) > {
3006
+ -> Option < ( Def , LastPrivate ) > {
3019
3007
// Check the items.
3020
3008
let module = self . current_module . clone ( ) ;
3021
3009
match self . resolve_item_in_lexical_scope ( module,
@@ -3058,8 +3046,8 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3058
3046
}
3059
3047
}
3060
3048
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
3063
3051
{
3064
3052
self . emit_errors = false ;
3065
3053
let rs = f ( self ) ;
@@ -3074,8 +3062,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3074
3062
}
3075
3063
3076
3064
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 ) > {
3079
3068
match t. node {
3080
3069
TyPath ( None , ref path) => Some ( ( path. clone ( ) , t. id , allow) ) ,
3081
3070
TyPtr ( ref mut_ty) => extract_path_and_node_id ( & * mut_ty. ty , OnlyTraitAndStatics ) ,
@@ -3087,8 +3076,10 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3087
3076
}
3088
3077
}
3089
3078
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 > > {
3092
3083
let root = this. current_module . clone ( ) ;
3093
3084
let last_name = name_path. last ( ) . unwrap ( ) ;
3094
3085
@@ -3190,8 +3181,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3190
3181
NoSuggestion
3191
3182
}
3192
3183
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 > {
3195
3185
let this = & mut * self ;
3196
3186
3197
3187
let mut maybes: Vec < token:: InternedString > = Vec :: new ( ) ;
@@ -3459,9 +3449,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3459
3449
debug ! ( "(getting traits containing item) looking for '{}'" ,
3460
3450
token:: get_name( name) ) ;
3461
3451
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 ) {
3465
3453
debug ! ( "(adding trait info) found trait {}:{} for method '{}'" ,
3466
3454
trait_def_id. krate,
3467
3455
trait_def_id. node,
@@ -3548,9 +3536,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3548
3536
}
3549
3537
3550
3538
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 ) {
3554
3542
match pat_binding_mode {
3555
3543
BindByValue ( _) => { }
3556
3544
BindByRef ( ..) => {
0 commit comments