remove a bunch of unnecessary 'pub' from tests

This commit is contained in:
Ralf Jung 2025-10-12 17:03:35 +02:00
parent f3c08df150
commit 61594ca4aa
113 changed files with 156 additions and 161 deletions

View file

@ -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;

View file

@ -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`

View file

@ -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

View file

@ -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/

View file

@ -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`

View file

@ -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
|

View file

@ -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;

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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`

View file

@ -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

View file

@ -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>>);

View file

@ -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>);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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>);

View file

@ -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);

View file

@ -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);

View file

@ -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>);

View file

@ -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(|| ());

View file

@ -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);

View file

@ -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>);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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);

View file

@ -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>);

View file

@ -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);
}

View file

@ -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;

View file

@ -29,6 +29,6 @@ fn main() {
}
}
pub fn callee(x: S) -> S {
fn callee(x: S) -> S {
x
}

View file

@ -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`!

View file

@ -22,6 +22,6 @@ fn main() {
}
}
pub fn change_arg(mut x: S) {
fn change_arg(mut x: S) {
x.0 = 0;
}

View file

@ -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.

View file

@ -7,7 +7,7 @@
use std::intrinsics::mir::*;
#[custom_mir(dialect = "runtime", phase = "optimized")]
pub fn main() {
fn main() {
mir! {
{
let _x = 0;

View file

@ -7,7 +7,7 @@
use std::intrinsics::mir::*;
#[custom_mir(dialect = "runtime", phase = "optimized")]
pub fn main() {
fn main() {
mir! {
{
let _x = 0;

View file

@ -9,7 +9,7 @@
use std::intrinsics::mir::*;
#[custom_mir(dialect = "runtime", phase = "optimized")]
pub fn main() {
fn main() {
mir! {
{
let _x = 0;

View file

@ -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",

View file

@ -1,6 +1,6 @@
#![feature(core_intrinsics)]
pub fn main() {
fn main() {
unsafe {
use std::intrinsics::*;

View file

@ -1,6 +1,6 @@
#![feature(core_intrinsics)]
pub fn main() {
fn main() {
unsafe {
use std::intrinsics::*;

View file

@ -11,7 +11,7 @@ pub struct Meta {
}
impl Meta {
pub fn new() -> Self {
fn new() -> Self {
Meta { drop_fn: |_| {}, size: 0, align: 1 }
}
}

View file

@ -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);

View file

@ -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

View file

@ -2,7 +2,7 @@
use std::cell::Cell;
pub fn main() {
fn main() {
thread_local! {
static TLS: Cell<Option<&'static i32>> = Cell::new(None);
}

View file

@ -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);

View file

@ -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)

View file

@ -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;

View file

@ -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;

View file

@ -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 {

View file

@ -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.

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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();

View file

@ -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,);

View file

@ -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 };
}

View file

@ -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);
}

View file

@ -39,7 +39,7 @@ fn f(ccx: &Ccx) {
return g(&fcx);
}
pub fn main() {
fn main() {
let ccx = Ccx { x: 0 };
f(&ccx);
}

View file

@ -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);

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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);

View file

@ -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,

View file

@ -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());

View file

@ -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| {

View file

@ -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| {

View file

@ -71,7 +71,7 @@ fn test_class() {
assert!(q != r);
}
pub fn main() {
fn main() {
test_nil();
test_bool();
test_ptr();

View file

@ -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("/="));

View file

@ -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

View file

@ -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();

View file

@ -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);

View file

@ -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)()

View file

@ -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));
}

View file

@ -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;

View file

@ -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);

View file

@ -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);

View file

@ -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());
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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

View file

@ -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)];

View file

@ -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));

View file

@ -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),

View file

@ -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>;

View file

@ -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);
}

View file

@ -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;
}

View file

@ -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 {

View file

@ -25,7 +25,7 @@ where
}
}
pub fn box_new_with<T>()
fn box_new_with<T>()
where
T: ?Sized,
{

View file

@ -12,6 +12,6 @@ fn foo() -> Box<dyn FnMut() -> isize + 'static> {
Box::new(result)
}
pub fn main() {
fn main() {
assert_eq!(foo()(), 22);
}

View file

@ -8,7 +8,7 @@ fn never_returns() {
}
}
pub fn main() {
fn main() {
let value = 'outer: loop {
if 1 == 1 {
break 13;

View file

@ -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);

View file

@ -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