Skip to content
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

Introduce a no-op PlaceMention statement for let _ =. #102256

Merged
merged 9 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions compiler/rustc_borrowck/src/dataflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ impl<'tcx> rustc_mir_dataflow::GenKillAnalysis<'tcx> for Borrows<'_, 'tcx> {
| mir::StatementKind::Deinit(..)
| mir::StatementKind::StorageLive(..)
| mir::StatementKind::Retag { .. }
| mir::StatementKind::PlaceMention(..)
| mir::StatementKind::AscribeUserType(..)
| mir::StatementKind::Coverage(..)
| mir::StatementKind::Intrinsic(..)
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_borrowck/src/def_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ pub fn categorize(context: PlaceContext) -> Option<DefUse> {
PlaceContext::MutatingUse(MutatingUseContext::Drop) =>
Some(DefUse::Drop),

// This statement exists to help unsafeck. It does not require the place to be live.
PlaceContext::NonUse(NonUseContext::PlaceMention) => None,
// Debug info is neither def nor use.
PlaceContext::NonUse(NonUseContext::VarDebugInfo) => None,

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_borrowck/src/invalidation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ impl<'cx, 'tcx> Visitor<'tcx> for InvalidationGenerator<'cx, 'tcx> {
}
// Only relevant for mir typeck
StatementKind::AscribeUserType(..)
// Only relevant for unsafeck
| StatementKind::PlaceMention(..)
// Doesn't have any language semantics
| StatementKind::Coverage(..)
// Does not actually affect borrowck
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_borrowck/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,8 @@ impl<'cx, 'tcx> rustc_mir_dataflow::ResultsVisitor<'cx, 'tcx> for MirBorrowckCtx
}
// Only relevant for mir typeck
StatementKind::AscribeUserType(..)
// Only relevant for unsafeck
| StatementKind::PlaceMention(..)
// Doesn't have any language semantics
| StatementKind::Coverage(..)
// These do not actually affect borrowck
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_borrowck/src/type_check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,9 @@ impl<'a, 'b, 'tcx> TypeVerifier<'a, 'b, 'tcx> {

match context {
PlaceContext::MutatingUse(_) => ty::Invariant,
PlaceContext::NonUse(StorageDead | StorageLive | VarDebugInfo) => ty::Invariant,
PlaceContext::NonUse(StorageDead | StorageLive | PlaceMention | VarDebugInfo) => {
ty::Invariant
}
PlaceContext::NonMutatingUse(
Inspect | Copy | Move | SharedBorrow | ShallowBorrow | UniqueBorrow | AddressOf
| Projection,
Expand Down Expand Up @@ -1282,6 +1284,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
| StatementKind::Retag { .. }
| StatementKind::Coverage(..)
| StatementKind::ConstEvalCounter
| StatementKind::PlaceMention(..)
| StatementKind::Nop => {}
StatementKind::Deinit(..) | StatementKind::SetDiscriminant { .. } => {
bug!("Statement not allowed in this MIR phase")
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -819,6 +819,7 @@ fn codegen_stmt<'tcx>(
| StatementKind::Nop
| StatementKind::FakeRead(..)
| StatementKind::Retag { .. }
| StatementKind::PlaceMention(..)
| StatementKind::AscribeUserType(..) => {}

StatementKind::Coverage { .. } => fx.tcx.sess.fatal("-Zcoverage is unimplemented"),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_cranelift/src/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,7 @@ pub(crate) fn mir_operand_get_const_val<'tcx>(
| StatementKind::StorageDead(_)
| StatementKind::Retag(_, _)
| StatementKind::AscribeUserType(_, _)
| StatementKind::PlaceMention(..)
| StatementKind::Coverage(_)
| StatementKind::ConstEvalCounter
| StatementKind::Nop => {}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/mir/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
| mir::StatementKind::Retag { .. }
| mir::StatementKind::AscribeUserType(..)
| mir::StatementKind::ConstEvalCounter
| mir::StatementKind::PlaceMention(..)
| mir::StatementKind::Nop => {}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/step.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Intrinsic(box intrinsic) => self.emulate_nondiverging_intrinsic(intrinsic)?,

// Statements we do not track.
AscribeUserType(..) => {}
PlaceMention(..) | AscribeUserType(..) => {}

// Currently, Miri discards Coverage statements. Coverage statements are only injected
// via an optional compile time MIR pass and have no side effects. Since Coverage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
| StatementKind::StorageLive(_)
| StatementKind::StorageDead(_)
| StatementKind::Retag { .. }
| StatementKind::PlaceMention(..)
Copy link
Contributor

@lcnr lcnr Mar 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we use super_statement here so if the place were to contain some operand which isn't allowed in const contexts this would change behavior. The only thing I was able to think of is the following which is already rejected, so this seems fine 🤷

static FOO: usize = 3;
const fn f() {
    let _ = FOO;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right. This would introduce an extra diagnostic for "dereferencing raw mutable pointers in constant functions is unstable". Exactly like unsafeck.

const unsafe fn foo(x: *mut usize) {
    let _ = *x;
}

As everything else around raw mutable pointers is already forbidden, I don't think this can break code. Can it?
Added a test.

| StatementKind::AscribeUserType(..)
| StatementKind::Coverage(..)
| StatementKind::Intrinsic(..)
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_const_eval/src/transform/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,14 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
}
}
}
StatementKind::PlaceMention(..) => {
if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Initial) {
self.fail(
location,
"`PlaceMention` should have been removed after drop lowering phase",
);
}
}
StatementKind::AscribeUserType(..) => {
if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Initial) {
self.fail(
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_middle/src/mir/spanview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_middle/src/mir/syntax.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_middle/src/mir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)]
Expand Down
11 changes: 11 additions & 0 deletions compiler/rustc_mir_build/src/build/cfg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ impl<'tcx> CFG<'tcx> {
self.push(block, stmt);
}

pub(crate) fn push_place_mention(
&mut self,
block: BasicBlock,
source_info: SourceInfo,
place: Place<'tcx>,
) {
let kind = StatementKind::PlaceMention(Box::new(place));
let stmt = Statement { source_info, kind };
self.push(block, stmt);
}

pub(crate) fn terminate(
&mut self,
block: BasicBlock,
Expand Down
7 changes: 7 additions & 0 deletions compiler/rustc_mir_build/src/build/matches/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,12 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {

_ => {
let place_builder = unpack!(block = self.as_place_builder(block, initializer));

if let Some(place) = place_builder.try_to_place(self) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's definitely not wrong to do this here, but I feel like ideally the code is structured in such a way that we can actually only do this for cases where the place is otherwise unused by the pattern.

Looked a bit at the code myself and decided that it is hard to understand and that I don't have the energy to refactor mir builder rn

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally, everything would go through lower_scrutinee. #103208 does this, but with a substantial change on how matches work, so it is better as a separate PR.

let source_info = self.source_info(initializer.span);
self.cfg.push_place_mention(block, source_info, place);
}

self.place_into_pattern(block, &irrefutable_pat, place_builder, true)
}
}
Expand All @@ -576,6 +582,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
false,
&mut [&mut candidate],
);

