Rollup merge of #53991 - TimDiekmann:fix-unchecked-intrinsics, r=oli-obk
Add unchecked_shl/shr check for intrinsics to fix miri's test suit r? @RalfJung cc @oli-obk #53697 broke miri's test suite as described in [this comment](https://github.com/rust-lang/rust/pull/53697#issuecomment-419034668). This PR adds test for the `unchecked_shr/shl` for the intrinsics.
This commit is contained in:
commit
dcca8e86b1
3 changed files with 59 additions and 4 deletions
21
src/test/ui/consts/const-int-unchecked.rs
Normal file
21
src/test/ui/consts/const-int-unchecked.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
|
||||
// file at the top-level directory of this distribution and at
|
||||
// http://rust-lang.org/COPYRIGHT.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
#![feature(core_intrinsics)]
|
||||
|
||||
use std::intrinsics;
|
||||
|
||||
const SHR: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) };
|
||||
//^~ ERROR: Overflowing shift by 8 in unchecked_shr
|
||||
const SHL: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) };
|
||||
//^~ ERROR: Overflowing shift by 8 in unchecked_shl
|
||||
|
||||
fn main() {
|
||||
}
|
||||
20
src/test/ui/consts/const-int-unchecked.stderr
Normal file
20
src/test/ui/consts/const-int-unchecked.stderr
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
error: this constant cannot be used
|
||||
--> $DIR/const-int-unchecked.rs:15:1
|
||||
|
|
||||
LL | const SHR: u8 = unsafe { intrinsics::unchecked_shr(5_u8, 8) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^
|
||||
| |
|
||||
| Overflowing shift by 8 in unchecked_shr
|
||||
|
|
||||
= note: #[deny(const_err)] on by default
|
||||
|
||||
error: this constant cannot be used
|
||||
--> $DIR/const-int-unchecked.rs:17:1
|
||||
|
|
||||
LL | const SHL: u8 = unsafe { intrinsics::unchecked_shl(5_u8, 8) };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------------^^^
|
||||
| |
|
||||
| Overflowing shift by 8 in unchecked_shl
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue