Auto merge of #2914 - RalfJung:unchecked_shl, r=RalfJung
add unchecked_shl test https://github.com/rust-lang/rust/pull/112238 made me realize that we have a test for add,sub,mul,shr but not shl. Add the missing test. Also name the existing tests more consistently.
This commit is contained in:
commit
df4b808db4
8
src/tools/miri/tests/fail/intrinsics/unchecked_shl.rs
Normal file
8
src/tools/miri/tests/fail/intrinsics/unchecked_shl.rs
Normal file
@ -0,0 +1,8 @@
|
||||
#![feature(unchecked_math)]
|
||||
|
||||
fn main() {
|
||||
unsafe {
|
||||
let _n = 1i8.unchecked_shl(8);
|
||||
//~^ ERROR: overflowing shift by 8 in `unchecked_shl`
|
||||
}
|
||||
}
|
15
src/tools/miri/tests/fail/intrinsics/unchecked_shl.stderr
Normal file
15
src/tools/miri/tests/fail/intrinsics/unchecked_shl.stderr
Normal file
@ -0,0 +1,15 @@
|
||||
error: Undefined Behavior: overflowing shift by 8 in `unchecked_shl`
|
||||
--> $DIR/unchecked_shl.rs:LL:CC
|
||||
|
|
||||
LL | let _n = 1i8.unchecked_shl(8);
|
||||
| ^^^^^^^^^^^^^^^^^^^^ overflowing shift by 8 in `unchecked_shl`
|
||||
|
|
||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||
= note: BACKTRACE:
|
||||
= note: inside `main` at $DIR/unchecked_shl.rs:LL:CC
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
||||
error: aborting due to previous error
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: Undefined Behavior: overflowing shift by 64 in `unchecked_shr`
|
||||
--> $DIR/overflowing-unchecked-rsh.rs:LL:CC
|
||||
--> $DIR/unchecked_shr.rs:LL:CC
|
||||
|
|
||||
LL | let _n = 1i64.unchecked_shr(64);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^ overflowing shift by 64 in `unchecked_shr`
|
||||
@ -7,7 +7,7 @@ LL | let _n = 1i64.unchecked_shr(64);
|
||||
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
|
||||
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
|
||||
= note: BACKTRACE:
|
||||
= note: inside `main` at $DIR/overflowing-unchecked-rsh.rs:LL:CC
|
||||
= note: inside `main` at $DIR/unchecked_shr.rs:LL:CC
|
||||
|
||||
note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
|
||||
|
Loading…
x
Reference in New Issue
Block a user