-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Simplify some code that depend on Deref #97077
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
Changes from all commits
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 |
---|---|---|
|
@@ -1461,6 +1461,14 @@ impl<'tcx> Place<'tcx> { | |
self.projection.iter().any(|elem| elem.is_indirect()) | ||
} | ||
|
||
/// If MirPhase >= Derefered and if projection contains Deref, | ||
/// It's guaranteed to be in the first place | ||
pub fn has_deref(&self) -> 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. This is super confusing, we now have 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. I wrote this function, I don't quite remember the details why we needed to check if |
||
// To make sure this is not accidently used in wrong mir phase | ||
debug_assert!(!self.projection[1..].contains(&PlaceElem::Deref)); | ||
self.projection.first() == Some(&PlaceElem::Deref) | ||
oli-obk marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
/// Finds the innermost `Local` from this `Place`, *if* it is either a local itself or | ||
/// a single deref of a local. | ||
#[inline(always)] | ||
|
@@ -1533,6 +1541,12 @@ impl<'tcx> PlaceRef<'tcx> { | |
} | ||
} | ||
|
||
/// If MirPhase >= Derefered and if projection contains Deref, | ||
/// It's guaranteed to be in the first place | ||
pub fn has_deref(&self) -> bool { | ||
self.projection.first() == Some(&PlaceElem::Deref) | ||
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. The same debug assertion should also be added here -- right now it seems very easy to accidentally call 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. Added the debug assertion and bit better documentation here #114505 |
||
} | ||
|
||
/// If this place represents a local variable like `_X` with no | ||
/// projections, return `Some(_X)`. | ||
#[inline] | ||
|
Uh oh!
There was an error while loading. Please reload this page.