@@ -44,7 +44,6 @@ use self::RibKind::*;
4444use self :: UseLexicalScopeFlag :: * ;
4545use self :: ModulePrefixResult :: * ;
4646use self :: AssocItemResolveResult :: * ;
47- use self :: NameSearchType :: * ;
4847use self :: BareIdentifierPatternResolution :: * ;
4948use self :: ParentLink :: * ;
5049use self :: FallbackChecks :: * ;
@@ -784,16 +783,6 @@ enum AssocItemResolveResult {
784783 ResolveAttempt ( Option < PathResolution > ) ,
785784}
786785
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-
797786#[ derive( Copy , Clone ) ]
798787enum BareIdentifierPatternResolution {
799788 FoundStructOrEnumVariant ( Def , LastPrivate ) ,
@@ -1370,7 +1359,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13701359 module_path : & [ Name ] ,
13711360 index : usize ,
13721361 span : Span ,
1373- name_search_type : NameSearchType ,
13741362 lp : LastPrivate )
13751363 -> ResolveResult < ( Module < ' a > , LastPrivate ) > {
13761364 fn search_parent_externals < ' a > ( needle : Name , module : Module < ' a > )
@@ -1396,11 +1384,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
13961384 // modules as we go.
13971385 while index < module_path_len {
13981386 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 ) {
14041388 Failed ( None ) => {
14051389 let segment_name = name. as_str ( ) ;
14061390 let module_name = module_to_string ( search_module) ;
@@ -1477,8 +1461,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
14771461 module_ : Module < ' a > ,
14781462 module_path : & [ Name ] ,
14791463 use_lexical_scope : UseLexicalScopeFlag ,
1480- span : Span ,
1481- name_search_type : NameSearchType )
1464+ span : Span )
14821465 -> ResolveResult < ( Module < ' a > , LastPrivate ) > {
14831466 let module_path_len = module_path. len ( ) ;
14841467 assert ! ( module_path_len > 0 ) ;
@@ -1559,7 +1542,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
15591542 module_path,
15601543 start_index,
15611544 span,
1562- name_search_type,
15631545 last_private)
15641546 }
15651547
@@ -1658,11 +1640,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
16581640 }
16591641
16601642 // 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 ) {
16661644 Failed ( Some ( ( span, msg) ) ) => {
16671645 resolve_error ( self , span, ResolutionError :: FailedToResolve ( & * msg) ) ;
16681646 }
@@ -1787,7 +1765,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
17871765 module_ : Module < ' a > ,
17881766 name : Name ,
17891767 namespace : Namespace ,
1790- name_search_type : NameSearchType ,
17911768 allow_private_imports : bool )
17921769 -> ResolveResult < ( Target < ' a > , bool ) > {
17931770 debug ! ( "(resolving name in module) resolving `{}` in `{}`" ,
@@ -1811,14 +1788,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
18111788 }
18121789 }
18131790
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-
18221791 // Check the list of resolved imports.
18231792 let children = module_. import_resolutions . borrow ( ) ;
18241793 match children. get ( & name) {
@@ -2912,9 +2881,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
29122881 }
29132882 }
29142883
2915- Indeterminate => {
2916- panic ! ( "unexpected indeterminate result" ) ;
2917- }
2884+ Indeterminate => return BareIdentifierPatternUnresolved ,
29182885 Failed ( err) => {
29192886 match err {
29202887 Some ( ( span, msg) ) => {
@@ -3154,11 +3121,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
31543121 let containing_module;
31553122 let last_private;
31563123 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) {
31623125 Failed ( err) => {
31633126 let ( span, msg) = match err {
31643127 Some ( ( span, msg) ) => ( span, msg) ,
@@ -3172,19 +3135,15 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
31723135 resolve_error ( self , span, ResolutionError :: FailedToResolve ( & * msg) ) ;
31733136 return None ;
31743137 }
3175- Indeterminate => panic ! ( "indeterminate unexpected" ) ,
3138+ Indeterminate => return None ,
31763139 Success ( ( resulting_module, resulting_last_private) ) => {
31773140 containing_module = resulting_module;
31783141 last_private = resulting_last_private;
31793142 }
31803143 }
31813144
31823145 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 ) {
31883147 Success ( ( Target { binding, .. } , _) ) => {
31893148 let ( def, lp) = binding. def_and_lp ( ) ;
31903149 ( def, last_private. or ( lp) )
@@ -3219,7 +3178,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
32193178 & module_path[ ..] ,
32203179 0 ,
32213180 span,
3222- PathSearch ,
32233181 LastMod ( AllPublic ) ) {
32243182 Failed ( err) => {
32253183 let ( span, msg) = match err {
@@ -3235,9 +3193,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
32353193 return None ;
32363194 }
32373195
3238- Indeterminate => {
3239- panic ! ( "indeterminate unexpected" ) ;
3240- }
3196+ Indeterminate => return None ,
32413197
32423198 Success ( ( resulting_module, resulting_last_private) ) => {
32433199 containing_module = resulting_module;
@@ -3246,11 +3202,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
32463202 }
32473203
32483204 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 ) {
32543206 Success ( ( Target { binding, .. } , _) ) => {
32553207 let ( def, lp) = binding. def_and_lp ( ) ;
32563208 Some ( ( def, last_private. or ( lp) ) )
@@ -3292,7 +3244,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
32923244 if let Success ( ( target, _) ) = self . resolve_name_in_module ( module,
32933245 ident. unhygienic_name ,
32943246 namespace,
3295- PathSearch ,
32963247 true ) {
32973248 if let Some ( def) = target. binding . def ( ) {
32983249 return Some ( LocalDef :: from_def ( def) ) ;
@@ -3332,9 +3283,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
33323283 }
33333284 }
33343285 }
3335- Indeterminate => {
3336- panic ! ( "unexpected indeterminate result" ) ;
3337- }
3286+ Indeterminate => None ,
33383287 Failed ( err) => {
33393288 debug ! ( "(resolving item path by identifier in lexical scope) failed to resolve {}" ,
33403289 name) ;
@@ -3390,11 +3339,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
33903339 }
33913340 }
33923341 } 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) {
33983343 Success ( ( module, _) ) => Some ( module) ,
33993344 _ => None ,
34003345 }
@@ -3640,10 +3585,9 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
36403585 let current_module = self . current_module ;
36413586
36423587 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 ) {
36473591 Success ( _) => {
36483592 context = UnresolvedNameContext :: PathIsMod ( expr. id ) ;
36493593 } ,
0 commit comments