remove a bunch of unnecessary 'pub' from tests
This commit is contained in:
parent
f3c08df150
commit
61594ca4aa
113 changed files with 156 additions and 161 deletions
|
|
@ -2,7 +2,7 @@
|
|||
//@[tree]compile-flags: -Zmiri-tree-borrows
|
||||
use std::mem;
|
||||
|
||||
pub fn safe(x: &mut i32, y: &mut i32) {
|
||||
fn safe(x: &mut i32, y: &mut i32) {
|
||||
//~[stack]^ ERROR: protect
|
||||
*x = 1; //~[tree] ERROR: /write access through .* is forbidden/
|
||||
*y = 2;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [Unique for <TAG>] which is strongly protected
|
||||
--> tests/fail/both_borrows/aliasing_mut1.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &mut i32, y: &mut i32) {
|
||||
| ^ Undefined Behavior occurred here
|
||||
LL | fn safe(x: &mut i32, y: &mut i32) {
|
||||
| ^ Undefined Behavior occurred here
|
||||
|
|
||||
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
|
||||
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
|
||||
|
|
@ -14,8 +14,8 @@ LL | let xraw: *mut i32 = unsafe { mem::transmute(&mut x) };
|
|||
help: <TAG> is this argument
|
||||
--> tests/fail/both_borrows/aliasing_mut1.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &mut i32, y: &mut i32) {
|
||||
| ^
|
||||
LL | fn safe(x: &mut i32, y: &mut i32) {
|
||||
| ^
|
||||
= note: BACKTRACE (of the first span):
|
||||
= note: inside `safe` at tests/fail/both_borrows/aliasing_mut1.rs:LL:CC
|
||||
note: inside `main`
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ LL | *x = 1;
|
|||
help: the accessed tag <TAG> was created here, in the initial state Reserved
|
||||
--> tests/fail/both_borrows/aliasing_mut1.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &mut i32, y: &mut i32) {
|
||||
| ^
|
||||
LL | fn safe(x: &mut i32, y: &mut i32) {
|
||||
| ^
|
||||
help: the accessed tag <TAG> later transitioned to Reserved (conflicted) due to a reborrow (acting as a foreign read access) at offsets [0x0..0x4]
|
||||
--> tests/fail/both_borrows/aliasing_mut1.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &mut i32, y: &mut i32) {
|
||||
| ^
|
||||
LL | fn safe(x: &mut i32, y: &mut i32) {
|
||||
| ^
|
||||
= help: this transition corresponds to a temporary loss of write permissions until function exit
|
||||
= note: BACKTRACE (of the first span):
|
||||
= note: inside `safe` at tests/fail/both_borrows/aliasing_mut1.rs:LL:CC
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//@[tree]compile-flags: -Zmiri-tree-borrows
|
||||
use std::mem;
|
||||
|
||||
pub fn safe(x: &i32, y: &mut i32) {
|
||||
fn safe(x: &i32, y: &mut i32) {
|
||||
//~[stack]^ ERROR: protect
|
||||
let _v = *x;
|
||||
*y = 2; //~[tree] ERROR: /write access through .* is forbidden/
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [SharedReadOnly for <TAG>] which is strongly protected
|
||||
--> tests/fail/both_borrows/aliasing_mut2.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &i32, y: &mut i32) {
|
||||
| ^ Undefined Behavior occurred here
|
||||
LL | fn safe(x: &i32, y: &mut i32) {
|
||||
| ^ Undefined Behavior occurred here
|
||||
|
|
||||
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
|
||||
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
|
||||
|
|
@ -14,8 +14,8 @@ LL | let xref = &mut x;
|
|||
help: <TAG> is this argument
|
||||
--> tests/fail/both_borrows/aliasing_mut2.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &i32, y: &mut i32) {
|
||||
| ^
|
||||
LL | fn safe(x: &i32, y: &mut i32) {
|
||||
| ^
|
||||
= note: BACKTRACE (of the first span):
|
||||
= note: inside `safe` at tests/fail/both_borrows/aliasing_mut2.rs:LL:CC
|
||||
note: inside `main`
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ LL | *y = 2;
|
|||
help: the accessed tag <TAG> was created here, in the initial state Reserved
|
||||
--> tests/fail/both_borrows/aliasing_mut2.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &i32, y: &mut i32) {
|
||||
| ^
|
||||
LL | fn safe(x: &i32, y: &mut i32) {
|
||||
| ^
|
||||
help: the accessed tag <TAG> later transitioned to Reserved (conflicted) due to a foreign read access at offsets [0x0..0x4]
|
||||
--> tests/fail/both_borrows/aliasing_mut2.rs:LL:CC
|
||||
|
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
//@[tree]compile-flags: -Zmiri-tree-borrows
|
||||
use std::mem;
|
||||
|
||||
pub fn safe(x: &mut i32, y: &i32) {
|
||||
fn safe(x: &mut i32, y: &i32) {
|
||||
//~[stack]^ ERROR: borrow stack
|
||||
*x = 1; //~[tree] ERROR: /write access through .* is forbidden/
|
||||
let _v = *y;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: Undefined Behavior: trying to retag from <TAG> for SharedReadOnly permission at ALLOC[0x0], but that tag does not exist in the borrow stack for this location
|
||||
--> tests/fail/both_borrows/aliasing_mut3.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &mut i32, y: &i32) {
|
||||
| ^ this error occurs as part of function-entry retag at ALLOC[0x0..0x4]
|
||||
LL | fn safe(x: &mut i32, y: &i32) {
|
||||
| ^ this error occurs as part of function-entry retag at ALLOC[0x0..0x4]
|
||||
|
|
||||
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
|
||||
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
|
||||
|
|
|
|||
|
|
@ -10,13 +10,13 @@ LL | *x = 1;
|
|||
help: the accessed tag <TAG> was created here, in the initial state Reserved
|
||||
--> tests/fail/both_borrows/aliasing_mut3.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &mut i32, y: &i32) {
|
||||
| ^
|
||||
LL | fn safe(x: &mut i32, y: &i32) {
|
||||
| ^
|
||||
help: the accessed tag <TAG> later transitioned to Reserved (conflicted) due to a reborrow (acting as a foreign read access) at offsets [0x0..0x4]
|
||||
--> tests/fail/both_borrows/aliasing_mut3.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &mut i32, y: &i32) {
|
||||
| ^
|
||||
LL | fn safe(x: &mut i32, y: &i32) {
|
||||
| ^
|
||||
= help: this transition corresponds to a temporary loss of write permissions until function exit
|
||||
= note: BACKTRACE (of the first span):
|
||||
= note: inside `safe` at tests/fail/both_borrows/aliasing_mut3.rs:LL:CC
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::cell::Cell;
|
|||
use std::mem;
|
||||
|
||||
// Make sure &mut UnsafeCell also is exclusive
|
||||
pub fn safe(x: &i32, y: &mut Cell<i32>) {
|
||||
fn safe(x: &i32, y: &mut Cell<i32>) {
|
||||
//~[stack]^ ERROR: protect
|
||||
y.set(1);
|
||||
let _load = *x;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
error: Undefined Behavior: not granting access to tag <TAG> because that would remove [SharedReadOnly for <TAG>] which is strongly protected
|
||||
--> tests/fail/both_borrows/aliasing_mut4.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &i32, y: &mut Cell<i32>) {
|
||||
| ^ Undefined Behavior occurred here
|
||||
LL | fn safe(x: &i32, y: &mut Cell<i32>) {
|
||||
| ^ Undefined Behavior occurred here
|
||||
|
|
||||
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
|
||||
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
|
||||
|
|
@ -14,8 +14,8 @@ LL | let xref = &mut x;
|
|||
help: <TAG> is this argument
|
||||
--> tests/fail/both_borrows/aliasing_mut4.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &i32, y: &mut Cell<i32>) {
|
||||
| ^
|
||||
LL | fn safe(x: &i32, y: &mut Cell<i32>) {
|
||||
| ^
|
||||
= note: BACKTRACE (of the first span):
|
||||
= note: inside `safe` at tests/fail/both_borrows/aliasing_mut4.rs:LL:CC
|
||||
note: inside `main`
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ LL | y.set(1);
|
|||
help: the protected tag <TAG> was created here, in the initial state Frozen
|
||||
--> tests/fail/both_borrows/aliasing_mut4.rs:LL:CC
|
||||
|
|
||||
LL | pub fn safe(x: &i32, y: &mut Cell<i32>) {
|
||||
| ^
|
||||
LL | fn safe(x: &i32, y: &mut Cell<i32>) {
|
||||
| ^
|
||||
= note: BACKTRACE (of the first span):
|
||||
= note: inside `std::mem::replace::<i32>` at RUSTLIB/core/src/mem/mod.rs:LL:CC
|
||||
= note: inside `std::cell::Cell::<i32>::replace` at RUSTLIB/core/src/cell.rs:LL:CC
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Shared atomic pointer
|
||||
let pointer = AtomicPtr::new(null_mut::<MaybeUninit<usize>>());
|
||||
let ptr = EvilSend(&pointer as *const AtomicPtr<MaybeUninit<usize>>);
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Shared atomic pointer
|
||||
let pointer = AtomicPtr::new(null_mut::<usize>());
|
||||
let ptr = EvilSend(&pointer as *const AtomicPtr<usize>);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = AtomicUsize::new(0);
|
||||
let b = &mut a as *mut AtomicUsize;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = AtomicUsize::new(0);
|
||||
let b = &mut a as *mut AtomicUsize;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = AtomicUsize::new(0);
|
||||
let b = &mut a as *mut AtomicUsize;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = AtomicUsize::new(0);
|
||||
let b = &mut a as *mut AtomicUsize;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = AtomicUsize::new(0);
|
||||
let b = &mut a as *mut AtomicUsize;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = AtomicUsize::new(0);
|
||||
let b = &mut a as *mut AtomicUsize;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ extern "Rust" {
|
|||
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Shared atomic pointer
|
||||
let pointer: *mut usize = Box::into_raw(Box::new(0usize));
|
||||
let ptr = EvilSend(pointer);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ extern "Rust" {
|
|||
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Shared atomic pointer
|
||||
let pointer: *mut usize = Box::into_raw(Box::new(0usize));
|
||||
let ptr = EvilSend(pointer);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Shared atomic pointer
|
||||
let pointer = AtomicPtr::new(null_mut::<usize>());
|
||||
let ptr = EvilSend(&pointer as *const AtomicPtr<usize>);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ extern "Rust" {
|
|||
#[rustc_std_internal_symbol]
|
||||
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
|
||||
}
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Shared atomic pointer
|
||||
let pointer: *mut usize = Box::into_raw(Box::new(0usize));
|
||||
let ptr = EvilSend(pointer);
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ extern "Rust" {
|
|||
#[rustc_std_internal_symbol]
|
||||
fn __rust_dealloc(ptr: *mut u8, size: usize, align: usize);
|
||||
}
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Shared atomic pointer
|
||||
let pointer: *mut usize = Box::into_raw(Box::new(0usize));
|
||||
let ptr = EvilSend(pointer);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Shared atomic pointer
|
||||
let pointer = AtomicPtr::new(null_mut::<usize>());
|
||||
let ptr = EvilSend(&pointer as *const AtomicPtr<usize>);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Enable and then join with multiple threads.
|
||||
let t1 = spawn(|| ());
|
||||
let t2 = spawn(|| ());
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = 0u32;
|
||||
let b = &mut a as *mut u32;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Shared atomic pointer
|
||||
let pointer = AtomicPtr::new(null_mut::<usize>());
|
||||
let ptr = EvilSend(&pointer as *const AtomicPtr<usize>);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ unsafe impl<T> Sync for EvilSend<T> {}
|
|||
|
||||
static SYNC: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = 0u32;
|
||||
let b = &mut a as *mut u32;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ unsafe impl<T> Sync for EvilSend<T> {}
|
|||
|
||||
static SYNC: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = 0u32;
|
||||
let b = &mut a as *mut u32;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ unsafe impl<T> Sync for EvilSend<T> {}
|
|||
|
||||
static SYNC: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = 0u32;
|
||||
let b = &mut a as *mut u32;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ unsafe impl<T> Sync for EvilSend<T> {}
|
|||
|
||||
static SYNC: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = 0u32;
|
||||
let b = &mut a as *mut u32;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = 0u32;
|
||||
let b = &mut a as *mut u32;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Shared atomic pointer
|
||||
let pointer = AtomicPtr::new(null_mut::<usize>());
|
||||
let ptr = EvilSend(&pointer as *const AtomicPtr<usize>);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ fn set_discriminant(ptr: &mut Option<NonZero<i32>>) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut v = None;
|
||||
set_discriminant(&mut v);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn callee(x: S, mut y: S) {
|
||||
fn callee(x: S, mut y: S) {
|
||||
// With the setup above, if `x` and `y` are both moved,
|
||||
// then writing to `y` will change the value stored in `x`!
|
||||
y.0 = 0;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,6 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn callee(x: S) -> S {
|
||||
fn callee(x: S) -> S {
|
||||
x
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn callee(x: S, ptr: *mut S) {
|
||||
fn callee(x: S, ptr: *mut S) {
|
||||
// With the setup above, if `x` is indeed moved in
|
||||
// (i.e. we actually just get a pointer to the underlying storage),
|
||||
// then writing to `ptr` will change the value stored in `x`!
|
||||
|
|
|
|||
|
|
@ -22,6 +22,6 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn change_arg(mut x: S) {
|
||||
fn change_arg(mut x: S) {
|
||||
x.0 = 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ fn main() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn change_arg(mut x: S, ptr: *mut S) {
|
||||
fn change_arg(mut x: S, ptr: *mut S) {
|
||||
x.0 = 0;
|
||||
// If `x` got passed in-place, we'd see the write through `ptr`!
|
||||
// Make sure we are not allowed to do that read.
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
use std::intrinsics::mir::*;
|
||||
|
||||
#[custom_mir(dialect = "runtime", phase = "optimized")]
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
mir! {
|
||||
{
|
||||
let _x = 0;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
use std::intrinsics::mir::*;
|
||||
|
||||
#[custom_mir(dialect = "runtime", phase = "optimized")]
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
mir! {
|
||||
{
|
||||
let _x = 0;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
use std::intrinsics::mir::*;
|
||||
|
||||
#[custom_mir(dialect = "runtime", phase = "optimized")]
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
mir! {
|
||||
{
|
||||
let _x = 0;
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ pub unsafe extern "C" fn foo(_y: f32, x: __m256) -> __m256 {
|
|||
x
|
||||
}
|
||||
|
||||
pub fn bar(x: __m256) -> __m256 {
|
||||
fn bar(x: __m256) -> __m256 {
|
||||
// The first and second argument get mixed up here since caller
|
||||
// and callee do not have the same feature flags.
|
||||
// In Miri, we don't have a concept of "dynamically available feature flags",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#![feature(core_intrinsics)]
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
unsafe {
|
||||
use std::intrinsics::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#![feature(core_intrinsics)]
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
unsafe {
|
||||
use std::intrinsics::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ pub struct Meta {
|
|||
}
|
||||
|
||||
impl Meta {
|
||||
pub fn new() -> Self {
|
||||
fn new() -> Self {
|
||||
Meta { drop_fn: |_| {}, size: 0, align: 1 }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use std::intrinsics::mir::*;
|
|||
// which wants to prevent overlapping assignments...
|
||||
// So we use two separate pointer arguments, and then arrange for them to alias.
|
||||
#[custom_mir(dialect = "runtime", phase = "optimized")]
|
||||
pub fn self_copy(ptr1: *mut [i32; 4], ptr2: *mut [i32; 4]) {
|
||||
fn self_copy(ptr1: *mut [i32; 4], ptr2: *mut [i32; 4]) {
|
||||
mir! {
|
||||
{
|
||||
*ptr1 = *ptr2; //~ERROR: overlapping ranges
|
||||
|
|
@ -16,7 +16,7 @@ pub fn self_copy(ptr1: *mut [i32; 4], ptr2: *mut [i32; 4]) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut x = [0; 4];
|
||||
let ptr = std::ptr::addr_of_mut!(x);
|
||||
self_copy(ptr, ptr);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ LL | panic::catch_unwind(move || unsafe { init(argc, argv, sigpipe) }).map_e
|
|||
help: the protected tag <TAG> was created here, in the initial state Active
|
||||
--> RUSTLIB/std/src/panic.rs:LL:CC
|
||||
|
|
||||
LL | pub fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
|
||||
LL | fn catch_unwind<F: FnOnce() -> R + UnwindSafe, R>(f: F) -> Result<R> {
|
||||
| ^
|
||||
= note: BACKTRACE (of the first span):
|
||||
= note: inside `std::rt::lang_start_internal` at RUSTLIB/std/src/rt.rs:LL:CC
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use std::cell::Cell;
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
thread_local! {
|
||||
static TLS: Cell<Option<&'static i32>> = Cell::new(None);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::cell::Cell;
|
|||
|
||||
/// Ensure that leaks through `thread_local` statics *not in the main thread*
|
||||
/// are detected.
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
#[thread_local]
|
||||
static TLS: Cell<Option<&'static i32>> = Cell::new(None);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// Check that TB properly rejects alternating Reads and Writes, but tolerates
|
||||
// alternating only Reads to Reserved mutable references.
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let x = &mut 0u8;
|
||||
let y = unsafe { &mut *(x as *mut u8) };
|
||||
// Foreign Read, but this is a no-op from the point of view of y (still Reserved)
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ struct Foo {
|
|||
field2: Cell<u32>,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let root = Foo { field1: 42, field2: Cell::new(88) };
|
||||
unsafe {
|
||||
let a = &root;
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ unsafe fn access_after_sub_1(x: &mut u8, orig_ptr: *mut u8) {
|
|||
*(x as *mut u8).byte_sub(1) = 42; //~ ERROR: /write access through .* is forbidden/
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
unsafe {
|
||||
let mut alloc = [0u8, 0u8];
|
||||
let orig_ptr = addr_of_mut!(alloc) as *mut u8;
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ impl Foo {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut f = Foo(0);
|
||||
let alias = &mut f.0 as *mut u64;
|
||||
let res = f.add(unsafe {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ union FooBar {
|
|||
bar: Bar,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// Initialize as u8 to ensure padding bytes are zeroed.
|
||||
let mut foobar = FooBar { bar: Bar { bytes: [0u8; 8] } };
|
||||
// Reading either field is ok.
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ fn cast(ptr: *const char) -> u32 {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let v = u32::MAX;
|
||||
cast(&v as *const u32 as *const char);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ fn switch_int(ptr: *const char) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let v = u32::MAX;
|
||||
switch_int(&v as *const u32 as *const char);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ fn cast(ptr: *const E) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let v = u32::MAX;
|
||||
cast(&v as *const u32 as *const E);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ fn relaxed() {
|
|||
j2.join().unwrap();
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// If we try often enough, we should hit UB.
|
||||
for _ in 0..100 {
|
||||
relaxed();
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
use core::intrinsics::mir::*;
|
||||
|
||||
#[custom_mir(dialect = "runtime", phase = "optimized")]
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
mir! {
|
||||
let x: i32;
|
||||
let tuple: (*mut i32,);
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ pub unsafe fn set(key: Key, value: *mut u8) {
|
|||
assert_eq!(r, 0);
|
||||
}
|
||||
|
||||
pub fn record(r: usize) {
|
||||
fn record(r: usize) {
|
||||
assert!(r < 10);
|
||||
unsafe { RECORD = RECORD * 10 + r };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ fn strlen(str: String) -> usize {
|
|||
unsafe { mlibc::my_strlen(s.as_ptr()) as usize }
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let len = strlen("Rust".to_string());
|
||||
assert_eq!(len, 4);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ fn f(ccx: &Ccx) {
|
|||
return g(&fcx);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let ccx = Ccx { x: 0 };
|
||||
f(&ccx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ fn to_c_wchar_t_str(s: &str) -> Vec<libc::wchar_t> {
|
|||
r
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let s = to_c_wchar_t_str("Rust");
|
||||
let len = unsafe { libc::wcslen(s.as_ptr()) };
|
||||
assert_eq!(len, 4);
|
||||
|
|
|
|||
|
|
@ -212,7 +212,7 @@ fn test_single_thread() {
|
|||
fn test_sync_through_rmw_and_fences() {
|
||||
// Example from https://github.com/llvm/llvm-project/issues/56450#issuecomment-1183695905
|
||||
#[no_mangle]
|
||||
pub fn rdmw(storing: &AtomicI32, sync: &AtomicI32, loading: &AtomicI32) -> i32 {
|
||||
fn rdmw(storing: &AtomicI32, sync: &AtomicI32, loading: &AtomicI32) -> i32 {
|
||||
storing.store(1, Relaxed);
|
||||
fence(Release);
|
||||
sync.fetch_add(0, Relaxed);
|
||||
|
|
@ -245,7 +245,7 @@ fn test_sync_through_rmw_and_fences() {
|
|||
assert_ne!((a, b), (0, 0));
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
for _ in 0..50 {
|
||||
test_single_thread();
|
||||
test_mixed_access();
|
||||
|
|
|
|||
|
|
@ -348,7 +348,7 @@ fn test_sc_relaxed() {
|
|||
assert!(!bad);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
for _ in 0..32 {
|
||||
test_sc_store_buffering();
|
||||
test_iriw_sc_rlx();
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ fn from_mut_split() {
|
|||
assert_eq!(x_lo_atomic.load(Relaxed), u16::from_be(0xfafa));
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
get_mut_write();
|
||||
from_mut_split();
|
||||
assign_to_mut();
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ fn initialization_write(add_fence: bool) {
|
|||
fn faa_replaced_by_load() {
|
||||
check_all_outcomes([true, false], || {
|
||||
// Example from https://github.com/llvm/llvm-project/issues/56450#issuecomment-1183695905
|
||||
pub fn rdmw(storing: &AtomicUsize, sync: &AtomicUsize, loading: &AtomicUsize) -> usize {
|
||||
fn rdmw(storing: &AtomicUsize, sync: &AtomicUsize, loading: &AtomicUsize) -> usize {
|
||||
storing.store(1, Relaxed);
|
||||
fence(Release);
|
||||
// sync.fetch_add(0, Relaxed);
|
||||
|
|
@ -226,7 +226,7 @@ fn old_release_store() {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
relaxed();
|
||||
seq_cst();
|
||||
initialization_write(false);
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ pub const KEYBYTES: usize = 8 * size_of::<u64>();
|
|||
pub const BLOCKBYTES: usize = 16 * size_of::<u64>();
|
||||
|
||||
impl Params {
|
||||
pub fn new() -> Self {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
hash_length: OUTBYTES as u8,
|
||||
key_length: 0,
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::future::Future;
|
|||
use std::pin::pin;
|
||||
use std::task::*;
|
||||
|
||||
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
|
||||
fn block_on<T>(fut: impl Future<Output = T>) -> T {
|
||||
let mut fut = pin!(fut);
|
||||
let ctx = &mut Context::from_waker(Waker::noop());
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ use std::future::Future;
|
|||
use std::pin::pin;
|
||||
use std::task::*;
|
||||
|
||||
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
|
||||
fn block_on<T>(fut: impl Future<Output = T>) -> T {
|
||||
let mut fut = pin!(fut);
|
||||
let ctx = &mut Context::from_waker(Waker::noop());
|
||||
|
||||
|
|
@ -29,7 +29,7 @@ impl Drop for DropMe {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
block_on(async {
|
||||
let b = DropMe("hello");
|
||||
let async_closure = async move |a: DropMe| {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use std::ops::{AsyncFn, AsyncFnMut, AsyncFnOnce};
|
|||
use std::pin::pin;
|
||||
use std::task::*;
|
||||
|
||||
pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
|
||||
fn block_on<T>(fut: impl Future<Output = T>) -> T {
|
||||
let mut fut = pin!(fut);
|
||||
let ctx = &mut Context::from_waker(Waker::noop());
|
||||
|
||||
|
|
@ -38,7 +38,7 @@ async fn call_normal_mut<F: Future<Output = ()>>(f: &mut impl FnMut(i32) -> F) {
|
|||
f(1).await;
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
block_on(async {
|
||||
let b = 2i32;
|
||||
let mut async_closure = async move |a: i32| {
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ fn test_class() {
|
|||
assert!(q != r);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
test_nil();
|
||||
test_bool();
|
||||
test_ptr();
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ fn test_all_refs<'a, T: 'a>(dummy: &mut T, iter: impl Iterator<Item = &'a mut T>
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut b = BTreeSet::new();
|
||||
b.insert(Foo::A("\'"));
|
||||
b.insert(Foo::A("/="));
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ fn const_fn_call() -> i64 {
|
|||
}
|
||||
|
||||
fn call_return_into_passed_reference() {
|
||||
pub fn func<T>(v: &mut T, f: fn(&T) -> T) {
|
||||
fn func<T>(v: &mut T, f: fn(&T) -> T) {
|
||||
// MIR building will introduce a temporary, so this becomes
|
||||
// `let temp = f(v); *v = temp;`.
|
||||
// If this got optimized to `*v = f(v)` on the MIR level we'd have UB
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ fn test_multiple_reads() {
|
|||
assert_eq!(var, 10);
|
||||
}
|
||||
|
||||
pub fn test_rmw_no_block() {
|
||||
fn test_rmw_no_block() {
|
||||
static SYNC: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
let mut a = 0u32;
|
||||
|
|
@ -89,7 +89,7 @@ pub fn test_rmw_no_block() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn test_simple_release() {
|
||||
fn test_simple_release() {
|
||||
static SYNC: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
let mut a = 0u32;
|
||||
|
|
@ -214,7 +214,7 @@ fn failing_rmw_is_read() {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
test_fence_sync();
|
||||
test_multiple_reads();
|
||||
test_rmw_no_block();
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ struct EvilSend<T>(pub T);
|
|||
unsafe impl<T> Send for EvilSend<T> {}
|
||||
unsafe impl<T> Sync for EvilSend<T> {}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let mut a = 0u32;
|
||||
let b = &mut a as *mut u32;
|
||||
let c = EvilSend(b);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
fn f() {}
|
||||
static mut CLOSURES: &'static mut [fn()] = &mut [f as fn(), f as fn()];
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
unsafe {
|
||||
for closure in &mut *CLOSURES {
|
||||
(*closure)()
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ fn drop_in_place_with_terminator(ptr: *mut i32) {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
drop_in_place_with_terminator(std::ptr::without_provenance_mut(0));
|
||||
drop_in_place_with_terminator(std::ptr::without_provenance_mut(1));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ struct Foo<T: ?Sized> {
|
|||
f: T,
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// raw trait object
|
||||
let x = A { f: 42 };
|
||||
let z: *const dyn Trait = &x;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ impl ToBar for Bar {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// With a vec of ints.
|
||||
let f1 = Fat { ptr: [1, 2, 3] };
|
||||
foo(&f1);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ impl ToBar for Bar {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
// With a vec of ints.
|
||||
let f1: Fat<[isize; 3]> = Fat { f1: 5, f2: "some str", ptr: [1, 2, 3] };
|
||||
foo(&f1);
|
||||
|
|
|
|||
|
|
@ -3,6 +3,6 @@ static C: Result<(), Box<isize>> = Ok(());
|
|||
// This is because of yet another bad assertion (ICE) about the null side of a nullable enum.
|
||||
// So we won't actually compile if the bug is present, but we check the value in main anyway.
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
assert!(C.is_ok());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1037,7 +1037,7 @@ fn mul_add() {
|
|||
assert_eq!(f.to_bits(), f32::to_bits(-0.0));
|
||||
}
|
||||
|
||||
pub fn libm() {
|
||||
fn libm() {
|
||||
fn ldexp(a: f64, b: i32) -> f64 {
|
||||
extern "C" {
|
||||
fn ldexp(x: f64, n: i32) -> f64;
|
||||
|
|
@ -1300,7 +1300,7 @@ fn test_fast() {
|
|||
use std::intrinsics::{fadd_fast, fdiv_fast, fmul_fast, frem_fast, fsub_fast};
|
||||
|
||||
#[inline(never)]
|
||||
pub fn test_operations_f16(a: f16, b: f16) {
|
||||
fn test_operations_f16(a: f16, b: f16) {
|
||||
// make sure they all map to the correct operation
|
||||
unsafe {
|
||||
assert_approx_eq!(fadd_fast(a, b), a + b);
|
||||
|
|
@ -1312,7 +1312,7 @@ fn test_fast() {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn test_operations_f32(a: f32, b: f32) {
|
||||
fn test_operations_f32(a: f32, b: f32) {
|
||||
// make sure they all map to the correct operation
|
||||
unsafe {
|
||||
assert_approx_eq!(fadd_fast(a, b), a + b);
|
||||
|
|
@ -1324,7 +1324,7 @@ fn test_fast() {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn test_operations_f64(a: f64, b: f64) {
|
||||
fn test_operations_f64(a: f64, b: f64) {
|
||||
// make sure they all map to the correct operation
|
||||
unsafe {
|
||||
assert_approx_eq!(fadd_fast(a, b), a + b);
|
||||
|
|
@ -1336,7 +1336,7 @@ fn test_fast() {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn test_operations_f128(a: f128, b: f128) {
|
||||
fn test_operations_f128(a: f128, b: f128) {
|
||||
// make sure they all map to the correct operation
|
||||
unsafe {
|
||||
assert_approx_eq!(fadd_fast(a, b), a + b);
|
||||
|
|
@ -1363,7 +1363,7 @@ fn test_algebraic() {
|
|||
};
|
||||
|
||||
#[inline(never)]
|
||||
pub fn test_operations_f16(a: f16, b: f16) {
|
||||
fn test_operations_f16(a: f16, b: f16) {
|
||||
// make sure they all map to the correct operation
|
||||
assert_approx_eq!(fadd_algebraic(a, b), a + b);
|
||||
assert_approx_eq!(fsub_algebraic(a, b), a - b);
|
||||
|
|
@ -1373,7 +1373,7 @@ fn test_algebraic() {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn test_operations_f32(a: f32, b: f32) {
|
||||
fn test_operations_f32(a: f32, b: f32) {
|
||||
// make sure they all map to the correct operation
|
||||
assert_approx_eq!(fadd_algebraic(a, b), a + b);
|
||||
assert_approx_eq!(fsub_algebraic(a, b), a - b);
|
||||
|
|
@ -1383,7 +1383,7 @@ fn test_algebraic() {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn test_operations_f64(a: f64, b: f64) {
|
||||
fn test_operations_f64(a: f64, b: f64) {
|
||||
// make sure they all map to the correct operation
|
||||
assert_approx_eq!(fadd_algebraic(a, b), a + b);
|
||||
assert_approx_eq!(fsub_algebraic(a, b), a - b);
|
||||
|
|
@ -1393,7 +1393,7 @@ fn test_algebraic() {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn test_operations_f128(a: f128, b: f128) {
|
||||
fn test_operations_f128(a: f128, b: f128) {
|
||||
// make sure they all map to the correct operation
|
||||
assert_approx_eq!(fadd_algebraic(a, b), a + b);
|
||||
assert_approx_eq!(fsub_algebraic(a, b), a - b);
|
||||
|
|
@ -1418,12 +1418,12 @@ fn test_fmuladd() {
|
|||
// FIXME(f16_f128): add when supported
|
||||
|
||||
#[inline(never)]
|
||||
pub fn test_operations_f32(a: f32, b: f32, c: f32) {
|
||||
fn test_operations_f32(a: f32, b: f32, c: f32) {
|
||||
assert_approx_eq!(fmuladdf32(a, b, c), a * b + c);
|
||||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn test_operations_f64(a: f64, b: f64, c: f64) {
|
||||
fn test_operations_f64(a: f64, b: f64, c: f64) {
|
||||
assert_approx_eq!(fmuladdf64(a, b, c), a * b + c);
|
||||
}
|
||||
|
||||
|
|
@ -1468,10 +1468,10 @@ fn test_non_determinism() {
|
|||
};
|
||||
}
|
||||
|
||||
pub fn test_operations_f16(a: f16, b: f16) {
|
||||
fn test_operations_f16(a: f16, b: f16) {
|
||||
test_operations_f!(a, b);
|
||||
}
|
||||
pub fn test_operations_f32(a: f32, b: f32) {
|
||||
fn test_operations_f32(a: f32, b: f32) {
|
||||
test_operations_f!(a, b);
|
||||
check_nondet(|| a.powf(b));
|
||||
check_nondet(|| a.powi(2));
|
||||
|
|
@ -1507,7 +1507,7 @@ fn test_non_determinism() {
|
|||
check_nondet(|| 5.0f32.erf());
|
||||
check_nondet(|| 5.0f32.erfc());
|
||||
}
|
||||
pub fn test_operations_f64(a: f64, b: f64) {
|
||||
fn test_operations_f64(a: f64, b: f64) {
|
||||
test_operations_f!(a, b);
|
||||
check_nondet(|| a.powf(b));
|
||||
check_nondet(|| a.powi(2));
|
||||
|
|
@ -1538,7 +1538,7 @@ fn test_non_determinism() {
|
|||
check_nondet(|| 5.0f64.erf());
|
||||
check_nondet(|| 5.0f64.erfc());
|
||||
}
|
||||
pub fn test_operations_f128(a: f128, b: f128) {
|
||||
fn test_operations_f128(a: f128, b: f128) {
|
||||
test_operations_f!(a, b);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::intrinsics::mir::*;
|
|||
|
||||
// Make sure calls with the return place "on the heap" work.
|
||||
#[custom_mir(dialect = "runtime", phase = "optimized")]
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
mir! {
|
||||
{
|
||||
let x = 0;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ fn basic() {
|
|||
assert_eq!(match_int_range(), 4);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
basic();
|
||||
|
||||
// This tests that we do (not) do sign extension properly when loading integers
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
#![feature(core_intrinsics, funnel_shifts)]
|
||||
use std::intrinsics::*;
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
unsafe {
|
||||
[assert_eq!(ctpop(0u8), 0), assert_eq!(ctpop(0i8), 0)];
|
||||
[assert_eq!(ctpop(0u16), 0), assert_eq!(ctpop(0i16), 0)];
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#![feature(core_intrinsics)]
|
||||
use std::intrinsics::{volatile_load, volatile_store};
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
unsafe {
|
||||
let i: &mut (isize, isize) = &mut (0, 0);
|
||||
volatile_store(i, (1, 2));
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ fn main() {
|
|||
}
|
||||
|
||||
#[inline(never)]
|
||||
pub fn take(h: Handler, f: Box<dyn Fn()>) -> Box<dyn Fn()> {
|
||||
fn take(h: Handler, f: Box<dyn Fn()>) -> Box<dyn Fn()> {
|
||||
unsafe {
|
||||
match h {
|
||||
Handler::Custom(ptr) => *Box::from_raw(ptr),
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ fn print_s(s: &S) {
|
|||
s.print();
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let s: Box<S> = Box::new(S { s: 5 });
|
||||
print_s(&*s);
|
||||
let t: Box<dyn T> = s as Box<dyn T>;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
struct T(&'static [isize]);
|
||||
static STATIC: T = T(&[5, 4, 3]);
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let T(ref v) = STATIC;
|
||||
assert_eq!(v[0], 5);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
#![allow(unnecessary_transmutes)]
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let bytes: [u8; 8] = unsafe { ::std::mem::transmute(0u64) };
|
||||
let _val: &[u8] = &bytes;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::future::Future;
|
|||
use std::pin::Pin;
|
||||
use std::task::{Context, Poll, Waker};
|
||||
|
||||
pub fn fuzzing_block_on<O, F: Future<Output = O>>(fut: F) -> O {
|
||||
fn fuzzing_block_on<O, F: Future<Output = O>>(fut: F) -> O {
|
||||
let mut fut = std::pin::pin!(fut);
|
||||
let mut context = Context::from_waker(Waker::noop());
|
||||
loop {
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
pub fn box_new_with<T>()
|
||||
fn box_new_with<T>()
|
||||
where
|
||||
T: ?Sized,
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@ fn foo() -> Box<dyn FnMut() -> isize + 'static> {
|
|||
Box::new(result)
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
assert_eq!(foo()(), 22);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ fn never_returns() {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let value = 'outer: loop {
|
||||
if 1 == 1 {
|
||||
break 13;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ fn test(foo: Box<Vec<isize>>) {
|
|||
assert_eq!((*foo)[0], 10);
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
fn main() {
|
||||
let x = Box::new(vec![10]);
|
||||
// Test forgetting a local by move-in
|
||||
test(x);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
pub fn main() {
|
||||
fn main() {
|
||||
let x = Box::new(10);
|
||||
let y = x;
|
||||
assert_eq!(*y, 10);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue