Skip to content

Commit

Permalink
Rollup merge of #76548 - tmiasko:validate, r=davidtwco
Browse files Browse the repository at this point in the history
Validate removal of AscribeUserType, FakeRead, and Shallow borrow

Those statements are removed by CleanupNonCodegenStatements pass
in drop lowering phase, and should not occur afterwards.
  • Loading branch information
tmandry committed Sep 10, 2020
2 parents 9f8a782 + 00e64ba commit 2df1487
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions compiler/rustc_mir/src/transform/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use super::{MirPass, MirSource};
use rustc_middle::mir::visit::Visitor;
use rustc_middle::{
mir::{
AggregateKind, BasicBlock, Body, Location, MirPhase, Operand, Rvalue, Statement,
StatementKind, Terminator, TerminatorKind,
AggregateKind, BasicBlock, Body, BorrowKind, Location, MirPhase, Operand, Rvalue,
Statement, StatementKind, Terminator, TerminatorKind,
},
ty::{
self,
Expand Down Expand Up @@ -274,9 +274,33 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
)
}
}
Rvalue::Ref(_, BorrowKind::Shallow, _) => {
if self.mir_phase > MirPhase::DropLowering {
self.fail(
location,
"`Assign` statement with a `Shallow` borrow should have been removed after drop lowering phase",
);
}
}
_ => {}
}
}
StatementKind::AscribeUserType(..) => {
if self.mir_phase > MirPhase::DropLowering {
self.fail(
location,
"`AscribeUserType` should have been removed after drop lowering phase",
);
}
}
StatementKind::FakeRead(..) => {
if self.mir_phase > MirPhase::DropLowering {
self.fail(
location,
"`FakeRead` should have been removed after drop lowering phase",
);
}
}
_ => {}
}
}
Expand Down

0 comments on commit 2df1487

Please sign in to comment.