diff options
| author | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-11-09 09:07:13 -0800 |
|---|---|---|
| committer | Dylan MacKenzie <ecstaticmorse@gmail.com> | 2019-11-13 10:44:14 -0800 |
| commit | 70aa781c2d8f4ebe0e826d2cdeb8fcd371676a88 (patch) | |
| tree | 6eec0fd1ef82bfde511837202893c68730118d94 /src | |
| parent | 0123cbdc31a994033cffd505a758beba20709de0 (diff) | |
| download | rust-70aa781c2d8f4ebe0e826d2cdeb8fcd371676a88.tar.gz rust-70aa781c2d8f4ebe0e826d2cdeb8fcd371676a88.zip | |
Change control flow error to delay span bug
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/transform/check_consts/validation.rs | 9 | ||||
| -rw-r--r-- | src/librustc_mir/transform/qualify_consts.rs | 15 | ||||
| -rw-r--r-- | src/librustc_passes/check_const.rs | 9 |
3 files changed, 25 insertions, 8 deletions
diff --git a/src/librustc_mir/transform/check_consts/validation.rs b/src/librustc_mir/transform/check_consts/validation.rs index 244d434a51e..88f16299dc0 100644 --- a/src/librustc_mir/transform/check_consts/validation.rs +++ b/src/librustc_mir/transform/check_consts/validation.rs @@ -461,7 +461,14 @@ impl Visitor<'tcx> for Validator<'_, 'mir, 'tcx> { self.super_statement(statement, location); } StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _) => { - self.check_op(ops::IfOrMatch); + // FIXME: make this the `emit_error` impl of `ops::IfOrMatch` once the const + // checker is no longer run in compatability mode. + if !self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you { + self.tcx.sess.delay_span_bug( + self.span, + "complex control flow is forbidden in a const context", + ); + } } // FIXME(eddyb) should these really do nothing? StatementKind::FakeRead(..) | diff --git a/src/librustc_mir/transform/qualify_consts.rs b/src/librustc_mir/transform/qualify_consts.rs index 39720af4cb5..255e71db89d 100644 --- a/src/librustc_mir/transform/qualify_consts.rs +++ b/src/librustc_mir/transform/qualify_consts.rs @@ -723,8 +723,12 @@ impl<'a, 'tcx> Checker<'a, 'tcx> { bb = target; } _ => { - self.not_const(ops::Loop); - validator.check_op(ops::Loop); + if !self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you { + self.tcx.sess.delay_span_bug( + self.span, + "complex control flow is forbidden in a const context", + ); + } break; } } @@ -1253,7 +1257,12 @@ impl<'a, 'tcx> Visitor<'tcx> for Checker<'a, 'tcx> { self.super_statement(statement, location); } StatementKind::FakeRead(FakeReadCause::ForMatchedPlace, _) => { - self.not_const(ops::IfOrMatch); + if !self.tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you { + self.tcx.sess.delay_span_bug( + self.span, + "complex control flow is forbidden in a const context", + ); + } } // FIXME(eddyb) should these really do nothing? StatementKind::FakeRead(..) | diff --git a/src/librustc_passes/check_const.rs b/src/librustc_passes/check_const.rs index ff0de4a73b7..3263ee512a9 100644 --- a/src/librustc_passes/check_const.rs +++ b/src/librustc_passes/check_const.rs @@ -60,10 +60,6 @@ impl fmt::Display for ConstKind { } fn check_mod_const_bodies(tcx: TyCtxt<'_>, module_def_id: DefId) { - if tcx.sess.opts.debugging_opts.unleash_the_miri_inside_of_you { - return; - } - let mut vis = CheckConstVisitor::new(tcx); tcx.hir().visit_item_likes_in_module(module_def_id, &mut vis.as_deep_visitor()); } @@ -93,6 +89,11 @@ impl<'tcx> CheckConstVisitor<'tcx> { /// Emits an error when an unsupported expression is found in a const context. fn const_check_violated(&self, bad_op: &str, span: Span) { + if self.sess.opts.debugging_opts.unleash_the_miri_inside_of_you { + self.sess.span_warn(span, "skipping const checks"); + return; + } + let const_kind = self.const_kind .expect("`const_check_violated` may only be called inside a const context"); |
