Change control flow error to delay span bug
This commit is contained in:
parent
0123cbdc31
commit
70aa781c2d
3 changed files with 25 additions and 8 deletions
|
|
@ -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(..) |
|
||||
|
|
|
|||
|
|
@ -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(..) |
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue