1
Fork 0

Make is_block_tail a variant of LocalInfo.

This commit is contained in:
Camille GILLOT 2023-03-10 09:08:10 +00:00
parent bcb161def7
commit d31386a52b
6 changed files with 26 additions and 39 deletions

View file

@ -124,9 +124,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
Category::Constant | Category::Place | Category::Rvalue(..) => {
let operand = unpack!(block = this.as_temp(block, scope, expr, Mutability::Mut));
let decl_info = this.local_decls[operand].local_info.as_mut().assert_crate_local();
if let LocalInfo::Boring = **decl_info {
**decl_info = local_info;
// Overwrite temp local info if we have something more interesting to record.
if !matches!(local_info, LocalInfo::Boring) {
let decl_info = this.local_decls[operand].local_info.as_mut().assert_crate_local();
if let LocalInfo::Boring | LocalInfo::BlockTailTemp(_) = **decl_info {
**decl_info = local_info;
}
}
block.and(Operand::Move(Place::from(operand)))
}

View file

@ -49,29 +49,28 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
}
debug!("creating temp {:?} with block_context: {:?}", local_decl, this.block_context);
// Find out whether this temp is being created within the
// tail expression of a block whose result is ignored.
if let Some(tail_info) = this.block_context.currently_in_block_tail() {
local_decl = local_decl.block_tail(tail_info);
}
match expr.kind {
let local_info = match expr.kind {
ExprKind::StaticRef { def_id, .. } => {
assert!(!this.tcx.is_thread_local_static(def_id));
local_decl.internal = true;
**local_decl.local_info.as_mut().assert_crate_local() =
LocalInfo::StaticRef { def_id, is_thread_local: false };
LocalInfo::StaticRef { def_id, is_thread_local: false }
}
ExprKind::ThreadLocalRef(def_id) => {
assert!(this.tcx.is_thread_local_static(def_id));
local_decl.internal = true;
**local_decl.local_info.as_mut().assert_crate_local() =
LocalInfo::StaticRef { def_id, is_thread_local: true };
LocalInfo::StaticRef { def_id, is_thread_local: true }
}
ExprKind::NamedConst { def_id, .. } | ExprKind::ConstParam { def_id, .. } => {
**local_decl.local_info.as_mut().assert_crate_local() = LocalInfo::ConstRef { def_id };
LocalInfo::ConstRef { def_id }
}
_ => {}
}
// Find out whether this temp is being created within the
// tail expression of a block whose result is ignored.
_ if let Some(tail_info) = this.block_context.currently_in_block_tail() => {
LocalInfo::BlockTailTemp(tail_info)
}
_ => LocalInfo::Boring,
};
**local_decl.local_info.as_mut().assert_crate_local() = local_info;
this.local_decls.push(local_decl)
};
let temp_place = Place::from(temp);

View file

@ -2224,7 +2224,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
user_ty: if user_ty.is_empty() { None } else { Some(Box::new(user_ty)) },
source_info,
internal: false,
is_block_tail: None,
local_info: ClearCrossCrate::Set(Box::new(LocalInfo::User(BindingForm::Var(
VarBindingForm {
binding_mode,
@ -2253,7 +2252,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
user_ty: None,
source_info,
internal: false,
is_block_tail: None,
local_info: ClearCrossCrate::Set(Box::new(LocalInfo::User(BindingForm::RefForGuard))),
});
self.var_debug_info.push(VarDebugInfo {