-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move Derefer before Retag #96549
Move Derefer before Retag #96549
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,17 @@ fn may_be_reference(ty: Ty<'_>) -> bool { | |
} | ||
} | ||
|
||
/// Determines whether or not this LocalDecl is temp, if not it needs retagging. | ||
fn is_not_temp<'tcx>(local_decl: &LocalDecl<'tcx>) -> bool { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right, I will change this function in the next update of derefer. |
||
if local_decl.local_info.is_some() { | ||
oli-obk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
match local_decl.local_info.as_ref().unwrap().as_ref() { | ||
LocalInfo::Temp => return false, | ||
_ => (), | ||
}; | ||
} | ||
return true; | ||
} | ||
|
||
impl<'tcx> MirPass<'tcx> for AddRetag { | ||
fn is_enabled(&self, sess: &rustc_session::Session) -> bool { | ||
sess.opts.debugging_opts.mir_emit_retag | ||
|
@@ -71,7 +82,9 @@ impl<'tcx> MirPass<'tcx> for AddRetag { | |
let needs_retag = |place: &Place<'tcx>| { | ||
// FIXME: Instead of giving up for unstable places, we should introduce | ||
// a temporary and retag on that. | ||
is_stable(place.as_ref()) && may_be_reference(place.ty(&*local_decls, tcx).ty) | ||
is_stable(place.as_ref()) | ||
&& may_be_reference(place.ty(&*local_decls, tcx).ty) | ||
&& is_not_temp(&local_decls[place.local]) | ||
}; | ||
let place_base_raw = |place: &Place<'tcx>| { | ||
// If this is a `Deref`, get the type of what we are deref'ing. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(should be "its retagging"... not a big deal though)