Introduce a no-op PlaceMention statement for let _ =
.
This commit is contained in:
parent
be758ef5ab
commit
4462bb54e3
44 changed files with 139 additions and 20 deletions
|
@ -1453,6 +1453,9 @@ impl Debug for Statement<'_> {
|
|||
write!(fmt, "discriminant({:?}) = {:?}", place, variant_index)
|
||||
}
|
||||
Deinit(ref place) => write!(fmt, "Deinit({:?})", place),
|
||||
PlaceMention(ref place) => {
|
||||
write!(fmt, "PlaceMention({:?})", place)
|
||||
}
|
||||
AscribeUserType(box (ref place, ref c_ty), ref variance) => {
|
||||
write!(fmt, "AscribeUserType({:?}, {:?}, {:?})", place, variance, c_ty)
|
||||
}
|
||||
|
|
|
@ -247,6 +247,7 @@ pub fn statement_kind_name(statement: &Statement<'_>) -> &'static str {
|
|||
StorageLive(..) => "StorageLive",
|
||||
StorageDead(..) => "StorageDead",
|
||||
Retag(..) => "Retag",
|
||||
PlaceMention(..) => "PlaceMention",
|
||||
AscribeUserType(..) => "AscribeUserType",
|
||||
Coverage(..) => "Coverage",
|
||||
Intrinsic(..) => "Intrinsic",
|
||||
|
|
|
@ -325,6 +325,15 @@ pub enum StatementKind<'tcx> {
|
|||
/// Only `RetagKind::Default` and `RetagKind::FnEntry` are permitted.
|
||||
Retag(RetagKind, Box<Place<'tcx>>),
|
||||
|
||||
/// This statement exists to preserve a trace of a scrutinee matched against a wildcard
|
||||
/// binding. This is especially useful for `let _ = PLACE;` bindings that desugar to a single
|
||||
/// `PlaceMention(PLACE)`.
|
||||
///
|
||||
/// When executed at runtime this is a nop.
|
||||
///
|
||||
/// Disallowed after drop elaboration.
|
||||
PlaceMention(Box<Place<'tcx>>),
|
||||
|
||||
/// Encodes a user's type ascription. These need to be preserved
|
||||
/// intact so that NLL can respect them. For example:
|
||||
/// ```ignore (illustrative)
|
||||
|
|
|
@ -405,6 +405,13 @@ macro_rules! make_mir_visitor {
|
|||
StatementKind::Retag(kind, place) => {
|
||||
self.visit_retag($(& $mutability)? *kind, place, location);
|
||||
}
|
||||
StatementKind::PlaceMention(place) => {
|
||||
self.visit_place(
|
||||
place,
|
||||
PlaceContext::NonUse(NonUseContext::PlaceMention),
|
||||
location
|
||||
);
|
||||
}
|
||||
StatementKind::AscribeUserType(
|
||||
box (place, user_ty),
|
||||
variance
|
||||
|
@ -1288,6 +1295,8 @@ pub enum NonUseContext {
|
|||
AscribeUserTy,
|
||||
/// The data of a user variable, for debug info.
|
||||
VarDebugInfo,
|
||||
/// PlaceMention statement.
|
||||
PlaceMention,
|
||||
}
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue