@@ -44,7 +44,6 @@ use self::RibKind::*;
44
44
use self :: UseLexicalScopeFlag :: * ;
45
45
use self :: ModulePrefixResult :: * ;
46
46
use self :: AssocItemResolveResult :: * ;
47
- use self :: NameSearchType :: * ;
48
47
use self :: BareIdentifierPatternResolution :: * ;
49
48
use self :: ParentLink :: * ;
50
49
use self :: FallbackChecks :: * ;
@@ -784,16 +783,6 @@ enum AssocItemResolveResult {
784
783
ResolveAttempt ( Option < PathResolution > ) ,
785
784
}
786
785
787
- #[ derive( Copy , Clone , PartialEq ) ]
788
- enum NameSearchType {
789
- /// We're doing a name search in order to resolve a `use` directive.
790
- ImportSearch ,
791
-
792
- /// We're doing a name search in order to resolve a path type, a path
793
- /// expression, or a path pattern.
794
- PathSearch ,
795
- }
796
-
797
786
#[ derive( Copy , Clone ) ]
798
787
enum BareIdentifierPatternResolution {
799
788
FoundStructOrEnumVariant ( Def , LastPrivate ) ,
@@ -1370,7 +1359,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1370
1359
module_path : & [ Name ] ,
1371
1360
index : usize ,
1372
1361
span : Span ,
1373
- name_search_type : NameSearchType ,
1374
1362
lp : LastPrivate )
1375
1363
-> ResolveResult < ( Module < ' a > , LastPrivate ) > {
1376
1364
fn search_parent_externals < ' a > ( needle : Name , module : Module < ' a > )
@@ -1396,11 +1384,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1396
1384
// modules as we go.
1397
1385
while index < module_path_len {
1398
1386
let name = module_path[ index] ;
1399
- match self . resolve_name_in_module ( search_module,
1400
- name,
1401
- TypeNS ,
1402
- name_search_type,
1403
- false ) {
1387
+ match self . resolve_name_in_module ( search_module, name, TypeNS , false ) {
1404
1388
Failed ( None ) => {
1405
1389
let segment_name = name. as_str ( ) ;
1406
1390
let module_name = module_to_string ( search_module) ;
@@ -1477,8 +1461,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1477
1461
module_ : Module < ' a > ,
1478
1462
module_path : & [ Name ] ,
1479
1463
use_lexical_scope : UseLexicalScopeFlag ,
1480
- span : Span ,
1481
- name_search_type : NameSearchType )
1464
+ span : Span )
1482
1465
-> ResolveResult < ( Module < ' a > , LastPrivate ) > {
1483
1466
let module_path_len = module_path. len ( ) ;
1484
1467
assert ! ( module_path_len > 0 ) ;
@@ -1559,7 +1542,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1559
1542
module_path,
1560
1543
start_index,
1561
1544
span,
1562
- name_search_type,
1563
1545
last_private)
1564
1546
}
1565
1547
@@ -1658,11 +1640,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1658
1640
}
1659
1641
1660
1642
// Resolve the name in the parent module.
1661
- match self . resolve_name_in_module ( search_module,
1662
- name,
1663
- namespace,
1664
- PathSearch ,
1665
- true ) {
1643
+ match self . resolve_name_in_module ( search_module, name, namespace, true ) {
1666
1644
Failed ( Some ( ( span, msg) ) ) => {
1667
1645
resolve_error ( self , span, ResolutionError :: FailedToResolve ( & * msg) ) ;
1668
1646
}
@@ -1787,7 +1765,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1787
1765
module_ : Module < ' a > ,
1788
1766
name : Name ,
1789
1767
namespace : Namespace ,
1790
- name_search_type : NameSearchType ,
1791
1768
allow_private_imports : bool )
1792
1769
-> ResolveResult < ( Target < ' a > , bool ) > {
1793
1770
debug ! ( "(resolving name in module) resolving `{}` in `{}`" ,
@@ -1811,14 +1788,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
1811
1788
}
1812
1789
}
1813
1790
1814
- // Next, check the module's imports if necessary.
1815
-
1816
- // If this is a search of all imports, we should be done with glob
1817
- // resolution at this point.
1818
- if name_search_type == PathSearch {
1819
- assert_eq ! ( module_. glob_count. get( ) , 0 ) ;
1820
- }
1821
-
1822
1791
// Check the list of resolved imports.
1823
1792
let children = module_. import_resolutions . borrow ( ) ;
1824
1793
match children. get ( & name) {
@@ -2912,9 +2881,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
2912
2881
}
2913
2882
}
2914
2883
2915
- Indeterminate => {
2916
- panic ! ( "unexpected indeterminate result" ) ;
2917
- }
2884
+ Indeterminate => return BareIdentifierPatternUnresolved ,
2918
2885
Failed ( err) => {
2919
2886
match err {
2920
2887
Some ( ( span, msg) ) => {
@@ -3154,11 +3121,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3154
3121
let containing_module;
3155
3122
let last_private;
3156
3123
let current_module = self . current_module ;
3157
- match self . resolve_module_path ( current_module,
3158
- & module_path[ ..] ,
3159
- UseLexicalScope ,
3160
- span,
3161
- PathSearch ) {
3124
+ match self . resolve_module_path ( current_module, & module_path, UseLexicalScope , span) {
3162
3125
Failed ( err) => {
3163
3126
let ( span, msg) = match err {
3164
3127
Some ( ( span, msg) ) => ( span, msg) ,
@@ -3172,19 +3135,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3172
3135
resolve_error ( self , span, ResolutionError :: FailedToResolve ( & * msg) ) ;
3173
3136
return None ;
3174
3137
}
3175
- Indeterminate => panic ! ( "indeterminate unexpected" ) ,
3138
+ Indeterminate => return None ,
3176
3139
Success ( ( resulting_module, resulting_last_private) ) => {
3177
3140
containing_module = resulting_module;
3178
3141
last_private = resulting_last_private;
3179
3142
}
3180
3143
}
3181
3144
3182
3145
let name = segments. last ( ) . unwrap ( ) . identifier . name ;
3183
- let def = match self . resolve_name_in_module ( containing_module,
3184
- name,
3185
- namespace,
3186
- NameSearchType :: PathSearch ,
3187
- false ) {
3146
+ let def = match self . resolve_name_in_module ( containing_module, name, namespace, false ) {
3188
3147
Success ( ( Target { binding, .. } , _) ) => {
3189
3148
let ( def, lp) = binding. def_and_lp ( ) ;
3190
3149
( def, last_private. or ( lp) )
@@ -3219,7 +3178,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3219
3178
& module_path[ ..] ,
3220
3179
0 ,
3221
3180
span,
3222
- PathSearch ,
3223
3181
LastMod ( AllPublic ) ) {
3224
3182
Failed ( err) => {
3225
3183
let ( span, msg) = match err {
@@ -3235,9 +3193,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3235
3193
return None ;
3236
3194
}
3237
3195
3238
- Indeterminate => {
3239
- panic ! ( "indeterminate unexpected" ) ;
3240
- }
3196
+ Indeterminate => return None ,
3241
3197
3242
3198
Success ( ( resulting_module, resulting_last_private) ) => {
3243
3199
containing_module = resulting_module;
@@ -3246,11 +3202,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3246
3202
}
3247
3203
3248
3204
let name = segments. last ( ) . unwrap ( ) . identifier . name ;
3249
- match self . resolve_name_in_module ( containing_module,
3250
- name,
3251
- namespace,
3252
- NameSearchType :: PathSearch ,
3253
- false ) {
3205
+ match self . resolve_name_in_module ( containing_module, name, namespace, false ) {
3254
3206
Success ( ( Target { binding, .. } , _) ) => {
3255
3207
let ( def, lp) = binding. def_and_lp ( ) ;
3256
3208
Some ( ( def, last_private. or ( lp) ) )
@@ -3292,7 +3244,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3292
3244
if let Success ( ( target, _) ) = self . resolve_name_in_module ( module,
3293
3245
ident. unhygienic_name ,
3294
3246
namespace,
3295
- PathSearch ,
3296
3247
true ) {
3297
3248
if let Some ( def) = target. binding . def ( ) {
3298
3249
return Some ( LocalDef :: from_def ( def) ) ;
@@ -3332,9 +3283,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3332
3283
}
3333
3284
}
3334
3285
}
3335
- Indeterminate => {
3336
- panic ! ( "unexpected indeterminate result" ) ;
3337
- }
3286
+ Indeterminate => None ,
3338
3287
Failed ( err) => {
3339
3288
debug ! ( "(resolving item path by identifier in lexical scope) failed to resolve {}" ,
3340
3289
name) ;
@@ -3390,11 +3339,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3390
3339
}
3391
3340
}
3392
3341
} else {
3393
- match this. resolve_module_path ( root,
3394
- & name_path[ ..] ,
3395
- UseLexicalScope ,
3396
- span,
3397
- PathSearch ) {
3342
+ match this. resolve_module_path ( root, & name_path, UseLexicalScope , span) {
3398
3343
Success ( ( module, _) ) => Some ( module) ,
3399
3344
_ => None ,
3400
3345
}
@@ -3640,10 +3585,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
3640
3585
let current_module = self . current_module ;
3641
3586
3642
3587
match self . resolve_module_path ( current_module,
3643
- & name_path[ ..] ,
3644
- UseLexicalScope ,
3645
- expr. span ,
3646
- PathSearch ) {
3588
+ & name_path[ ..] ,
3589
+ UseLexicalScope ,
3590
+ expr. span ) {
3647
3591
Success ( _) => {
3648
3592
context = UnresolvedNameContext :: PathIsMod ( expr. id ) ;
3649
3593
} ,
0 commit comments