about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2021-09-14 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2021-09-18 07:28:55 +0200
commit5118dd5a2f0b97a006f55ef68408a7dd1925bc12 (patch)
tree1ab5d99779ab2e32aea8e5774b3e7f6b839444ac
parent8e398f5ba77b283b529c0c61cc2313c4f82d61dd (diff)
downloadrust-5118dd5a2f0b97a006f55ef68408a7dd1925bc12.tar.gz
rust-5118dd5a2f0b97a006f55ef68408a7dd1925bc12.zip
Start block is not allowed to have basic block predecessors
-rw-r--r--compiler/rustc_const_eval/src/transform/validate.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/transform/validate.rs b/compiler/rustc_const_eval/src/transform/validate.rs
index 40a32a76c94..b09b2227f3e 100644
--- a/compiler/rustc_const_eval/src/transform/validate.rs
+++ b/compiler/rustc_const_eval/src/transform/validate.rs
@@ -9,7 +9,7 @@ use rustc_middle::mir::visit::{PlaceContext, Visitor};
 use rustc_middle::mir::{
     AggregateKind, BasicBlock, Body, BorrowKind, Local, Location, MirPhase, Operand, PlaceElem,
     PlaceRef, ProjectionElem, Rvalue, SourceScope, Statement, StatementKind, Terminator,
-    TerminatorKind,
+    TerminatorKind, START_BLOCK,
 };
 use rustc_middle::ty::fold::BottomUpFolder;
 use rustc_middle::ty::{self, ParamEnv, Ty, TyCtxt, TypeFoldable};
@@ -130,6 +130,9 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
     }
 
     fn check_edge(&self, location: Location, bb: BasicBlock, edge_kind: EdgeKind) {
+        if bb == START_BLOCK {
+            self.fail(location, "start block must not have predecessors")
+        }
         if let Some(bb) = self.body.basic_blocks().get(bb) {
             let src = self.body.basic_blocks().get(location.block).unwrap();
             match (src.is_cleanup, bb.is_cleanup, edge_kind) {