@@ -307,7 +307,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
307
307
let normalized_ident = Ident { span : normalized_span, ..ident } ;
308
308
309
309
// Walk backwards up the ribs in scope.
310
- let mut module = self . graph_root ;
311
310
for ( i, rib) in ribs. iter ( ) . enumerate ( ) . rev ( ) {
312
311
debug ! ( "walk rib\n {:?}" , rib. bindings) ;
313
312
// Use the rib kind to determine whether we are resolving parameters
@@ -323,50 +322,46 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
323
322
* original_rib_ident_def,
324
323
ribs,
325
324
) ) ) ;
325
+ } else if let RibKind :: Block ( Some ( module) ) = rib. kind
326
+ && let Ok ( binding) = self . resolve_ident_in_module_unadjusted (
327
+ ModuleOrUniformRoot :: Module ( module) ,
328
+ ident,
329
+ ns,
330
+ parent_scope,
331
+ Shadowing :: Unrestricted ,
332
+ finalize. map ( |finalize| Finalize { used : Used :: Scope , ..finalize } ) ,
333
+ ignore_binding,
334
+ None ,
335
+ )
336
+ {
337
+ // The ident resolves to an item in a block.
338
+ return Some ( LexicalScopeBinding :: Item ( binding) ) ;
339
+ } else if let RibKind :: Module ( module) = rib. kind {
340
+ // Encountered a module item, abandon ribs and look into that module and preludes.
341
+ return self
342
+ . early_resolve_ident_in_lexical_scope (
343
+ orig_ident,
344
+ ScopeSet :: Late ( ns, module, finalize. map ( |finalize| finalize. node_id ) ) ,
345
+ parent_scope,
346
+ finalize,
347
+ finalize. is_some ( ) ,
348
+ ignore_binding,
349
+ None ,
350
+ )
351
+ . ok ( )
352
+ . map ( LexicalScopeBinding :: Item ) ;
326
353
}
327
354
328
- module = match rib. kind {
329
- RibKind :: Module ( module) | RibKind :: Block ( Some ( module) ) => module,
330
- RibKind :: MacroDefinition ( def) if def == self . macro_def ( ident. span . ctxt ( ) ) => {
331
- // If an invocation of this macro created `ident`, give up on `ident`
332
- // and switch to `ident`'s source from the macro definition.
333
- ident. span . remove_mark ( ) ;
334
- continue ;
335
- }
336
- _ => continue ,
337
- } ;
338
-
339
- match module. kind {
340
- ModuleKind :: Block => { } // We can see through blocks
341
- _ => break ,
342
- }
343
-
344
- let item = self . resolve_ident_in_module_unadjusted (
345
- ModuleOrUniformRoot :: Module ( module) ,
346
- ident,
347
- ns,
348
- parent_scope,
349
- Shadowing :: Unrestricted ,
350
- finalize. map ( |finalize| Finalize { used : Used :: Scope , ..finalize } ) ,
351
- ignore_binding,
352
- None ,
353
- ) ;
354
- if let Ok ( binding) = item {
355
- // The ident resolves to an item.
356
- return Some ( LexicalScopeBinding :: Item ( binding) ) ;
355
+ if let RibKind :: MacroDefinition ( def) = rib. kind
356
+ && def == self . macro_def ( ident. span . ctxt ( ) )
357
+ {
358
+ // If an invocation of this macro created `ident`, give up on `ident`
359
+ // and switch to `ident`'s source from the macro definition.
360
+ ident. span . remove_mark ( ) ;
357
361
}
358
362
}
359
- self . early_resolve_ident_in_lexical_scope (
360
- orig_ident,
361
- ScopeSet :: Late ( ns, module, finalize. map ( |finalize| finalize. node_id ) ) ,
362
- parent_scope,
363
- finalize,
364
- finalize. is_some ( ) ,
365
- ignore_binding,
366
- None ,
367
- )
368
- . ok ( )
369
- . map ( LexicalScopeBinding :: Item )
363
+
364
+ unreachable ! ( )
370
365
}
371
366
372
367
/// Resolve an identifier in lexical scope.
0 commit comments