@@ -361,17 +361,40 @@ impl<'a> LifetimeContext<'a> {
361
361
scope_data : region:: CodeExtent ,
362
362
lifetime_ref : & ast:: Lifetime ,
363
363
scope : Scope ) {
364
+ debug ! ( "resolve_free_lifetime_ref \
365
+ scope_data: {} lifetime_ref: {} scope: {}",
366
+ scope_data, lifetime_ref, scope) ;
367
+
364
368
// Walk up the scope chain, tracking the outermost free scope,
365
369
// until we encounter a scope that contains the named lifetime
366
370
// or we run out of scopes.
367
371
let mut scope_data = scope_data;
368
372
let mut scope = scope;
369
373
let mut search_result = None ;
374
+ let mut loop_count = 0 u;
370
375
loop {
376
+ debug ! ( "resolve_free_lifetime_ref loop: {} \
377
+ scope_data: {} scope: {} search_result: {}",
378
+ loop_count, scope_data, scope, search_result) ;
371
379
match * scope {
372
380
BlockScope ( blk_scope_data, s) => {
373
- scope_data = blk_scope_data;
374
- scope = s;
381
+ // FIXME (pnkfelix): I still need to work through
382
+ // the theoretical justification for this
383
+ // transition from the block itself to its
384
+ // enclosing destruction scope. (In particular,
385
+ // perhaps athis *actually* belongs as part of the
386
+ // `RootScope` case, or maybe following the loop
387
+ // (either of which I think would resolve my
388
+ // problem), but not here, where it has a broad
389
+ // effect.
390
+ if let CodeExtent :: Misc ( node_id) = blk_scope_data {
391
+ let d = CodeExtent :: DestructionScope ( node_id) ;
392
+ scope_data = d;
393
+ scope = s;
394
+ } else {
395
+ self . sess . bug (
396
+ "found unexpected CodeExtent associated with blk_scope" )
397
+ }
375
398
}
376
399
377
400
RootScope => {
@@ -393,8 +416,9 @@ impl<'a> LifetimeContext<'a> {
393
416
Some ( ( _depth, decl_id) ) => {
394
417
let def = DefFreeRegion ( scope_data, decl_id) ;
395
418
debug ! ( "resolve_free_lifetime_ref: \
419
+ from parent scope {} \
396
420
insert_lifetime(lifetime_ref: {} def: {})",
397
- lifetime_ref, def) ;
421
+ lifetime_ref, * scope , def) ;
398
422
self . insert_lifetime ( lifetime_ref, def) ;
399
423
}
400
424
0 commit comments