// For matches and function arguments, the place that is being matched
// can be set when creating the variables. But the place for
// let PATTERN = ... might not even exist until we do the assignment.
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_dataflow/src/impls/liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ impl<'a, 'tcx> Analysis<'tcx> for MaybeTransitiveLiveLocals<'a> {
| StatementKind::StorageDead(_)
| StatementKind::Retag(..)
| StatementKind::AscribeUserType(..)
| StatementKind::PlaceMention(..)
| StatementKind::Coverage(..)
| StatementKind::Intrinsic(..)
| StatementKind::ConstEvalCounter
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_dataflow/src/impls/storage_liveness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ impl<'mir, 'tcx> crate::GenKillAnalysis<'tcx> for MaybeRequiresStorage<'mir, 'tc
// Nothing to do for these. Match exhaustively so this fails to compile when new
// variants are added.
StatementKind::AscribeUserType(..)
| StatementKind::PlaceMention(..)
| StatementKind::Coverage(..)
| StatementKind::FakeRead(..)
| StatementKind::ConstEvalCounter
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_dataflow/src/move_paths/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
}
StatementKind::Retag { .. }
| StatementKind::AscribeUserType(..)
| StatementKind::PlaceMention(..)
| StatementKind::Coverage(..)
| StatementKind::Intrinsic(..)
| StatementKind::ConstEvalCounter
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_dataflow/src/value_analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ pub trait ValueAnalysis<'tcx> {
StatementKind::ConstEvalCounter
| StatementKind::Nop
| StatementKind::FakeRead(..)
| StatementKind::PlaceMention(..)
| StatementKind::Coverage(..)
| StatementKind::AscribeUserType(..) => (),
}
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_mir_transform/src/check_unsafety.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,16 @@ impl<'tcx> Visitor<'tcx> for UnsafetyChecker<'_, 'tcx> {
| StatementKind::StorageLive(..)
| StatementKind::StorageDead(..)
| StatementKind::Retag { .. }
| StatementKind::AscribeUserType(..)
| StatementKind::PlaceMention(..)
| StatementKind::Coverage(..)
| StatementKind::Intrinsic(..)
| StatementKind::ConstEvalCounter
| StatementKind::Nop => {
// safe (at least as emitted during MIR construction)
}
// `AscribeUserType` just exists to help MIR borrowck.
// It has no semantics, and everything is already reported by `PlaceMention`.
StatementKind::AscribeUserType(..) => return,
RalfJung marked this conversation as resolved.
Show resolved Hide resolved
}
self.super_statement(statement, location);
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_transform/src/cleanup_post_borrowck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl<'tcx> MirPass<'tcx> for CleanupPostBorrowck {
for statement in basic_block.statements.iter_mut() {
match statement.kind {
StatementKind::AscribeUserType(..)
| StatementKind::PlaceMention(..)
| StatementKind::Assign(box (_, Rvalue::Ref(_, BorrowKind::Shallow, _)))
| StatementKind::FakeRead(..) => statement.make_nop(),
_ => (),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_transform/src/coverage/spans.rs
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,7 @@ pub(super) fn filtered_statement_span(statement: &Statement<'_>) -> Option<Span>
| StatementKind::SetDiscriminant { .. }
| StatementKind::Deinit(..)
| StatementKind::Retag(_, _)
| StatementKind::PlaceMention(..)
| StatementKind::AscribeUserType(_, _) => {
Some(statement.source_info.span)
}
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_mir_transform/src/dead_store_elimination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, borrowed: &BitS
| StatementKind::ConstEvalCounter
| StatementKind::Nop => (),

StatementKind::FakeRead(_) | StatementKind::AscribeUserType(_, _) => {
StatementKind::FakeRead(_)
| StatementKind::PlaceMention(_)
| StatementKind::AscribeUserType(_, _) => {
bug!("{:?} not found in this MIR phase!", &statement.kind)
}
}
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_mir_transform/src/dest_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,9 @@ impl WriteInfo {
| StatementKind::Coverage(_)
| StatementKind::StorageLive(_)
| StatementKind::StorageDead(_) => (),
StatementKind::FakeRead(_) | StatementKind::AscribeUserType(_, _) => {
StatementKind::FakeRead(_)
| StatementKind::AscribeUserType(_, _)
| StatementKind::PlaceMention(_) => {
bug!("{:?} not found in this MIR phase", statement)
}
}
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_transform/src/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1647,6 +1647,7 @@ impl<'tcx> Visitor<'tcx> for EnsureGeneratorFieldAssignmentsNeverAlias<'_> {
| StatementKind::StorageDead(_)
| StatementKind::Retag(..)
| StatementKind::AscribeUserType(..)
| StatementKind::PlaceMention(..)
| StatementKind::Coverage(..)
| StatementKind::Intrinsic(..)
| StatementKind::ConstEvalCounter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ impl RemoveNoopLandingPads {
StatementKind::FakeRead(..)
| StatementKind::StorageLive(_)
| StatementKind::StorageDead(_)
| StatementKind::PlaceMention(..)
| StatementKind::AscribeUserType(..)
| StatementKind::Coverage(..)
| StatementKind::ConstEvalCounter
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_mir_transform/src/separate_const_switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ fn is_likely_const<'tcx>(mut tracked_place: Place<'tcx>, block: &BasicBlockData<
| StatementKind::StorageLive(_)
| StatementKind::Retag(_, _)
| StatementKind::AscribeUserType(_, _)
| StatementKind::PlaceMention(..)
| StatementKind::Coverage(_)
| StatementKind::StorageDead(_)
| StatementKind::Intrinsic(_)
Expand Down Expand Up @@ -315,6 +316,7 @@ fn find_determining_place<'tcx>(
| StatementKind::StorageDead(_)
| StatementKind::Retag(_, _)
| StatementKind::AscribeUserType(_, _)
| StatementKind::PlaceMention(..)
| StatementKind::Coverage(_)
| StatementKind::Intrinsic(_)
| StatementKind::ConstEvalCounter
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_mir_transform/src/simplify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ impl<'tcx> Visitor<'tcx> for UsedLocals {
| StatementKind::Retag(..)
| StatementKind::Coverage(..)
| StatementKind::FakeRead(..)
| StatementKind::PlaceMention(..)
| StatementKind::AscribeUserType(..) => {
self.super_statement(statement, location);
}
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_utils/src/qualify_min_const_fn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ fn check_statement<'tcx>(
| StatementKind::StorageDead(_)
| StatementKind::Retag { .. }
| StatementKind::AscribeUserType(..)
| StatementKind::PlaceMention(..)
| StatementKind::Coverage(..)
| StatementKind::ConstEvalCounter
| StatementKind::Nop => Ok(()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn full_tested_match() -> () {
}

bb11: {
PlaceMention(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6
StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
_0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:28: +6:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ fn full_tested_match2() -> () {
}

bb11: {
PlaceMention(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6
StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
_0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:29: +6:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ fn main() -> () {
}

bb19: {
PlaceMention(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +6:6
StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7
StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7
_0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:11: +7:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fn move_out_by_subslice() -> () {
bb6: {
StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
PlaceMention(_1); // scope 1 at $DIR/uniform_array_move_out.rs:+2:21: +2:22
StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
_12 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
_0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +3:2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ fn move_out_from_end() -> () {
bb6: {
StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
PlaceMention(_1); // scope 1 at $DIR/uniform_array_move_out.rs:+2:20: +2:21
StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
_12 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
_0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +3:2
Expand Down
2 changes: 2 additions & 0 deletions tests/mir-opt/issue_72181.main.built.after.mir
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ fn main() -> () {
}

bb1: {
PlaceMention(_1); // scope 0 at $DIR/issue_72181.rs:+1:13: +1:34
StorageDead(_1); // scope 0 at $DIR/issue_72181.rs:+1:34: +1:35
StorageLive(_2); // scope 1 at $DIR/issue_72181.rs:+3:9: +3:10
StorageLive(_3); // scope 1 at $DIR/issue_72181.rs:+3:14: +3:27
Expand All @@ -49,6 +50,7 @@ fn main() -> () {

bb2: {
_5 = (_2[_6].0: u64); // scope 4 at $DIR/issue_72181.rs:+4:22: +4:28
PlaceMention(_5); // scope 2 at $DIR/issue_72181.rs:+4:13: +4:30
StorageDead(_6); // scope 2 at $DIR/issue_72181.rs:+4:30: +4:31
StorageDead(_5); // scope 2 at $DIR/issue_72181.rs:+4:30: +4:31
_0 = const (); // scope 0 at $DIR/issue_72181.rs:+0:11: +5:2
Expand Down
Loading