Skip to content

Commit 4462bb5

Browse files
committed
Introduce a no-op PlaceMention statement for let _ =.
1 parent be758ef commit 4462bb5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+139
-20
lines changed

compiler/rustc_borrowck/src/dataflow.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,7 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
390390
| mir::StatementKind::Deinit(..)
391391
| mir::StatementKind::StorageLive(..)
392392
| mir::StatementKind::Retag { .. }
393+
| mir::StatementKind::PlaceMention(..)
393394
| mir::StatementKind::AscribeUserType(..)
394395
| mir::StatementKind::Coverage(..)
395396
| mir::StatementKind::Intrinsic(..)

compiler/rustc_borrowck/src/def_use.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ pub fn categorize(context: PlaceContext) -> Option<DefUse> {
7373
Some(DefUse::Drop),
7474

7575
// Debug info is neither def nor use.
76-
PlaceContext::NonUse(NonUseContext::VarDebugInfo) => None,
76+
PlaceContext::NonUse(NonUseContext::PlaceMention | NonUseContext::VarDebugInfo) => None,
7777

7878
PlaceContext::MutatingUse(MutatingUseContext::Deinit | MutatingUseContext::SetDiscriminant) => {
7979
bug!("These statements are not allowed in this MIR phase")

compiler/rustc_borrowck/src/invalidation.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
7979
}
8080
// Only relevant for mir typeck
8181
StatementKind::AscribeUserType(..)
82+
// Only relevant for unsafeck
83+
| StatementKind::PlaceMention(..)
8284
// Doesn't have any language semantics
8385
| StatementKind::Coverage(..)
8486
// Does not actually affect borrowck

compiler/rustc_borrowck/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,8 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
690690
}
691691
// Only relevant for mir typeck
692692
StatementKind::AscribeUserType(..)
693+
// Only relevant for unsafeck
694+
| StatementKind::PlaceMention(..)
693695
// Doesn't have any language semantics
694696
| StatementKind::Coverage(..)
695697
// These do not actually affect borrowck

compiler/rustc_borrowck/src/type_check/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,9 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {
772772

773773
match context {
774774
PlaceContext::MutatingUse(_) => ty::Invariant,
775-
PlaceContext::NonUse(StorageDead | StorageLive | VarDebugInfo) => ty::Invariant,
775+
PlaceContext::NonUse(StorageDead | StorageLive | PlaceMention | VarDebugInfo) => {
776+
ty::Invariant
777+
}
776778
PlaceContext::NonMutatingUse(
777779
Inspect | Copy | Move | SharedBorrow | ShallowBorrow | UniqueBorrow | AddressOf
778780
| Projection,
@@ -1282,6 +1284,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
12821284
| StatementKind::Retag { .. }
12831285
| StatementKind::Coverage(..)
12841286
| StatementKind::ConstEvalCounter
1287+
| StatementKind::PlaceMention(..)
12851288
| StatementKind::Nop => {}
12861289
StatementKind::Deinit(..) | StatementKind::SetDiscriminant { .. } => {
12871290
bug!("Statement not allowed in this MIR phase")

compiler/rustc_codegen_cranelift/src/base.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -819,6 +819,7 @@ fn codegen_stmt<'tcx>(
819819
| StatementKind::Nop
820820
| StatementKind::FakeRead(..)
821821
| StatementKind::Retag { .. }
822+
| StatementKind::PlaceMention(..)
822823
| StatementKind::AscribeUserType(..) => {}
823824

824825
StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"),

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
529529
| StatementKind::StorageDead(_)
530530
| StatementKind::Retag(_, _)
531531
| StatementKind::AscribeUserType(_, _)
532+
| StatementKind::PlaceMention(..)
532533
| StatementKind::Coverage(_)
533534
| StatementKind::ConstEvalCounter
534535
| StatementKind::Nop => {}

compiler/rustc_codegen_ssa/src/mir/statement.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
9292
| mir::StatementKind::Retag { .. }
9393
| mir::StatementKind::AscribeUserType(..)
9494
| mir::StatementKind::ConstEvalCounter
95+
| mir::StatementKind::PlaceMention(..)
9596
| mir::StatementKind::Nop => {}
9697
}
9798
}

compiler/rustc_const_eval/src/interpret/step.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
114114
Intrinsic(box intrinsic) => self.emulate_nondiverging_intrinsic(intrinsic)?,
115115

116116
// Statements we do not track.
117-
AscribeUserType(..) => {}
117+
PlaceMention(..) | AscribeUserType(..) => {}
118118

119119
// Currently, Miri discards Coverage statements. Coverage statements are only injected
120120
// via an optional compile time MIR pass and have no side effects. Since Coverage

compiler/rustc_const_eval/src/transform/check_consts/check.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
690690
| StatementKind::StorageLive(_)
691691
| StatementKind::StorageDead(_)
692692
| StatementKind::Retag { .. }
693+
| StatementKind::PlaceMention(..)
693694
| StatementKind::AscribeUserType(..)
694695
| StatementKind::Coverage(..)
695696
| StatementKind::Intrinsic(..)

0 commit comments

Comments
 (0)