From a4b7ed7a42c716ab9f05e351f003d589124fd55d Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:58 +0200 Subject: Adding upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/intrinsics/auxiliary/cci_intrinsic.rs | 14 - .../intrinsics/bad-intrinsic-monomorphization.rs | 32 -- .../bad-intrinsic-monomorphization.stderr | 21 -- .../intrinsics/const-eval-select-backtrace-std.rs | 7 - .../const-eval-select-backtrace-std.run.stderr | 2 - .../ui/intrinsics/const-eval-select-backtrace.rs | 19 -- .../const-eval-select-backtrace.run.stderr | 2 - src/test/ui/intrinsics/const-eval-select-bad.rs | 46 --- .../ui/intrinsics/const-eval-select-bad.stderr | 113 ------ .../ui/intrinsics/const-eval-select-stability.rs | 21 -- .../intrinsics/const-eval-select-stability.stderr | 10 - src/test/ui/intrinsics/const-eval-select-x86_64.rs | 40 --- src/test/ui/intrinsics/const-eval-select.rs | 27 -- src/test/ui/intrinsics/intrinsic-alignment.rs | 67 ---- src/test/ui/intrinsics/intrinsic-assume.rs | 17 - src/test/ui/intrinsics/intrinsic-atomics-cc.rs | 12 - src/test/ui/intrinsics/intrinsic-atomics.rs | 102 ------ src/test/ui/intrinsics/intrinsic-nearby.rs | 11 - .../intrinsics/intrinsic-raw_eq-const-padding.rs | 10 - .../intrinsic-raw_eq-const-padding.stderr | 9 - src/test/ui/intrinsics/intrinsic-raw_eq-const.rs | 26 -- src/test/ui/intrinsics/intrinsic-unreachable.rs | 17 - src/test/ui/intrinsics/intrinsic-volatile.rs | 44 --- src/test/ui/intrinsics/intrinsics-integer.rs | 177 ---------- src/test/ui/intrinsics/intrinsics-math.rs | 60 ---- src/test/ui/intrinsics/issue-28575.mir.stderr | 11 - src/test/ui/intrinsics/issue-28575.rs | 12 - src/test/ui/intrinsics/issue-28575.thir.stderr | 11 - .../ui/intrinsics/issue-84297-reifying-copy.rs | 9 - src/test/ui/intrinsics/non-integer-atomic.rs | 92 ----- src/test/ui/intrinsics/non-integer-atomic.stderr | 99 ------ .../ui/intrinsics/panic-uninitialized-zeroed.rs | 377 --------------------- src/test/ui/intrinsics/safe-intrinsic-mismatch.rs | 11 - .../ui/intrinsics/safe-intrinsic-mismatch.stderr | 14 - .../ui/intrinsics/unchecked_math_unsafe.mir.stderr | 27 -- src/test/ui/intrinsics/unchecked_math_unsafe.rs | 11 - .../intrinsics/unchecked_math_unsafe.thir.stderr | 27 -- src/test/ui/intrinsics/unchecked_math_unstable.rs | 8 - .../ui/intrinsics/unchecked_math_unstable.stderr | 27 -- 39 files changed, 1642 deletions(-) delete mode 100644 src/test/ui/intrinsics/auxiliary/cci_intrinsic.rs delete mode 100644 src/test/ui/intrinsics/bad-intrinsic-monomorphization.rs delete mode 100644 src/test/ui/intrinsics/bad-intrinsic-monomorphization.stderr delete mode 100644 src/test/ui/intrinsics/const-eval-select-backtrace-std.rs delete mode 100644 src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr delete mode 100644 src/test/ui/intrinsics/const-eval-select-backtrace.rs delete mode 100644 src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr delete mode 100644 src/test/ui/intrinsics/const-eval-select-bad.rs delete mode 100644 src/test/ui/intrinsics/const-eval-select-bad.stderr delete mode 100644 src/test/ui/intrinsics/const-eval-select-stability.rs delete mode 100644 src/test/ui/intrinsics/const-eval-select-stability.stderr delete mode 100644 src/test/ui/intrinsics/const-eval-select-x86_64.rs delete mode 100644 src/test/ui/intrinsics/const-eval-select.rs delete mode 100644 src/test/ui/intrinsics/intrinsic-alignment.rs delete mode 100644 src/test/ui/intrinsics/intrinsic-assume.rs delete mode 100644 src/test/ui/intrinsics/intrinsic-atomics-cc.rs delete mode 100644 src/test/ui/intrinsics/intrinsic-atomics.rs delete mode 100644 src/test/ui/intrinsics/intrinsic-nearby.rs delete mode 100644 src/test/ui/intrinsics/intrinsic-raw_eq-const-padding.rs delete mode 100644 src/test/ui/intrinsics/intrinsic-raw_eq-const-padding.stderr delete mode 100644 src/test/ui/intrinsics/intrinsic-raw_eq-const.rs delete mode 100644 src/test/ui/intrinsics/intrinsic-unreachable.rs delete mode 100644 src/test/ui/intrinsics/intrinsic-volatile.rs delete mode 100644 src/test/ui/intrinsics/intrinsics-integer.rs delete mode 100644 src/test/ui/intrinsics/intrinsics-math.rs delete mode 100644 src/test/ui/intrinsics/issue-28575.mir.stderr delete mode 100644 src/test/ui/intrinsics/issue-28575.rs delete mode 100644 src/test/ui/intrinsics/issue-28575.thir.stderr delete mode 100644 src/test/ui/intrinsics/issue-84297-reifying-copy.rs delete mode 100644 src/test/ui/intrinsics/non-integer-atomic.rs delete mode 100644 src/test/ui/intrinsics/non-integer-atomic.stderr delete mode 100644 src/test/ui/intrinsics/panic-uninitialized-zeroed.rs delete mode 100644 src/test/ui/intrinsics/safe-intrinsic-mismatch.rs delete mode 100644 src/test/ui/intrinsics/safe-intrinsic-mismatch.stderr delete mode 100644 src/test/ui/intrinsics/unchecked_math_unsafe.mir.stderr delete mode 100644 src/test/ui/intrinsics/unchecked_math_unsafe.rs delete mode 100644 src/test/ui/intrinsics/unchecked_math_unsafe.thir.stderr delete mode 100644 src/test/ui/intrinsics/unchecked_math_unstable.rs delete mode 100644 src/test/ui/intrinsics/unchecked_math_unstable.stderr (limited to 'src/test/ui/intrinsics') diff --git a/src/test/ui/intrinsics/auxiliary/cci_intrinsic.rs b/src/test/ui/intrinsics/auxiliary/cci_intrinsic.rs deleted file mode 100644 index f3b9d569c..000000000 --- a/src/test/ui/intrinsics/auxiliary/cci_intrinsic.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(intrinsics)] - -pub mod rusti { - extern "rust-intrinsic" { - pub fn atomic_xchg_seqcst(dst: *mut T, src: T) -> T; - } -} - -#[inline(always)] -pub fn atomic_xchg_seqcst(dst: *mut isize, src: isize) -> isize { - unsafe { - rusti::atomic_xchg_seqcst(dst, src) - } -} diff --git a/src/test/ui/intrinsics/bad-intrinsic-monomorphization.rs b/src/test/ui/intrinsics/bad-intrinsic-monomorphization.rs deleted file mode 100644 index f36a5f1ac..000000000 --- a/src/test/ui/intrinsics/bad-intrinsic-monomorphization.rs +++ /dev/null @@ -1,32 +0,0 @@ -// build-fail - -#![feature(repr_simd, platform_intrinsics, core_intrinsics)] -#![allow(warnings)] -#![crate_type = "rlib"] - -// Bad monomorphizations could previously cause LLVM asserts even though the -// error was caught in the compiler. - -extern "platform-intrinsic" { - fn simd_add(x: T, y: T) -> T; -} - -use std::intrinsics; - -#[derive(Copy, Clone)] -pub struct Foo(i64); - -pub fn test_cttz(v: Foo) -> Foo { - intrinsics::cttz(v) - //~^ ERROR `cttz` intrinsic: expected basic integer type, found `Foo` -} - -pub unsafe fn test_fadd_fast(a: Foo, b: Foo) -> Foo { - intrinsics::fadd_fast(a, b) - //~^ ERROR `fadd_fast` intrinsic: expected basic float type, found `Foo` -} - -pub unsafe fn test_simd_add(a: Foo, b: Foo) -> Foo { - simd_add(a, b) - //~^ ERROR `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo` -} diff --git a/src/test/ui/intrinsics/bad-intrinsic-monomorphization.stderr b/src/test/ui/intrinsics/bad-intrinsic-monomorphization.stderr deleted file mode 100644 index c070f0181..000000000 --- a/src/test/ui/intrinsics/bad-intrinsic-monomorphization.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error[E0511]: invalid monomorphization of `cttz` intrinsic: expected basic integer type, found `Foo` - --> $DIR/bad-intrinsic-monomorphization.rs:20:5 - | -LL | intrinsics::cttz(v) - | ^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `fadd_fast` intrinsic: expected basic float type, found `Foo` - --> $DIR/bad-intrinsic-monomorphization.rs:25:5 - | -LL | intrinsics::fadd_fast(a, b) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `Foo` - --> $DIR/bad-intrinsic-monomorphization.rs:30:5 - | -LL | simd_add(a, b) - | ^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs b/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs deleted file mode 100644 index 1164a3a5b..000000000 --- a/src/test/ui/intrinsics/const-eval-select-backtrace-std.rs +++ /dev/null @@ -1,7 +0,0 @@ -// See issue #100696. -// run-fail -// check-run-results -// exec-env:RUST_BACKTRACE=0 -fn main() { - &""[1..]; -} diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr b/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr deleted file mode 100644 index 463cd52c5..000000000 --- a/src/test/ui/intrinsics/const-eval-select-backtrace-std.run.stderr +++ /dev/null @@ -1,2 +0,0 @@ -thread 'main' panicked at 'byte index 1 is out of bounds of ``', $DIR/const-eval-select-backtrace-std.rs:6:6 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace.rs b/src/test/ui/intrinsics/const-eval-select-backtrace.rs deleted file mode 100644 index ef1c7c419..000000000 --- a/src/test/ui/intrinsics/const-eval-select-backtrace.rs +++ /dev/null @@ -1,19 +0,0 @@ -#![feature(core_intrinsics)] -// See issue #100696. -// run-fail -// check-run-results -// exec-env:RUST_BACKTRACE=0 - -#[track_caller] -fn uhoh() { - panic!("Aaah!") -} - -const fn c() {} - -fn main() { - // safety: this is unsound and just used to test - unsafe { - std::intrinsics::const_eval_select((), c, uhoh); - } -} diff --git a/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr b/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr deleted file mode 100644 index 54e28db5e..000000000 --- a/src/test/ui/intrinsics/const-eval-select-backtrace.run.stderr +++ /dev/null @@ -1,2 +0,0 @@ -thread 'main' panicked at 'Aaah!', $DIR/const-eval-select-backtrace.rs:17:9 -note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/src/test/ui/intrinsics/const-eval-select-bad.rs b/src/test/ui/intrinsics/const-eval-select-bad.rs deleted file mode 100644 index fa14efad7..000000000 --- a/src/test/ui/intrinsics/const-eval-select-bad.rs +++ /dev/null @@ -1,46 +0,0 @@ -#![feature(const_eval_select)] -#![feature(core_intrinsics)] - -use std::intrinsics::const_eval_select; - -const fn not_fn_items() { - const_eval_select((), || {}, || {}); - //~^ ERROR this argument must be a function item - //~| ERROR this argument must be a function item - const_eval_select((), 42, 0xDEADBEEF); - //~^ ERROR expected a `FnOnce<()>` closure - //~| ERROR expected a `FnOnce<()>` closure - //~| ERROR this argument must be a function item - //~| ERROR this argument must be a function item -} - -const fn foo(n: i32) -> i32 { - n -} - -fn bar(n: i32) -> bool { - assert_eq!(n, 0, "{} must be equal to {}", n, 0); - n == 0 -} - -fn baz(n: bool) -> i32 { - assert!(n, "{} must be true", n); - n as i32 -} - -const fn return_ty_mismatch() { - const_eval_select((1,), foo, bar); - //~^ ERROR expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it returns `bool` -} - -const fn args_ty_mismatch() { - const_eval_select((true,), foo, baz); - //~^ ERROR type mismatch -} - -const fn non_const_fn() { - const_eval_select((1,), bar, bar); - //~^ ERROR this argument must be a `const fn` -} - -fn main() {} diff --git a/src/test/ui/intrinsics/const-eval-select-bad.stderr b/src/test/ui/intrinsics/const-eval-select-bad.stderr deleted file mode 100644 index 3720528ad..000000000 --- a/src/test/ui/intrinsics/const-eval-select-bad.stderr +++ /dev/null @@ -1,113 +0,0 @@ -error: this argument must be a function item - --> $DIR/const-eval-select-bad.rs:7:27 - | -LL | const_eval_select((), || {}, || {}); - | ^^^^^ - | - = note: expected a function item, found [closure@$DIR/const-eval-select-bad.rs:7:27: 7:29] - = help: consult the documentation on `const_eval_select` for more information - -error: this argument must be a function item - --> $DIR/const-eval-select-bad.rs:7:34 - | -LL | const_eval_select((), || {}, || {}); - | ^^^^^ - | - = note: expected a function item, found [closure@$DIR/const-eval-select-bad.rs:7:34: 7:36] - = help: consult the documentation on `const_eval_select` for more information - -error: this argument must be a function item - --> $DIR/const-eval-select-bad.rs:10:27 - | -LL | const_eval_select((), 42, 0xDEADBEEF); - | ^^ - | - = note: expected a function item, found {integer} - = help: consult the documentation on `const_eval_select` for more information - -error[E0277]: expected a `FnOnce<()>` closure, found `{integer}` - --> $DIR/const-eval-select-bad.rs:10:27 - | -LL | const_eval_select((), 42, 0xDEADBEEF); - | ----------------- ^^ expected an `FnOnce<()>` closure, found `{integer}` - | | - | required by a bound introduced by this call - | - = help: the trait `FnOnce<()>` is not implemented for `{integer}` - = note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }` -note: required by a bound in `const_eval_select` - --> $SRC_DIR/core/src/intrinsics.rs:LL:COL - | -LL | F: FnOnce; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select` - -error: this argument must be a function item - --> $DIR/const-eval-select-bad.rs:10:31 - | -LL | const_eval_select((), 42, 0xDEADBEEF); - | ^^^^^^^^^^ - | - = note: expected a function item, found {integer} - = help: consult the documentation on `const_eval_select` for more information - -error[E0277]: expected a `FnOnce<()>` closure, found `{integer}` - --> $DIR/const-eval-select-bad.rs:10:31 - | -LL | const_eval_select((), 42, 0xDEADBEEF); - | ----------------- ^^^^^^^^^^ expected an `FnOnce<()>` closure, found `{integer}` - | | - | required by a bound introduced by this call - | - = help: the trait `FnOnce<()>` is not implemented for `{integer}` - = note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }` -note: required by a bound in `const_eval_select` - --> $SRC_DIR/core/src/intrinsics.rs:LL:COL - | -LL | G: FnOnce, - | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select` - -error[E0271]: expected `fn(i32) -> bool {bar}` to be a fn item that returns `i32`, but it returns `bool` - --> $DIR/const-eval-select-bad.rs:32:34 - | -LL | const_eval_select((1,), foo, bar); - | ----------------- ^^^ expected `i32`, found `bool` - | | - | required by a bound introduced by this call - | -note: required by a bound in `const_eval_select` - --> $SRC_DIR/core/src/intrinsics.rs:LL:COL - | -LL | G: FnOnce, - | ^^^^^^^^^^^^ required by this bound in `const_eval_select` - -error[E0631]: type mismatch in function arguments - --> $DIR/const-eval-select-bad.rs:37:32 - | -LL | const fn foo(n: i32) -> i32 { - | --------------------------- found signature defined here -... -LL | const_eval_select((true,), foo, baz); - | ----------------- ^^^ expected due to this - | | - | required by a bound introduced by this call - | - = note: expected function signature `fn(bool) -> _` - found function signature `fn(i32) -> _` -note: required by a bound in `const_eval_select` - --> $SRC_DIR/core/src/intrinsics.rs:LL:COL - | -LL | F: FnOnce; - | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `const_eval_select` - -error: this argument must be a `const fn` - --> $DIR/const-eval-select-bad.rs:42:29 - | -LL | const_eval_select((1,), bar, bar); - | ^^^ - | - = help: consult the documentation on `const_eval_select` for more information - -error: aborting due to 9 previous errors - -Some errors have detailed explanations: E0271, E0277, E0631. -For more information about an error, try `rustc --explain E0271`. diff --git a/src/test/ui/intrinsics/const-eval-select-stability.rs b/src/test/ui/intrinsics/const-eval-select-stability.rs deleted file mode 100644 index f9554dece..000000000 --- a/src/test/ui/intrinsics/const-eval-select-stability.rs +++ /dev/null @@ -1,21 +0,0 @@ -#![feature(staged_api)] -#![feature(const_eval_select)] -#![feature(core_intrinsics)] -#![stable(since = "1.0", feature = "ui_test")] - -use std::intrinsics::const_eval_select; - -fn log() { - println!("HEY HEY HEY") -} - -const fn nothing(){} - -#[stable(since = "1.0", feature = "hey")] -#[rustc_const_stable(since = "1.0", feature = "const_hey")] -pub const unsafe fn hey() { - const_eval_select((), nothing, log); - //~^ ERROR `const_eval_select` is not yet stable as a const fn -} - -fn main() {} diff --git a/src/test/ui/intrinsics/const-eval-select-stability.stderr b/src/test/ui/intrinsics/const-eval-select-stability.stderr deleted file mode 100644 index 65b507b88..000000000 --- a/src/test/ui/intrinsics/const-eval-select-stability.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: `const_eval_select` is not yet stable as a const fn - --> $DIR/const-eval-select-stability.rs:17:5 - | -LL | const_eval_select((), nothing, log); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: const-stable functions can only call other const-stable functions - -error: aborting due to previous error - diff --git a/src/test/ui/intrinsics/const-eval-select-x86_64.rs b/src/test/ui/intrinsics/const-eval-select-x86_64.rs deleted file mode 100644 index f3924acf0..000000000 --- a/src/test/ui/intrinsics/const-eval-select-x86_64.rs +++ /dev/null @@ -1,40 +0,0 @@ -// run-pass -// only-x86_64 - -#![feature(const_eval_select)] -#![feature(core_intrinsics)] -use std::intrinsics::const_eval_select; -use std::arch::x86_64::*; -use std::mem::transmute; - -const fn eq_ct(x: [i32; 4], y: [i32; 4]) -> bool { - x[0] == y[0] && x[1] == y[1] && x[2] == y[2] && x[3] == y[3] -} - -fn eq_rt(x: [i32; 4], y: [i32; 4]) -> bool { - unsafe { - let x = _mm_loadu_si128(&x as *const _ as *const _); - let y = _mm_loadu_si128(&y as *const _ as *const _); - let r = _mm_cmpeq_epi32(x, y); - let r = _mm_movemask_ps(transmute(r) ); - r == 0b1111 - } -} - -const fn eq(x: [i32; 4], y: [i32; 4]) -> bool { - unsafe { - const_eval_select((x, y), eq_ct, eq_rt) - } -} - -fn main() { - const X: bool = eq([0, 1, 2, 3], [0, 1, 2, 3]); - assert_eq!(X, true); - let x = eq([0, 1, 2, 3], [0, 1, 2, 3]); - assert_eq!(x, true); - - const Y: bool = eq([0, 1, 2, 3], [0, 1, 3, 2]); - assert_eq!(Y, false); - let y = eq([0, 1, 2, 3], [0, 1, 3, 2]); - assert_eq!(y, false); -} diff --git a/src/test/ui/intrinsics/const-eval-select.rs b/src/test/ui/intrinsics/const-eval-select.rs deleted file mode 100644 index 9ff20d3fb..000000000 --- a/src/test/ui/intrinsics/const-eval-select.rs +++ /dev/null @@ -1,27 +0,0 @@ -// run-pass - -#![feature(const_eval_select)] -#![feature(core_intrinsics)] - -use std::intrinsics::const_eval_select; - -const fn yes() -> bool { - true -} - -fn no() -> bool { - false -} - -// not a sound use case; testing only -const fn is_const_eval() -> bool { - unsafe { const_eval_select((), yes, no) } -} - -fn main() { - const YES: bool = is_const_eval(); - let no = is_const_eval(); - - assert_eq!(true, YES); - assert_eq!(false, no); -} diff --git a/src/test/ui/intrinsics/intrinsic-alignment.rs b/src/test/ui/intrinsics/intrinsic-alignment.rs deleted file mode 100644 index c8b1ff1db..000000000 --- a/src/test/ui/intrinsics/intrinsic-alignment.rs +++ /dev/null @@ -1,67 +0,0 @@ -// run-pass -// ignore-wasm32-bare seems not important to test here - -#![feature(intrinsics)] - -mod rusti { - extern "rust-intrinsic" { - pub fn pref_align_of() -> usize; - #[rustc_safe_intrinsic] - pub fn min_align_of() -> usize; - } -} - -#[cfg(any(target_os = "android", - target_os = "dragonfly", - target_os = "emscripten", - target_os = "freebsd", - target_os = "fuchsia", - target_os = "illumos", - target_os = "linux", - target_os = "macos", - target_os = "netbsd", - target_os = "openbsd", - target_os = "solaris", - target_os = "vxworks"))] -mod m { - #[cfg(target_arch = "x86")] - pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::(), 8); - assert_eq!(::rusti::min_align_of::(), 4); - } - } - - #[cfg(not(target_arch = "x86"))] - pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::(), 8); - assert_eq!(::rusti::min_align_of::(), 8); - } - } -} - -#[cfg(target_env = "sgx")] -mod m { - #[cfg(target_arch = "x86_64")] - pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::(), 8); - assert_eq!(::rusti::min_align_of::(), 8); - } - } -} - -#[cfg(target_os = "windows")] -mod m { - pub fn main() { - unsafe { - assert_eq!(::rusti::pref_align_of::(), 8); - assert_eq!(::rusti::min_align_of::(), 8); - } - } -} - -fn main() { - m::main(); -} diff --git a/src/test/ui/intrinsics/intrinsic-assume.rs b/src/test/ui/intrinsics/intrinsic-assume.rs deleted file mode 100644 index 3c9d70cb5..000000000 --- a/src/test/ui/intrinsics/intrinsic-assume.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -#![feature(core_intrinsics)] - -use std::intrinsics::assume; - -unsafe fn f(x: i32) -> i32 { - assume(x == 34); - match x { - 34 => 42, - _ => 30 - } -} - -fn main() { - let x = unsafe { f(34) }; - assert_eq!(x, 42); -} diff --git a/src/test/ui/intrinsics/intrinsic-atomics-cc.rs b/src/test/ui/intrinsics/intrinsic-atomics-cc.rs deleted file mode 100644 index ce3fa7b0c..000000000 --- a/src/test/ui/intrinsics/intrinsic-atomics-cc.rs +++ /dev/null @@ -1,12 +0,0 @@ -// run-pass -// aux-build:cci_intrinsic.rs - - -extern crate cci_intrinsic; -use cci_intrinsic::atomic_xchg_seqcst; - -pub fn main() { - let mut x = 1; - atomic_xchg_seqcst(&mut x, 5); - assert_eq!(x, 5); -} diff --git a/src/test/ui/intrinsics/intrinsic-atomics.rs b/src/test/ui/intrinsics/intrinsic-atomics.rs deleted file mode 100644 index b17f4347b..000000000 --- a/src/test/ui/intrinsics/intrinsic-atomics.rs +++ /dev/null @@ -1,102 +0,0 @@ -// run-pass -#![feature(intrinsics)] - -mod rusti { - extern "rust-intrinsic" { - pub fn atomic_cxchg_seqcst_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); - pub fn atomic_cxchg_acquire_acquire(dst: *mut T, old: T, src: T) -> (T, bool); - pub fn atomic_cxchg_release_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); - - pub fn atomic_cxchgweak_seqcst_seqcst(dst: *mut T, old: T, src: T) -> (T, bool); - pub fn atomic_cxchgweak_acquire_acquire(dst: *mut T, old: T, src: T) -> (T, bool); - pub fn atomic_cxchgweak_release_relaxed(dst: *mut T, old: T, src: T) -> (T, bool); - - pub fn atomic_load_seqcst(src: *const T) -> T; - pub fn atomic_load_acquire(src: *const T) -> T; - - pub fn atomic_store_seqcst(dst: *mut T, val: T); - pub fn atomic_store_release(dst: *mut T, val: T); - - pub fn atomic_xchg_seqcst(dst: *mut T, src: T) -> T; - pub fn atomic_xchg_acquire(dst: *mut T, src: T) -> T; - pub fn atomic_xchg_release(dst: *mut T, src: T) -> T; - - pub fn atomic_xadd_seqcst(dst: *mut T, src: T) -> T; - pub fn atomic_xadd_acquire(dst: *mut T, src: T) -> T; - pub fn atomic_xadd_release(dst: *mut T, src: T) -> T; - - pub fn atomic_xsub_seqcst(dst: *mut T, src: T) -> T; - pub fn atomic_xsub_acquire(dst: *mut T, src: T) -> T; - pub fn atomic_xsub_release(dst: *mut T, src: T) -> T; - } -} - -pub fn main() { - unsafe { - let mut x: Box<_> = Box::new(1); - - assert_eq!(rusti::atomic_load_seqcst(&*x), 1); - *x = 5; - assert_eq!(rusti::atomic_load_acquire(&*x), 5); - - rusti::atomic_store_seqcst(&mut *x,3); - assert_eq!(*x, 3); - rusti::atomic_store_release(&mut *x,1); - assert_eq!(*x, 1); - - assert_eq!(rusti::atomic_cxchg_seqcst_seqcst(&mut *x, 1, 2), (1, true)); - assert_eq!(*x, 2); - - assert_eq!(rusti::atomic_cxchg_acquire_acquire(&mut *x, 1, 3), (2, false)); - assert_eq!(*x, 2); - - assert_eq!(rusti::atomic_cxchg_release_relaxed(&mut *x, 2, 1), (2, true)); - assert_eq!(*x, 1); - - assert_eq!(rusti::atomic_xchg_seqcst(&mut *x, 0), 1); - assert_eq!(*x, 0); - - assert_eq!(rusti::atomic_xchg_acquire(&mut *x, 1), 0); - assert_eq!(*x, 1); - - assert_eq!(rusti::atomic_xchg_release(&mut *x, 0), 1); - assert_eq!(*x, 0); - - assert_eq!(rusti::atomic_xadd_seqcst(&mut *x, 1), 0); - assert_eq!(rusti::atomic_xadd_acquire(&mut *x, 1), 1); - assert_eq!(rusti::atomic_xadd_release(&mut *x, 1), 2); - assert_eq!(*x, 3); - - assert_eq!(rusti::atomic_xsub_seqcst(&mut *x, 1), 3); - assert_eq!(rusti::atomic_xsub_acquire(&mut *x, 1), 2); - assert_eq!(rusti::atomic_xsub_release(&mut *x, 1), 1); - assert_eq!(*x, 0); - - loop { - let res = rusti::atomic_cxchgweak_seqcst_seqcst(&mut *x, 0, 1); - assert_eq!(res.0, 0); - if res.1 { - break; - } - } - assert_eq!(*x, 1); - - loop { - let res = rusti::atomic_cxchgweak_acquire_acquire(&mut *x, 1, 2); - assert_eq!(res.0, 1); - if res.1 { - break; - } - } - assert_eq!(*x, 2); - - loop { - let res = rusti::atomic_cxchgweak_release_relaxed(&mut *x, 2, 3); - assert_eq!(res.0, 2); - if res.1 { - break; - } - } - assert_eq!(*x, 3); - } -} diff --git a/src/test/ui/intrinsics/intrinsic-nearby.rs b/src/test/ui/intrinsics/intrinsic-nearby.rs deleted file mode 100644 index 7b1d1eeaa..000000000 --- a/src/test/ui/intrinsics/intrinsic-nearby.rs +++ /dev/null @@ -1,11 +0,0 @@ -// run-pass -#![feature(core_intrinsics)] - -use std::intrinsics::*; - -fn main() { - unsafe { - assert_eq!(nearbyintf32(5.234f32), 5f32); - assert_eq!(nearbyintf64(6.777f64), 7f64); - } -} diff --git a/src/test/ui/intrinsics/intrinsic-raw_eq-const-padding.rs b/src/test/ui/intrinsics/intrinsic-raw_eq-const-padding.rs deleted file mode 100644 index a93d777d2..000000000 --- a/src/test/ui/intrinsics/intrinsic-raw_eq-const-padding.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(core_intrinsics)] -#![feature(const_intrinsic_raw_eq)] - -const BAD_RAW_EQ_CALL: bool = unsafe { - std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) -//~^ ERROR evaluation of constant value failed -}; - -pub fn main() { -} diff --git a/src/test/ui/intrinsics/intrinsic-raw_eq-const-padding.stderr b/src/test/ui/intrinsics/intrinsic-raw_eq-const-padding.stderr deleted file mode 100644 index 56d5a4857..000000000 --- a/src/test/ui/intrinsics/intrinsic-raw_eq-const-padding.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/intrinsic-raw_eq-const-padding.rs:5:5 - | -LL | std::intrinsics::raw_eq(&(1_u8, 2_u16), &(1_u8, 2_u16)) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ reading memory at alloc3[0x0..0x4], but memory is uninitialized at [0x1..0x2], and this operation requires initialized memory - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/src/test/ui/intrinsics/intrinsic-raw_eq-const.rs b/src/test/ui/intrinsics/intrinsic-raw_eq-const.rs deleted file mode 100644 index 32841f531..000000000 --- a/src/test/ui/intrinsics/intrinsic-raw_eq-const.rs +++ /dev/null @@ -1,26 +0,0 @@ -// run-pass - -#![feature(core_intrinsics)] -#![feature(const_intrinsic_raw_eq)] - -pub fn main() { - use std::intrinsics::raw_eq; - - const RAW_EQ_I32_TRUE: bool = unsafe { raw_eq(&42_i32, &42) }; - assert!(RAW_EQ_I32_TRUE); - - const RAW_EQ_I32_FALSE: bool = unsafe { raw_eq(&4_i32, &2) }; - assert!(!RAW_EQ_I32_FALSE); - - const RAW_EQ_CHAR_TRUE: bool = unsafe { raw_eq(&'a', &'a') }; - assert!(RAW_EQ_CHAR_TRUE); - - const RAW_EQ_CHAR_FALSE: bool = unsafe { raw_eq(&'a', &'A') }; - assert!(!RAW_EQ_CHAR_FALSE); - - const RAW_EQ_ARRAY_TRUE: bool = unsafe { raw_eq(&[13_u8, 42], &[13, 42]) }; - assert!(RAW_EQ_ARRAY_TRUE); - - const RAW_EQ_ARRAY_FALSE: bool = unsafe { raw_eq(&[13_u8, 42], &[42, 13]) }; - assert!(!RAW_EQ_ARRAY_FALSE); -} diff --git a/src/test/ui/intrinsics/intrinsic-unreachable.rs b/src/test/ui/intrinsics/intrinsic-unreachable.rs deleted file mode 100644 index da1a32d58..000000000 --- a/src/test/ui/intrinsics/intrinsic-unreachable.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -#![feature(core_intrinsics)] - -use std::intrinsics; - -// See also src/test/run-make/intrinsic-unreachable. - -unsafe fn f(x: usize) -> usize { - match x { - 17 => 23, - _ => intrinsics::unreachable(), - } -} - -fn main() { - assert_eq!(unsafe { f(17) }, 23); -} diff --git a/src/test/ui/intrinsics/intrinsic-volatile.rs b/src/test/ui/intrinsics/intrinsic-volatile.rs deleted file mode 100644 index 7b2c825a2..000000000 --- a/src/test/ui/intrinsics/intrinsic-volatile.rs +++ /dev/null @@ -1,44 +0,0 @@ -// run-pass - -#![feature(core_intrinsics)] - -use std::intrinsics::*; - -pub fn main() { - unsafe { - let mut x: Box = Box::new(0); - let mut y: Box = Box::new(0); - - // test volatile load - assert_eq!(volatile_load(&*x), 0); - *x = 1; - assert_eq!(volatile_load(&*x), 1); - - // test volatile store - volatile_store(&mut *x, 2); - assert_eq!(*x, 2); - - // test volatile copy memory - volatile_copy_memory(&mut *y, &*x, 1); - assert_eq!(*y, 2); - - // test volatile copy non-overlapping memory - *x = 3; - volatile_copy_nonoverlapping_memory(&mut *y, &*x, 1); - assert_eq!(*y, 3); - - // test volatile set memory - volatile_set_memory(&mut *x, 4, 1); - assert_eq!(*x, 4); - - // test unaligned volatile load - let arr: [u8; 3] = [1, 2, 3]; - let ptr = arr[1..].as_ptr() as *const u16; - assert_eq!(unaligned_volatile_load(ptr), u16::from_ne_bytes([arr[1], arr[2]])); - - // test unaligned volatile store - let ptr = arr[1..].as_ptr() as *mut u16; - unaligned_volatile_store(ptr, 0); - assert_eq!(arr, [1, 0, 0]); - } -} diff --git a/src/test/ui/intrinsics/intrinsics-integer.rs b/src/test/ui/intrinsics/intrinsics-integer.rs deleted file mode 100644 index 88bf42b68..000000000 --- a/src/test/ui/intrinsics/intrinsics-integer.rs +++ /dev/null @@ -1,177 +0,0 @@ -// run-pass - -#![feature(intrinsics)] -#![feature(rustc_attrs)] - -mod rusti { - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn ctpop(x: T) -> T; - #[rustc_safe_intrinsic] - pub fn ctlz(x: T) -> T; - pub fn ctlz_nonzero(x: T) -> T; - #[rustc_safe_intrinsic] - pub fn cttz(x: T) -> T; - pub fn cttz_nonzero(x: T) -> T; - #[rustc_safe_intrinsic] - pub fn bswap(x: T) -> T; - #[rustc_safe_intrinsic] - pub fn bitreverse(x: T) -> T; - } -} - -pub fn main() { - use rusti::*; - - assert_eq!(ctpop(0u8), 0); assert_eq!(ctpop(0i8), 0); - assert_eq!(ctpop(0u16), 0); assert_eq!(ctpop(0i16), 0); - assert_eq!(ctpop(0u32), 0); assert_eq!(ctpop(0i32), 0); - assert_eq!(ctpop(0u64), 0); assert_eq!(ctpop(0i64), 0); - assert_eq!(ctpop(0u128), 0); assert_eq!(ctpop(0i128), 0); - - assert_eq!(ctpop(1u8), 1); assert_eq!(ctpop(1i8), 1); - assert_eq!(ctpop(1u16), 1); assert_eq!(ctpop(1i16), 1); - assert_eq!(ctpop(1u32), 1); assert_eq!(ctpop(1i32), 1); - assert_eq!(ctpop(1u64), 1); assert_eq!(ctpop(1i64), 1); - assert_eq!(ctpop(1u128), 1); assert_eq!(ctpop(1i128), 1); - - assert_eq!(ctpop(10u8), 2); assert_eq!(ctpop(10i8), 2); - assert_eq!(ctpop(10u16), 2); assert_eq!(ctpop(10i16), 2); - assert_eq!(ctpop(10u32), 2); assert_eq!(ctpop(10i32), 2); - assert_eq!(ctpop(10u64), 2); assert_eq!(ctpop(10i64), 2); - assert_eq!(ctpop(10u128), 2); assert_eq!(ctpop(10i128), 2); - - assert_eq!(ctpop(100u8), 3); assert_eq!(ctpop(100i8), 3); - assert_eq!(ctpop(100u16), 3); assert_eq!(ctpop(100i16), 3); - assert_eq!(ctpop(100u32), 3); assert_eq!(ctpop(100i32), 3); - assert_eq!(ctpop(100u64), 3); assert_eq!(ctpop(100i64), 3); - assert_eq!(ctpop(100u128), 3); assert_eq!(ctpop(100i128), 3); - - assert_eq!(ctpop(-1i8 as u8), 8); assert_eq!(ctpop(-1i8), 8); - assert_eq!(ctpop(-1i16 as u16), 16); assert_eq!(ctpop(-1i16), 16); - assert_eq!(ctpop(-1i32 as u32), 32); assert_eq!(ctpop(-1i32), 32); - assert_eq!(ctpop(-1i64 as u64), 64); assert_eq!(ctpop(-1i64), 64); - assert_eq!(ctpop(-1i128 as u128), 128); assert_eq!(ctpop(-1i128), 128); - - assert_eq!(ctlz(0u8), 8); assert_eq!(ctlz(0i8), 8); - assert_eq!(ctlz(0u16), 16); assert_eq!(ctlz(0i16), 16); - assert_eq!(ctlz(0u32), 32); assert_eq!(ctlz(0i32), 32); - assert_eq!(ctlz(0u64), 64); assert_eq!(ctlz(0i64), 64); - assert_eq!(ctlz(0u128), 128); assert_eq!(ctlz(0i128), 128); - - assert_eq!(ctlz(1u8), 7); assert_eq!(ctlz(1i8), 7); - assert_eq!(ctlz(1u16), 15); assert_eq!(ctlz(1i16), 15); - assert_eq!(ctlz(1u32), 31); assert_eq!(ctlz(1i32), 31); - assert_eq!(ctlz(1u64), 63); assert_eq!(ctlz(1i64), 63); - assert_eq!(ctlz(1u128), 127); assert_eq!(ctlz(1i128), 127); - - assert_eq!(ctlz(10u8), 4); assert_eq!(ctlz(10i8), 4); - assert_eq!(ctlz(10u16), 12); assert_eq!(ctlz(10i16), 12); - assert_eq!(ctlz(10u32), 28); assert_eq!(ctlz(10i32), 28); - assert_eq!(ctlz(10u64), 60); assert_eq!(ctlz(10i64), 60); - assert_eq!(ctlz(10u128), 124); assert_eq!(ctlz(10i128), 124); - - assert_eq!(ctlz(100u8), 1); assert_eq!(ctlz(100i8), 1); - assert_eq!(ctlz(100u16), 9); assert_eq!(ctlz(100i16), 9); - assert_eq!(ctlz(100u32), 25); assert_eq!(ctlz(100i32), 25); - assert_eq!(ctlz(100u64), 57); assert_eq!(ctlz(100i64), 57); - assert_eq!(ctlz(100u128), 121); assert_eq!(ctlz(100i128), 121); - - unsafe { - assert_eq!(ctlz_nonzero(1u8), 7); assert_eq!(ctlz_nonzero(1i8), 7); - assert_eq!(ctlz_nonzero(1u16), 15); assert_eq!(ctlz_nonzero(1i16), 15); - assert_eq!(ctlz_nonzero(1u32), 31); assert_eq!(ctlz_nonzero(1i32), 31); - assert_eq!(ctlz_nonzero(1u64), 63); assert_eq!(ctlz_nonzero(1i64), 63); - assert_eq!(ctlz_nonzero(1u128), 127); assert_eq!(ctlz_nonzero(1i128), 127); - - assert_eq!(ctlz_nonzero(10u8), 4); assert_eq!(ctlz_nonzero(10i8), 4); - assert_eq!(ctlz_nonzero(10u16), 12); assert_eq!(ctlz_nonzero(10i16), 12); - assert_eq!(ctlz_nonzero(10u32), 28); assert_eq!(ctlz_nonzero(10i32), 28); - assert_eq!(ctlz_nonzero(10u64), 60); assert_eq!(ctlz_nonzero(10i64), 60); - assert_eq!(ctlz_nonzero(10u128), 124); assert_eq!(ctlz_nonzero(10i128), 124); - - assert_eq!(ctlz_nonzero(100u8), 1); assert_eq!(ctlz_nonzero(100i8), 1); - assert_eq!(ctlz_nonzero(100u16), 9); assert_eq!(ctlz_nonzero(100i16), 9); - assert_eq!(ctlz_nonzero(100u32), 25); assert_eq!(ctlz_nonzero(100i32), 25); - assert_eq!(ctlz_nonzero(100u64), 57); assert_eq!(ctlz_nonzero(100i64), 57); - assert_eq!(ctlz_nonzero(100u128), 121); assert_eq!(ctlz_nonzero(100i128), 121); - } - - assert_eq!(cttz(-1i8 as u8), 0); assert_eq!(cttz(-1i8), 0); - assert_eq!(cttz(-1i16 as u16), 0); assert_eq!(cttz(-1i16), 0); - assert_eq!(cttz(-1i32 as u32), 0); assert_eq!(cttz(-1i32), 0); - assert_eq!(cttz(-1i64 as u64), 0); assert_eq!(cttz(-1i64), 0); - assert_eq!(cttz(-1i128 as u128), 0); assert_eq!(cttz(-1i128), 0); - - assert_eq!(cttz(0u8), 8); assert_eq!(cttz(0i8), 8); - assert_eq!(cttz(0u16), 16); assert_eq!(cttz(0i16), 16); - assert_eq!(cttz(0u32), 32); assert_eq!(cttz(0i32), 32); - assert_eq!(cttz(0u64), 64); assert_eq!(cttz(0i64), 64); - assert_eq!(cttz(0u128), 128); assert_eq!(cttz(0i128), 128); - - assert_eq!(cttz(1u8), 0); assert_eq!(cttz(1i8), 0); - assert_eq!(cttz(1u16), 0); assert_eq!(cttz(1i16), 0); - assert_eq!(cttz(1u32), 0); assert_eq!(cttz(1i32), 0); - assert_eq!(cttz(1u64), 0); assert_eq!(cttz(1i64), 0); - assert_eq!(cttz(1u128), 0); assert_eq!(cttz(1i128), 0); - - assert_eq!(cttz(10u8), 1); assert_eq!(cttz(10i8), 1); - assert_eq!(cttz(10u16), 1); assert_eq!(cttz(10i16), 1); - assert_eq!(cttz(10u32), 1); assert_eq!(cttz(10i32), 1); - assert_eq!(cttz(10u64), 1); assert_eq!(cttz(10i64), 1); - assert_eq!(cttz(10u128), 1); assert_eq!(cttz(10i128), 1); - - assert_eq!(cttz(100u8), 2); assert_eq!(cttz(100i8), 2); - assert_eq!(cttz(100u16), 2); assert_eq!(cttz(100i16), 2); - assert_eq!(cttz(100u32), 2); assert_eq!(cttz(100i32), 2); - assert_eq!(cttz(100u64), 2); assert_eq!(cttz(100i64), 2); - assert_eq!(cttz(100u128), 2); assert_eq!(cttz(100i128), 2); - - unsafe { - assert_eq!(cttz_nonzero(-1i8 as u8), 0); assert_eq!(cttz_nonzero(-1i8), 0); - assert_eq!(cttz_nonzero(-1i16 as u16), 0); assert_eq!(cttz_nonzero(-1i16), 0); - assert_eq!(cttz_nonzero(-1i32 as u32), 0); assert_eq!(cttz_nonzero(-1i32), 0); - assert_eq!(cttz_nonzero(-1i64 as u64), 0); assert_eq!(cttz_nonzero(-1i64), 0); - assert_eq!(cttz_nonzero(-1i128 as u128), 0); assert_eq!(cttz_nonzero(-1i128), 0); - - assert_eq!(cttz_nonzero(1u8), 0); assert_eq!(cttz_nonzero(1i8), 0); - assert_eq!(cttz_nonzero(1u16), 0); assert_eq!(cttz_nonzero(1i16), 0); - assert_eq!(cttz_nonzero(1u32), 0); assert_eq!(cttz_nonzero(1i32), 0); - assert_eq!(cttz_nonzero(1u64), 0); assert_eq!(cttz_nonzero(1i64), 0); - assert_eq!(cttz_nonzero(1u128), 0); assert_eq!(cttz_nonzero(1i128), 0); - - assert_eq!(cttz_nonzero(10u8), 1); assert_eq!(cttz_nonzero(10i8), 1); - assert_eq!(cttz_nonzero(10u16), 1); assert_eq!(cttz_nonzero(10i16), 1); - assert_eq!(cttz_nonzero(10u32), 1); assert_eq!(cttz_nonzero(10i32), 1); - assert_eq!(cttz_nonzero(10u64), 1); assert_eq!(cttz_nonzero(10i64), 1); - assert_eq!(cttz_nonzero(10u128), 1); assert_eq!(cttz_nonzero(10i128), 1); - - assert_eq!(cttz_nonzero(100u8), 2); assert_eq!(cttz_nonzero(100i8), 2); - assert_eq!(cttz_nonzero(100u16), 2); assert_eq!(cttz_nonzero(100i16), 2); - assert_eq!(cttz_nonzero(100u32), 2); assert_eq!(cttz_nonzero(100i32), 2); - assert_eq!(cttz_nonzero(100u64), 2); assert_eq!(cttz_nonzero(100i64), 2); - assert_eq!(cttz_nonzero(100u128), 2); assert_eq!(cttz_nonzero(100i128), 2); - } - - assert_eq!(bswap(0x0Au8), 0x0A); // no-op - assert_eq!(bswap(0x0Ai8), 0x0A); // no-op - assert_eq!(bswap(0x0A0Bu16), 0x0B0A); - assert_eq!(bswap(0x0A0Bi16), 0x0B0A); - assert_eq!(bswap(0x0ABBCC0Du32), 0x0DCCBB0A); - assert_eq!(bswap(0x0ABBCC0Di32), 0x0DCCBB0A); - assert_eq!(bswap(0x0122334455667708u64), 0x0877665544332201); - assert_eq!(bswap(0x0122334455667708i64), 0x0877665544332201); - assert_eq!(bswap(0x0122334455667708u128), 0x08776655443322010000000000000000); - assert_eq!(bswap(0x0122334455667708i128), 0x08776655443322010000000000000000); - - assert_eq!(bitreverse(0x0Au8), 0x50); - assert_eq!(bitreverse(0x0Ai8), 0x50); - assert_eq!(bitreverse(0x0A0Cu16), 0x3050); - assert_eq!(bitreverse(0x0A0Ci16), 0x3050); - assert_eq!(bitreverse(0x0ABBCC0Eu32), 0x7033DD50); - assert_eq!(bitreverse(0x0ABBCC0Ei32), 0x7033DD50); - assert_eq!(bitreverse(0x0122334455667708u64), 0x10EE66AA22CC4480); - assert_eq!(bitreverse(0x0122334455667708i64), 0x10EE66AA22CC4480); - assert_eq!(bitreverse(0x0122334455667708u128), 0x10EE66AA22CC44800000000000000000); - assert_eq!(bitreverse(0x0122334455667708i128), 0x10EE66AA22CC44800000000000000000); -} diff --git a/src/test/ui/intrinsics/intrinsics-math.rs b/src/test/ui/intrinsics/intrinsics-math.rs deleted file mode 100644 index aea9fde69..000000000 --- a/src/test/ui/intrinsics/intrinsics-math.rs +++ /dev/null @@ -1,60 +0,0 @@ -// run-pass -// ignore-emscripten fma not implemented in emscripten - -macro_rules! assert_approx_eq { - ($a:expr, $b:expr) => ({ - let (a, b) = (&$a, &$b); - assert!((*a - *b).abs() < 1.0e-6, - "{} is not approximately equal to {}", *a, *b); - }) -} - -pub fn main() { - use std::f32; - use std::f64; - - assert_approx_eq!(64f32.sqrt(), 8f32); - assert_approx_eq!(64f64.sqrt(), 8f64); - - assert_approx_eq!(25f32.powi(-2), 0.0016f32); - assert_approx_eq!(23.2f64.powi(2), 538.24f64); - - assert_approx_eq!(0f32.sin(), 0f32); - assert_approx_eq!((f64::consts::PI / 2f64).sin(), 1f64); - - assert_approx_eq!(0f32.cos(), 1f32); - assert_approx_eq!((f64::consts::PI * 2f64).cos(), 1f64); - - assert_approx_eq!(25f32.powf(-2f32), 0.0016f32); - assert_approx_eq!(400f64.powf(0.5f64), 20f64); - - assert_approx_eq!((1f32.exp() - f32::consts::E).abs(), 0f32); - assert_approx_eq!(1f64.exp(), f64::consts::E); - - assert_approx_eq!(10f32.exp2(), 1024f32); - assert_approx_eq!(50f64.exp2(), 1125899906842624f64); - - assert_approx_eq!((f32::consts::E.ln() - 1f32).abs(), 0f32); - assert_approx_eq!(1f64.ln(), 0f64); - - assert_approx_eq!(10f32.log10(), 1f32); - assert_approx_eq!(f64::consts::E.log10(), f64::consts::LOG10_E); - - assert_approx_eq!(8f32.log2(), 3f32); - assert_approx_eq!(f64::consts::E.log2(), f64::consts::LOG2_E); - - assert_approx_eq!(1.0f32.mul_add(2.0f32, 5.0f32), 7.0f32); - assert_approx_eq!(0.0f64.mul_add(-2.0f64, f64::consts::E), f64::consts::E); - - assert_approx_eq!((-1.0f32).abs(), 1.0f32); - assert_approx_eq!(34.2f64.abs(), 34.2f64); - - assert_approx_eq!(3.8f32.floor(), 3.0f32); - assert_approx_eq!((-1.1f64).floor(), -2.0f64); - - assert_approx_eq!((-2.3f32).ceil(), -2.0f32); - assert_approx_eq!(3.8f64.ceil(), 4.0f64); - - assert_approx_eq!(0.1f32.trunc(), 0.0f32); - assert_approx_eq!((-0.1f64).trunc(), 0.0f64); -} diff --git a/src/test/ui/intrinsics/issue-28575.mir.stderr b/src/test/ui/intrinsics/issue-28575.mir.stderr deleted file mode 100644 index c42498390..000000000 --- a/src/test/ui/intrinsics/issue-28575.mir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0133]: use of extern static is unsafe and requires unsafe function or block - --> $DIR/issue-28575.rs:11:5 - | -LL | FOO() - | ^^^ use of extern static - | - = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/intrinsics/issue-28575.rs b/src/test/ui/intrinsics/issue-28575.rs deleted file mode 100644 index 410f664f8..000000000 --- a/src/test/ui/intrinsics/issue-28575.rs +++ /dev/null @@ -1,12 +0,0 @@ -// revisions: mir thir -// [thir]compile-flags: -Z thir-unsafeck - -#![feature(intrinsics)] - -extern "C" { - pub static FOO: extern "rust-intrinsic" fn(); -} - -fn main() { - FOO() //~ ERROR: use of extern static is unsafe -} diff --git a/src/test/ui/intrinsics/issue-28575.thir.stderr b/src/test/ui/intrinsics/issue-28575.thir.stderr deleted file mode 100644 index c42498390..000000000 --- a/src/test/ui/intrinsics/issue-28575.thir.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0133]: use of extern static is unsafe and requires unsafe function or block - --> $DIR/issue-28575.rs:11:5 - | -LL | FOO() - | ^^^ use of extern static - | - = note: extern statics are not controlled by the Rust type system: invalid data, aliasing violations or data races will cause undefined behavior - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/intrinsics/issue-84297-reifying-copy.rs b/src/test/ui/intrinsics/issue-84297-reifying-copy.rs deleted file mode 100644 index 08ba9ce7e..000000000 --- a/src/test/ui/intrinsics/issue-84297-reifying-copy.rs +++ /dev/null @@ -1,9 +0,0 @@ -// check-pass - -fn main() { - let _unused = if true { - core::ptr::copy:: - } else { - core::ptr::copy_nonoverlapping:: - }; -} diff --git a/src/test/ui/intrinsics/non-integer-atomic.rs b/src/test/ui/intrinsics/non-integer-atomic.rs deleted file mode 100644 index 85ea81ba6..000000000 --- a/src/test/ui/intrinsics/non-integer-atomic.rs +++ /dev/null @@ -1,92 +0,0 @@ -// build-fail - -#![feature(core_intrinsics)] -#![allow(warnings)] -#![crate_type = "rlib"] - -use std::intrinsics; - -#[derive(Copy, Clone)] -pub struct Foo(i64); -pub type Bar = &'static Fn(); -pub type Quux = [u8; 100]; - -pub unsafe fn test_bool_load(p: &mut bool, v: bool) { - intrinsics::atomic_load_seqcst(p); - //~^ ERROR `atomic_load_seqcst` intrinsic: expected basic integer type, found `bool` -} - -pub unsafe fn test_bool_store(p: &mut bool, v: bool) { - intrinsics::atomic_store_seqcst(p, v); - //~^ ERROR `atomic_store_seqcst` intrinsic: expected basic integer type, found `bool` -} - -pub unsafe fn test_bool_xchg(p: &mut bool, v: bool) { - intrinsics::atomic_xchg_seqcst(p, v); - //~^ ERROR `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `bool` -} - -pub unsafe fn test_bool_cxchg(p: &mut bool, v: bool) { - intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - //~^ ERROR `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `bool` -} - -pub unsafe fn test_Foo_load(p: &mut Foo, v: Foo) { - intrinsics::atomic_load_seqcst(p); - //~^ ERROR `atomic_load_seqcst` intrinsic: expected basic integer type, found `Foo` -} - -pub unsafe fn test_Foo_store(p: &mut Foo, v: Foo) { - intrinsics::atomic_store_seqcst(p, v); - //~^ ERROR `atomic_store_seqcst` intrinsic: expected basic integer type, found `Foo` -} - -pub unsafe fn test_Foo_xchg(p: &mut Foo, v: Foo) { - intrinsics::atomic_xchg_seqcst(p, v); - //~^ ERROR `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `Foo` -} - -pub unsafe fn test_Foo_cxchg(p: &mut Foo, v: Foo) { - intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - //~^ ERROR `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `Foo` -} - -pub unsafe fn test_Bar_load(p: &mut Bar, v: Bar) { - intrinsics::atomic_load_seqcst(p); - //~^ ERROR expected basic integer type, found `&dyn Fn()` -} - -pub unsafe fn test_Bar_store(p: &mut Bar, v: Bar) { - intrinsics::atomic_store_seqcst(p, v); - //~^ ERROR expected basic integer type, found `&dyn Fn()` -} - -pub unsafe fn test_Bar_xchg(p: &mut Bar, v: Bar) { - intrinsics::atomic_xchg_seqcst(p, v); - //~^ ERROR expected basic integer type, found `&dyn Fn()` -} - -pub unsafe fn test_Bar_cxchg(p: &mut Bar, v: Bar) { - intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - //~^ ERROR expected basic integer type, found `&dyn Fn()` -} - -pub unsafe fn test_Quux_load(p: &mut Quux, v: Quux) { - intrinsics::atomic_load_seqcst(p); - //~^ ERROR `atomic_load_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` -} - -pub unsafe fn test_Quux_store(p: &mut Quux, v: Quux) { - intrinsics::atomic_store_seqcst(p, v); - //~^ ERROR `atomic_store_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` -} - -pub unsafe fn test_Quux_xchg(p: &mut Quux, v: Quux) { - intrinsics::atomic_xchg_seqcst(p, v); - //~^ ERROR `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` -} - -pub unsafe fn test_Quux_cxchg(p: &mut Quux, v: Quux) { - intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - //~^ ERROR `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` -} diff --git a/src/test/ui/intrinsics/non-integer-atomic.stderr b/src/test/ui/intrinsics/non-integer-atomic.stderr deleted file mode 100644 index 32791a8e8..000000000 --- a/src/test/ui/intrinsics/non-integer-atomic.stderr +++ /dev/null @@ -1,99 +0,0 @@ -error[E0511]: invalid monomorphization of `atomic_load_seqcst` intrinsic: expected basic integer type, found `bool` - --> $DIR/non-integer-atomic.rs:15:5 - | -LL | intrinsics::atomic_load_seqcst(p); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `bool` - --> $DIR/non-integer-atomic.rs:20:5 - | -LL | intrinsics::atomic_store_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `bool` - --> $DIR/non-integer-atomic.rs:25:5 - | -LL | intrinsics::atomic_xchg_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `bool` - --> $DIR/non-integer-atomic.rs:30:5 - | -LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_load_seqcst` intrinsic: expected basic integer type, found `Foo` - --> $DIR/non-integer-atomic.rs:35:5 - | -LL | intrinsics::atomic_load_seqcst(p); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `Foo` - --> $DIR/non-integer-atomic.rs:40:5 - | -LL | intrinsics::atomic_store_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `Foo` - --> $DIR/non-integer-atomic.rs:45:5 - | -LL | intrinsics::atomic_xchg_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `Foo` - --> $DIR/non-integer-atomic.rs:50:5 - | -LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_load_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()` - --> $DIR/non-integer-atomic.rs:55:5 - | -LL | intrinsics::atomic_load_seqcst(p); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()` - --> $DIR/non-integer-atomic.rs:60:5 - | -LL | intrinsics::atomic_store_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()` - --> $DIR/non-integer-atomic.rs:65:5 - | -LL | intrinsics::atomic_xchg_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `&dyn Fn()` - --> $DIR/non-integer-atomic.rs:70:5 - | -LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_load_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` - --> $DIR/non-integer-atomic.rs:75:5 - | -LL | intrinsics::atomic_load_seqcst(p); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_store_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` - --> $DIR/non-integer-atomic.rs:80:5 - | -LL | intrinsics::atomic_store_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_xchg_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` - --> $DIR/non-integer-atomic.rs:85:5 - | -LL | intrinsics::atomic_xchg_seqcst(p, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0511]: invalid monomorphization of `atomic_cxchg_seqcst_seqcst` intrinsic: expected basic integer type, found `[u8; 100]` - --> $DIR/non-integer-atomic.rs:90:5 - | -LL | intrinsics::atomic_cxchg_seqcst_seqcst(p, v, v); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 16 previous errors - -For more information about this error, try `rustc --explain E0511`. diff --git a/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs b/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs deleted file mode 100644 index ec3860a32..000000000 --- a/src/test/ui/intrinsics/panic-uninitialized-zeroed.rs +++ /dev/null @@ -1,377 +0,0 @@ -// run-pass -// needs-unwind -// revisions: mir thir strict -// [thir]compile-flags: -Zthir-unsafeck -// [strict]compile-flags: -Zstrict-init-checks -// ignore-tidy-linelength - -// This test checks panic emitted from `mem::{uninitialized,zeroed}`. - -#![feature(never_type)] -#![allow(deprecated, invalid_value)] - -use std::{ - mem::{self, MaybeUninit, ManuallyDrop}, - panic, - ptr::NonNull, - num, -}; - -#[allow(dead_code)] -struct Foo { - x: u8, - y: !, -} - -enum Bar {} - -#[allow(dead_code)] -enum OneVariant { Variant(i32) } - -#[allow(dead_code, non_camel_case_types)] -enum OneVariant_NonZero { - Variant(i32, i32, num::NonZeroI32), - DeadVariant(Bar), -} - -#[allow(dead_code, non_camel_case_types)] -enum OneVariant_Ref { - Variant(&'static i32), - DeadVariant(Bar), -} - -// An `Aggregate` abi enum where 0 is not a valid discriminant. -#[allow(dead_code)] -#[repr(i32)] -enum NoNullVariant { - Variant1(i32, i32) = 1, - Variant2(i32, i32) = 2, -} - -// An enum with ScalarPair layout -#[allow(dead_code)] -enum LR { - Left(i64), - Right(i64), -} -#[allow(dead_code, non_camel_case_types)] -enum LR_NonZero { - Left(num::NonZeroI64), - Right(num::NonZeroI64), -} - -struct ZeroSized; - -#[allow(dead_code)] -#[repr(i32)] -enum ZeroIsValid { - Zero(u8) = 0, - One(NonNull<()>) = 1, -} - -#[track_caller] -fn test_panic_msg(op: impl (FnOnce() -> T) + panic::UnwindSafe, msg: &str) { - let err = panic::catch_unwind(op).err(); - assert_eq!( - err.as_ref().and_then(|a| a.downcast_ref::<&str>()), - Some(&msg) - ); -} - -#[track_caller] -fn test_panic_msg_only_if_strict(op: impl (FnOnce() -> T) + panic::UnwindSafe, msg: &str) { - let err = panic::catch_unwind(op).err(); - assert_eq!( - err.as_ref().and_then(|a| a.downcast_ref::<&str>()), - if cfg!(strict) { Some(&msg) } else { None }, - ); -} - -fn main() { - unsafe { - // Uninhabited types - test_panic_msg( - || mem::uninitialized::(), - "attempted to instantiate uninhabited type `!`" - ); - test_panic_msg( - || mem::zeroed::(), - "attempted to instantiate uninhabited type `!`" - ); - test_panic_msg( - || MaybeUninit::::uninit().assume_init(), - "attempted to instantiate uninhabited type `!`" - ); - - test_panic_msg( - || mem::uninitialized::(), - "attempted to instantiate uninhabited type `Foo`" - ); - test_panic_msg( - || mem::zeroed::(), - "attempted to instantiate uninhabited type `Foo`" - ); - test_panic_msg( - || MaybeUninit::::uninit().assume_init(), - "attempted to instantiate uninhabited type `Foo`" - ); - - test_panic_msg( - || mem::uninitialized::(), - "attempted to instantiate uninhabited type `Bar`" - ); - test_panic_msg( - || mem::zeroed::(), - "attempted to instantiate uninhabited type `Bar`" - ); - test_panic_msg( - || MaybeUninit::::uninit().assume_init(), - "attempted to instantiate uninhabited type `Bar`" - ); - - test_panic_msg( - || mem::uninitialized::<[Foo; 2]>(), - "attempted to instantiate uninhabited type `[Foo; 2]`" - ); - test_panic_msg( - || mem::zeroed::<[Foo; 2]>(), - "attempted to instantiate uninhabited type `[Foo; 2]`" - ); - test_panic_msg( - || MaybeUninit::<[Foo; 2]>::uninit().assume_init(), - "attempted to instantiate uninhabited type `[Foo; 2]`" - ); - - test_panic_msg( - || mem::uninitialized::<[Bar; 2]>(), - "attempted to instantiate uninhabited type `[Bar; 2]`" - ); - test_panic_msg( - || mem::zeroed::<[Bar; 2]>(), - "attempted to instantiate uninhabited type `[Bar; 2]`" - ); - test_panic_msg( - || MaybeUninit::<[Bar; 2]>::uninit().assume_init(), - "attempted to instantiate uninhabited type `[Bar; 2]`" - ); - - // Types that don't allow either. - test_panic_msg( - || mem::zeroed::<&i32>(), - "attempted to zero-initialize type `&i32`, which is invalid" - ); - test_panic_msg( - || mem::uninitialized::<&i32>(), - "attempted to leave type `&i32` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::>(), - "attempted to zero-initialize type `alloc::boxed::Box<[i32; 0]>`, which is invalid" - ); - test_panic_msg( - || mem::uninitialized::>(), - "attempted to leave type `alloc::boxed::Box<[i32; 0]>` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::>(), - "attempted to zero-initialize type `alloc::boxed::Box`, which is invalid" - ); - test_panic_msg( - || mem::uninitialized::>(), - "attempted to leave type `alloc::boxed::Box` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<&[i32]>(), - "attempted to zero-initialize type `&[i32]`, which is invalid" - ); - test_panic_msg( - || mem::uninitialized::<&[i32]>(), - "attempted to leave type `&[i32]` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<&(u8, [u8])>(), - "attempted to zero-initialize type `&(u8, [u8])`, which is invalid" - ); - test_panic_msg( - || mem::uninitialized::<&(u8, [u8])>(), - "attempted to leave type `&(u8, [u8])` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<&dyn Send>(), - "attempted to zero-initialize type `&dyn core::marker::Send`, which is invalid" - ); - test_panic_msg( - || mem::uninitialized::<&dyn Send>(), - "attempted to leave type `&dyn core::marker::Send` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<*const dyn Send>(), - "attempted to zero-initialize type `*const dyn core::marker::Send`, which is invalid" - ); - test_panic_msg( - || mem::uninitialized::<*const dyn Send>(), - "attempted to leave type `*const dyn core::marker::Send` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::uninitialized::(), - "attempted to leave type `NoNullVariant` uninitialized, \ - which is invalid" - ); - test_panic_msg( - || mem::zeroed::(), - "attempted to zero-initialize type `NoNullVariant`, \ - which is invalid" - ); - - test_panic_msg( - || mem::zeroed::(), - "attempted to zero-initialize type `OneVariant_Ref`, \ - which is invalid" - ); - test_panic_msg( - || mem::uninitialized::(), - "attempted to leave type `OneVariant_Ref` uninitialized, which is invalid" - ); - - // Types where both are invalid, but we allow uninit since the 0x01-filling is not LLVM UB. - test_panic_msg( - || mem::zeroed::(), - "attempted to zero-initialize type `fn()`, which is invalid" - ); - test_panic_msg_only_if_strict( - || mem::uninitialized::(), - "attempted to leave type `fn()` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<&()>(), - "attempted to zero-initialize type `&()`, which is invalid" - ); - test_panic_msg_only_if_strict( - || mem::uninitialized::<&()>(), - "attempted to leave type `&()` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<&[u8]>(), - "attempted to zero-initialize type `&[u8]`, which is invalid" - ); - test_panic_msg_only_if_strict( - || mem::uninitialized::<&[u8]>(), - "attempted to leave type `&[u8]` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<&str>(), - "attempted to zero-initialize type `&str`, which is invalid" - ); - test_panic_msg_only_if_strict( - || mem::uninitialized::<&str>(), - "attempted to leave type `&str` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::<(NonNull, u32, u32)>(), - "attempted to zero-initialize type `(core::ptr::non_null::NonNull, u32, u32)`, \ - which is invalid" - ); - test_panic_msg_only_if_strict( - || mem::uninitialized::<(NonNull, u32, u32)>(), - "attempted to leave type `(core::ptr::non_null::NonNull, u32, u32)` uninitialized, which is invalid" - ); - - test_panic_msg( - || mem::zeroed::(), - "attempted to zero-initialize type `OneVariant_NonZero`, \ - which is invalid" - ); - test_panic_msg_only_if_strict( - || mem::uninitialized::(), - "attempted to leave type `OneVariant_NonZero` uninitialized, which is invalid" - ); - - // Types where both are invalid but we allow the zeroed form since it is not LLVM UB. - test_panic_msg_only_if_strict( - || mem::zeroed::(), - "attempted to zero-initialize type `LR_NonZero`, which is invalid" - ); - test_panic_msg( - || mem::uninitialized::(), - "attempted to leave type `LR_NonZero` uninitialized, which is invalid" - ); - - test_panic_msg_only_if_strict( - || mem::zeroed::>(), - "attempted to zero-initialize type `core::mem::manually_drop::ManuallyDrop`, \ - which is invalid" - ); - test_panic_msg( - || mem::uninitialized::>(), - "attempted to leave type `core::mem::manually_drop::ManuallyDrop` uninitialized, \ - which is invalid" - ); - - // Some strict-only things - test_panic_msg_only_if_strict( - || mem::uninitialized::(), - "attempted to leave type `i32` uninitialized, which is invalid" - ); - - test_panic_msg_only_if_strict( - || mem::uninitialized::<*const ()>(), - "attempted to leave type `*const ()` uninitialized, which is invalid" - ); - - test_panic_msg_only_if_strict( - || mem::uninitialized::<[i32; 1]>(), - "attempted to leave type `[i32; 1]` uninitialized, which is invalid" - ); - - test_panic_msg_only_if_strict( - || mem::zeroed::<[NonNull<()>; 1]>(), - "attempted to zero-initialize type `[core::ptr::non_null::NonNull<()>; 1]`, which is invalid" - ); - - // Types that can be zero, but not uninit (though some are mitigated). - let _val = mem::zeroed::(); - test_panic_msg( - || mem::uninitialized::(), - "attempted to leave type `LR` uninitialized, which is invalid" - ); - - let _val = mem::zeroed::>(); - test_panic_msg( - || mem::uninitialized::>(), - "attempted to leave type `core::mem::manually_drop::ManuallyDrop` uninitialized, which is invalid" - ); - - let _val = mem::zeroed::(); - test_panic_msg_only_if_strict( - || mem::uninitialized::(), - "attempted to leave type `bool` uninitialized, which is invalid" - ); - - let _val = mem::zeroed::(); - test_panic_msg_only_if_strict( - || mem::uninitialized::(), - "attempted to leave type `OneVariant` uninitialized, which is invalid" - ); - - // Some things that are actually allowed. - let _val = mem::zeroed::>(); - let _val = mem::zeroed::>>(); - let _val = mem::zeroed::<[!; 0]>(); - let _val = mem::zeroed::(); - let _val = mem::uninitialized::>(); - let _val = mem::uninitialized::<[!; 0]>(); - let _val = mem::uninitialized::<()>(); - let _val = mem::uninitialized::(); - } -} diff --git a/src/test/ui/intrinsics/safe-intrinsic-mismatch.rs b/src/test/ui/intrinsics/safe-intrinsic-mismatch.rs deleted file mode 100644 index 50e12eaeb..000000000 --- a/src/test/ui/intrinsics/safe-intrinsic-mismatch.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![feature(intrinsics)] -#![feature(rustc_attrs)] - -extern "rust-intrinsic" { - fn size_of() -> usize; //~ ERROR intrinsic safety mismatch - - #[rustc_safe_intrinsic] - fn assume(b: bool); //~ ERROR intrinsic safety mismatch -} - -fn main() {} diff --git a/src/test/ui/intrinsics/safe-intrinsic-mismatch.stderr b/src/test/ui/intrinsics/safe-intrinsic-mismatch.stderr deleted file mode 100644 index 0c2f3be49..000000000 --- a/src/test/ui/intrinsics/safe-intrinsic-mismatch.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `size_of` - --> $DIR/safe-intrinsic-mismatch.rs:5:5 - | -LL | fn size_of() -> usize; - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: intrinsic safety mismatch between list of intrinsics within the compiler and core library intrinsics for intrinsic `assume` - --> $DIR/safe-intrinsic-mismatch.rs:8:5 - | -LL | fn assume(b: bool); - | ^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/intrinsics/unchecked_math_unsafe.mir.stderr b/src/test/ui/intrinsics/unchecked_math_unsafe.mir.stderr deleted file mode 100644 index 26b2f9f27..000000000 --- a/src/test/ui/intrinsics/unchecked_math_unsafe.mir.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0133]: call to unsafe function is unsafe and requires unsafe function or block - --> $DIR/unchecked_math_unsafe.rs:8:15 - | -LL | let add = std::intrinsics::unchecked_add(x, y); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function - | - = note: consult the function's documentation for information on how to avoid undefined behavior - -error[E0133]: call to unsafe function is unsafe and requires unsafe function or block - --> $DIR/unchecked_math_unsafe.rs:9:15 - | -LL | let sub = std::intrinsics::unchecked_sub(x, y); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function - | - = note: consult the function's documentation for information on how to avoid undefined behavior - -error[E0133]: call to unsafe function is unsafe and requires unsafe function or block - --> $DIR/unchecked_math_unsafe.rs:10:15 - | -LL | let mul = std::intrinsics::unchecked_mul(x, y); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function - | - = note: consult the function's documentation for information on how to avoid undefined behavior - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/intrinsics/unchecked_math_unsafe.rs b/src/test/ui/intrinsics/unchecked_math_unsafe.rs deleted file mode 100644 index 98d3a11ad..000000000 --- a/src/test/ui/intrinsics/unchecked_math_unsafe.rs +++ /dev/null @@ -1,11 +0,0 @@ -// revisions: mir thir -// [thir]compile-flags: -Z thir-unsafeck - -#![feature(core_intrinsics)] - -fn main() { - let (x, y) = (1u32, 2u32); - let add = std::intrinsics::unchecked_add(x, y); //~ ERROR call to unsafe function - let sub = std::intrinsics::unchecked_sub(x, y); //~ ERROR call to unsafe function - let mul = std::intrinsics::unchecked_mul(x, y); //~ ERROR call to unsafe function -} diff --git a/src/test/ui/intrinsics/unchecked_math_unsafe.thir.stderr b/src/test/ui/intrinsics/unchecked_math_unsafe.thir.stderr deleted file mode 100644 index 5c3728ccd..000000000 --- a/src/test/ui/intrinsics/unchecked_math_unsafe.thir.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0133]: call to unsafe function `unchecked_add` is unsafe and requires unsafe function or block - --> $DIR/unchecked_math_unsafe.rs:8:15 - | -LL | let add = std::intrinsics::unchecked_add(x, y); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function - | - = note: consult the function's documentation for information on how to avoid undefined behavior - -error[E0133]: call to unsafe function `unchecked_sub` is unsafe and requires unsafe function or block - --> $DIR/unchecked_math_unsafe.rs:9:15 - | -LL | let sub = std::intrinsics::unchecked_sub(x, y); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function - | - = note: consult the function's documentation for information on how to avoid undefined behavior - -error[E0133]: call to unsafe function `unchecked_mul` is unsafe and requires unsafe function or block - --> $DIR/unchecked_math_unsafe.rs:10:15 - | -LL | let mul = std::intrinsics::unchecked_mul(x, y); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function - | - = note: consult the function's documentation for information on how to avoid undefined behavior - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0133`. diff --git a/src/test/ui/intrinsics/unchecked_math_unstable.rs b/src/test/ui/intrinsics/unchecked_math_unstable.rs deleted file mode 100644 index 8869063d1..000000000 --- a/src/test/ui/intrinsics/unchecked_math_unstable.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn main() { - let (x, y) = (1u32, 2u32); - unsafe { - let add = std::intrinsics::unchecked_add(x, y); //~ ERROR use of unstable library feature - let sub = std::intrinsics::unchecked_sub(x, y); //~ ERROR use of unstable library feature - let mul = std::intrinsics::unchecked_mul(x, y); //~ ERROR use of unstable library feature - } -} diff --git a/src/test/ui/intrinsics/unchecked_math_unstable.stderr b/src/test/ui/intrinsics/unchecked_math_unstable.stderr deleted file mode 100644 index a43aa16ae..000000000 --- a/src/test/ui/intrinsics/unchecked_math_unstable.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0658]: use of unstable library feature 'core_intrinsics': intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library - --> $DIR/unchecked_math_unstable.rs:4:19 - | -LL | let add = std::intrinsics::unchecked_add(x, y); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable - -error[E0658]: use of unstable library feature 'core_intrinsics': intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library - --> $DIR/unchecked_math_unstable.rs:5:19 - | -LL | let sub = std::intrinsics::unchecked_sub(x, y); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable - -error[E0658]: use of unstable library feature 'core_intrinsics': intrinsics are unlikely to ever be stabilized, instead they should be used through stabilized interfaces in the rest of the standard library - --> $DIR/unchecked_math_unstable.rs:6:19 - | -LL | let mul = std::intrinsics::unchecked_mul(x, y); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: add `#![feature(core_intrinsics)]` to the crate attributes to enable - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0658`. -- cgit v1.2.3