Repository navigation
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
With the Miri engine now having support for properly executing panics, a panicking program does not really constitute an "interpreter error" any more. So we should get rid of the InterpError::Panic variant.
- We'll need to decide what else to do with the
throw_panic!that still exist. This one I think should bethrow_ub!instead; same for the "division/remainder by zero" in this file. With well-formed MIR I think those are all unreachable, but I see no harm in letting Miri also support some "reasonable" MIR that rustc would never emit (such as omitting the bounds check on an array access, or the div-by-zero check). Overflowing pointer arithmetic should also be UB I think. - ConstEval should probably format an error message directly when a panic occurs (here or in the new
assert_panichook added by Miri engine: proper support forAssertMIR terminators #66874). This could be propagated outwards via a newMachineError(String)variant ofInterpError, if nothing else fits. - I am not sure what ConstProp should do. The
throw_panic!mentioned above are, I think, currently actually hit by ConstProp -- but maybe those same errors can be better shown by determining that the condition of anAssertterminator is constant, and indeed that might explain why we currently sometimes have duplicate error messages. It also contains athrow_panic!here.
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)C-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Activity
wesleywiser commentedon Nov 30, 2019
Unless I'm not understanding what you're saying, that's exactly how it currently works in ConstProp:
rust/src/librustc_mir/transform/const_prop.rs
Lines 817 to 822 in d8bdb3f
RalfJung commentedon Dec 1, 2019
Yeah I think that is what I imagined. So I will start by experimenting with replacing the
throw_panic!that we have withthrow_ub!.RalfJung commentedon Dec 1, 2019
PR opened at #66927.
RalfJung commentedon Dec 1, 2019
Turns out that assumption is wrong: the MIR of promoteds actually is not well-formed in this sense; it can contain unchecked array/slice accesses.
Rollup merge of rust-lang#66926 - RalfJung:miri-stop, r=oli-obk
Rollup merge of rust-lang#66927 - RalfJung:engines-dont-panic, r=oli-obk
Rollup merge of rust-lang#66927 - RalfJung:engines-dont-panic, r=oli-obk
Auto merge of #68969 - RalfJung:dont-panic, r=oli-obk