rescope temp lifetime in let-chain into IfElse
apply rules by span edition
This commit is contained in:
parent
33855f80d4
commit
f93df1f7dc
30 changed files with 1102 additions and 35 deletions
|
@ -1,7 +1,9 @@
|
|||
//! See docs in build/expr/mod.rs
|
||||
|
||||
use rustc_data_structures::stack::ensure_sufficient_stack;
|
||||
use rustc_hir::HirId;
|
||||
use rustc_middle::middle::region;
|
||||
use rustc_middle::middle::region::{Scope, ScopeData};
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::thir::*;
|
||||
use tracing::{debug, instrument};
|
||||
|
@ -73,11 +75,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
|
|||
_ if let Some(tail_info) = this.block_context.currently_in_block_tail() => {
|
||||
LocalInfo::BlockTailTemp(tail_info)
|
||||
}
|
||||
|
||||
_ if let Some(Scope { data: ScopeData::IfThenRescope, id }) = temp_lifetime => {
|
||||
LocalInfo::IfThenRescopeTemp {
|
||||
if_then: HirId { owner: this.hir_id.owner, local_id: id },
|
||||
}
|
||||
}
|
||||
|
||||
_ => LocalInfo::Boring,
|
||||
};
|
||||
**local_decl.local_info.as_mut().assert_crate_local() = local_info;
|
||||
this.local_decls.push(local_decl)
|
||||
};
|
||||
debug!(?temp);
|
||||
if deduplicate_temps {
|
||||
this.fixed_temps.insert(expr_id, temp);
|
||||
}
|
||||
|
|
|
@ -706,7 +706,13 @@ impl<'tcx> Cx<'tcx> {
|
|||
hir::ExprKind::If(cond, then, else_opt) => ExprKind::If {
|
||||
if_then_scope: region::Scope {
|
||||
id: then.hir_id.local_id,
|
||||
data: region::ScopeData::IfThen,
|
||||
data: {
|
||||
if expr.span.at_least_rust_2024() && tcx.features().if_let_rescope {
|
||||
region::ScopeData::IfThenRescope
|
||||
} else {
|
||||
region::ScopeData::IfThen
|
||||
}
|
||||
},
|
||||
},
|
||||
cond: self.mirror_expr(cond),
|
||||
then: self.mirror_expr(then),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue