@@ -17,6 +17,7 @@ use rustc_index::Idx;
17
17
use rustc_middle:: bug;
18
18
use rustc_middle:: middle:: region:: * ;
19
19
use rustc_middle:: ty:: TyCtxt ;
20
+ use rustc_session:: lint;
20
21
use rustc_span:: source_map;
21
22
use tracing:: debug;
22
23
@@ -167,10 +168,24 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h
167
168
}
168
169
}
169
170
if let Some ( tail_expr) = blk. expr {
170
- if visitor. tcx . features ( ) . shorter_tail_lifetimes
171
- && blk. span . edition ( ) . at_least_rust_2024 ( )
171
+ let local_id = tail_expr. hir_id . local_id ;
172
+ let edition = blk. span . edition ( ) ;
173
+ if visitor. tcx . features ( ) . shorter_tail_lifetimes && edition. at_least_rust_2024 ( ) {
174
+ visitor. terminating_scopes . insert ( local_id) ;
175
+ } else if edition < lint:: Edition :: Edition2024
176
+ && !matches ! (
177
+ visitor. tcx. lint_level_at_node( lint:: builtin:: TAIL_EXPR_DROP_ORDER , blk. hir_id) ,
178
+ ( lint:: Level :: Allow , _)
179
+ )
172
180
{
173
- visitor. terminating_scopes . insert ( tail_expr. hir_id . local_id ) ;
181
+ // If this temporary scope will be changing once the codebase adopts Rust 2024,
182
+ // and we are linting about possible semantic changes that would result,
183
+ // then record this node-id in the field `backwards_incompatible_scope`
184
+ // for future reference.
185
+ visitor
186
+ . scope_tree
187
+ . backwards_incompatible_scope
188
+ . insert ( local_id, Scope { id : local_id, data : ScopeData :: Node } ) ;
174
189
}
175
190
visitor. visit_expr ( tail_expr) ;
176
191
}
0 commit comments