Report precondition violation for <usize as SliceIndex>::get_unchecked in const-eval - #161616
Conversation
|
r? @wesleywiser rustbot has assigned @wesleywiser. Use Why was this reviewer chosen?The reviewer was selected based on:
|
<usize as SliceIndex>::get_unchecked in const-eval<usize as SliceIndex>::get_unchecked in const-eval
|
Any special-casing of Miri in the standard library requires review. cc @rust-lang/miri |
|
@bors squash |
This comment has been minimized.
This comment has been minimized.
…ed` in const-eval * Add a test for the diagnostics on `<usize as SliceIndex>::get_unchecked` in const-eval * Report a precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval The precondition check was gated on `check_language_ub`, which is disabled in const-eval and Miri, on the grounds that the `assume` below it is language UB that the interpreter will catch anyway. It does catch it, but only as "`assume` called with `false`", which says nothing about what the caller did wrong. This commit instead gates the check on `check_library_ub`, matching `get_unchecked_mut`, so that the interpreter reports the violated precondition. * fixup! Report a precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval * tweak comment Co-authored-by: Ralf Jung <post@ralfj.de>
|
🔨 4 commits were squashed into 3974528. |
2a40480 to
3974528
Compare
|
Makes sense, thanks :) |
…precondition-const-eval, r=RalfJung Report precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval The precondition check was gated on `check_language_ub`, which is disabled in const-eval and Miri, on the grounds that the `assume` below it is language UB that the interpreter will catch anyway. It does catch it, but only as "`assume` called with `false`", which says nothing about what the caller did wrong. This PR instead gates the check on `check_library_ub`, matching `get_unchecked_mut`, so that the interpreter reports the violated precondition. Fixes rust-lang#161611
Rollup of 14 pull requests Successful merges: - #162324 (miri subtree update) - #162170 (bootstrap: use target's LLVM libdir when cross-compiling) - #158312 (Adds support for AArch64 SVE to inline assembly) - #159792 (A more readable debug map for IndexMaps) - #160745 (make closures act like MaybeDangling) - #161263 (break rustc_expand-rustc_middle dependency) - #161895 (std::sys::pal::sgx: fix mismatched alloc/free alignment) - #161940 (Promote `wasm32-wasip3` to a tier 2 target) - #161397 (coverage: Tidy tests and add some new ones) - #161616 (Report precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval) - #162248 (Add regression test for unsized const parameter default ICE) - #162250 (Fix hashing of span end columns in incremental compilation) - #162265 (cargotest: add lockfiles) - #162318 (bootstrap: Fix broken path for `./x doc compiler/rustc --open`)
Rollup merge of #161616 - bardiharborow:get-unchecked-index-precondition-const-eval, r=RalfJung Report precondition violation for `<usize as SliceIndex>::get_unchecked` in const-eval The precondition check was gated on `check_language_ub`, which is disabled in const-eval and Miri, on the grounds that the `assume` below it is language UB that the interpreter will catch anyway. It does catch it, but only as "`assume` called with `false`", which says nothing about what the caller did wrong. This PR instead gates the check on `check_library_ub`, matching `get_unchecked_mut`, so that the interpreter reports the violated precondition. Fixes #161611
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (bee0ce4): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)Results (secondary -0.3%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesThis perf run didn't have relevant results for this metric. Binary sizeResults (primary 0.0%, secondary 0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: missing data |
The precondition check was gated on
check_language_ub, which is disabled in const-eval and Miri, on the grounds that theassumebelow it is language UB that the interpreter will catch anyway. It does catch it, but only as "assumecalled withfalse", which says nothing about what the caller did wrong.This PR instead gates the check on
check_library_ub, matchingget_unchecked_mut, so that the interpreter reports the violated precondition.Fixes #161611
@rustbot label +A-const-eval +A-diagnostics +A-slice +T-libs +requires-nightly