re-name stuff
This commit is contained in:
parent
4d4b0f140f
commit
d9ddb6446d
@ -1080,7 +1080,7 @@ pub enum LocalInfo<'tcx> {
|
||||
/// (e.g. a temporary for `foo` in `MyStruct { my_field: foo }`)
|
||||
AggregateTemp,
|
||||
/// A temporary created during the pass `Derefer` to avoid it's retagging
|
||||
Temp,
|
||||
DerefTemp,
|
||||
}
|
||||
|
||||
impl<'tcx> LocalDecl<'tcx> {
|
||||
|
@ -78,20 +78,22 @@ impl<'tcx> MirPatch<'tcx> {
|
||||
Location { block: bb, statement_index: offset }
|
||||
}
|
||||
|
||||
pub fn new_local_temp(&mut self, ty: Ty<'tcx>, span: Span) -> Local {
|
||||
pub fn new_local_with_info(
|
||||
&mut self,
|
||||
ty: Ty<'tcx>,
|
||||
span: Span,
|
||||
local_info: Option<Box<LocalInfo<'tcx>>>,
|
||||
) -> Local {
|
||||
let index = self.next_local;
|
||||
self.next_local += 1;
|
||||
let mut new_decl = LocalDecl::new(ty, span);
|
||||
new_decl.local_info = Some(Box::new(LocalInfo::Temp));
|
||||
new_decl.local_info = local_info;
|
||||
self.new_locals.push(new_decl);
|
||||
Local::new(index as usize)
|
||||
}
|
||||
|
||||
pub fn new_temp(&mut self, ty: Ty<'tcx>, span: Span) -> Local {
|
||||
let index = self.next_local;
|
||||
self.next_local += 1;
|
||||
self.new_locals.push(LocalDecl::new(ty, span));
|
||||
Local::new(index as usize)
|
||||
self.new_local_with_info(ty, span, None)
|
||||
}
|
||||
|
||||
pub fn new_internal(&mut self, ty: Ty<'tcx>, span: Span) -> Local {
|
||||
|
@ -61,7 +61,7 @@ fn may_be_reference(ty: Ty<'_>) -> bool {
|
||||
fn is_not_temp<'tcx>(local_decl: &LocalDecl<'tcx>) -> bool {
|
||||
if let Some(local_info) = &local_decl.local_info {
|
||||
match local_info.as_ref() {
|
||||
LocalInfo::Temp => return false,
|
||||
LocalInfo::DerefTemp => return false,
|
||||
_ => (),
|
||||
};
|
||||
}
|
||||
|
@ -33,8 +33,11 @@ impl<'tcx> MutVisitor<'tcx> for DerefChecker<'tcx> {
|
||||
for (idx, (p_ref, p_elem)) in place.iter_projections().enumerate() {
|
||||
if p_elem == ProjectionElem::Deref && !p_ref.projection.is_empty() {
|
||||
let ty = p_ref.ty(&self.local_decls, self.tcx).ty;
|
||||
let temp =
|
||||
self.patcher.new_local_temp(ty, self.local_decls[p_ref.local].source_info.span);
|
||||
let temp = self.patcher.new_local_with_info(
|
||||
ty,
|
||||
self.local_decls[p_ref.local].source_info.span,
|
||||
Some(Box::new(LocalInfo::DerefTemp)),
|
||||
);
|
||||
|
||||
self.patcher.add_statement(loc, StatementKind::StorageLive(temp));
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user