@@ -2774,9 +2774,17 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
27742774 }
27752775 }
27762776
2777+ // Check the items.
2778+ let module = self . current_module ;
27772779 let name = identifier. unhygienic_name ;
2778- self . resolve_item_by_name_in_lexical_scope ( name, namespace, record_used)
2779- . map ( LocalDef :: from_def)
2780+ match self . resolve_item_in_lexical_scope ( module, name, namespace, record_used) {
2781+ Success ( ( target, _) ) => target. binding . def ( ) . map ( LocalDef :: from_def) ,
2782+ Failed ( Some ( ( span, msg) ) ) => {
2783+ resolve_error ( self , span, ResolutionError :: FailedToResolve ( & * msg) ) ;
2784+ None
2785+ }
2786+ _ => None ,
2787+ }
27802788 }
27812789
27822790 // Resolve a local definition, potentially adjusting for closures.
@@ -3020,49 +3028,6 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
30203028 None
30213029 }
30223030
3023- fn resolve_item_by_name_in_lexical_scope ( & mut self ,
3024- name : Name ,
3025- namespace : Namespace ,
3026- record_used : bool )
3027- -> Option < Def > {
3028- // Check the items.
3029- let module = self . current_module ;
3030- match self . resolve_item_in_lexical_scope ( module, name, namespace, record_used) {
3031- Success ( ( target, _) ) => {
3032- match target. binding . def ( ) {
3033- None => {
3034- // This can happen if we were looking for a type and
3035- // found a module instead. Modules don't have defs.
3036- debug ! ( "(resolving item path by identifier in lexical scope) failed to \
3037- resolve {} after success...",
3038- name) ;
3039- None
3040- }
3041- Some ( def) => {
3042- debug ! ( "(resolving item path in lexical scope) resolved `{}` to item" ,
3043- name) ;
3044- // This lookup is "all public" because it only searched
3045- // for one identifier in the current module (couldn't
3046- // have passed through reexports or anything like that.
3047- Some ( def)
3048- }
3049- }
3050- }
3051- Indeterminate => None ,
3052- Failed ( err) => {
3053- debug ! ( "(resolving item path by identifier in lexical scope) failed to \
3054- resolve `{}`",
3055- name) ;
3056-
3057- if let Some ( ( span, msg) ) = err {
3058- resolve_error ( self , span, ResolutionError :: FailedToResolve ( & * msg) )
3059- }
3060-
3061- None
3062- }
3063- }
3064- }
3065-
30663031 fn with_no_errors < T , F > ( & mut self , f : F ) -> T
30673032 where F : FnOnce ( & mut Resolver ) -> T
30683033 {
0 commit comments