Validate removal of AscribeUserType, FakeRead, and Shallow borrow
Those statements are removed by CleanupNonCodegenStatements pass in drop lowering phase, and should not occur afterwards.
This commit is contained in:
parent
e2be5f568d
commit
00e64ba476
1 changed files with 26 additions and 2 deletions
|
@ -4,8 +4,8 @@ use super::{MirPass, MirSource};
|
||||||
use rustc_middle::mir::visit::Visitor;
|
use rustc_middle::mir::visit::Visitor;
|
||||||
use rustc_middle::{
|
use rustc_middle::{
|
||||||
mir::{
|
mir::{
|
||||||
AggregateKind, BasicBlock, Body, Location, MirPhase, Operand, Rvalue, Statement,
|
AggregateKind, BasicBlock, Body, BorrowKind, Location, MirPhase, Operand, Rvalue,
|
||||||
StatementKind, Terminator, TerminatorKind,
|
Statement, StatementKind, Terminator, TerminatorKind,
|
||||||
},
|
},
|
||||||
ty::{
|
ty::{
|
||||||
self,
|
self,
|
||||||
|
@ -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",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue