Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 3ee5698

Browse files
committed
get rid of some uses of core_intrinsics
1 parent c33fc24 commit 3ee5698

10 files changed

+16
-29
lines changed

tests/fail/data_race/atomic_read_na_write_race1.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// We want to control preemption here.
22
//@compile-flags: -Zmiri-preemption-rate=0
33
//@ignore-target-windows: Concurrency on Windows is not supported yet.
4-
#![feature(core_intrinsics)]
54

6-
use std::intrinsics;
7-
use std::sync::atomic::AtomicUsize;
5+
use std::sync::atomic::{AtomicUsize, Ordering};
86
use std::thread::spawn;
97

108
#[derive(Copy, Clone)]
@@ -23,8 +21,7 @@ pub fn main() {
2321
});
2422

2523
let j2 = spawn(move || {
26-
//Equivalent to: (&*c.0).load(Ordering::SeqCst)
27-
intrinsics::atomic_load_seqcst(c.0 as *mut usize) //~ ERROR: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>`
24+
(&*c.0).load(Ordering::SeqCst) //~ ERROR: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>`
2825
});
2926

3027
j1.join().unwrap();

tests/fail/data_race/atomic_read_na_write_race1.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: Undefined Behavior: Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
22
--> $DIR/atomic_read_na_write_race1.rs:LL:CC
33
|
4-
LL | intrinsics::atomic_load_seqcst(c.0 as *mut usize)
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
4+
LL | (&*c.0).load(Ordering::SeqCst)
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Load on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information

tests/fail/data_race/atomic_write_na_read_race2.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// We want to control preemption here.
22
//@compile-flags: -Zmiri-preemption-rate=0
33
//@ignore-target-windows: Concurrency on Windows is not supported yet.
4-
#![feature(core_intrinsics)]
54

6-
use std::intrinsics::atomic_store;
7-
use std::sync::atomic::AtomicUsize;
5+
use std::sync::atomic::{AtomicUsize, Ordering};
86
use std::thread::spawn;
97

108
#[derive(Copy, Clone)]
@@ -23,8 +21,7 @@ pub fn main() {
2321
});
2422

2523
let j2 = spawn(move || {
26-
//Equivalent to: (&*c.0).store(32, Ordering::SeqCst)
27-
atomic_store(c.0 as *mut usize, 32); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>`
24+
(&*c.0).store(32, Ordering::SeqCst); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>`
2825
});
2926

3027
j1.join().unwrap();

tests/fail/data_race/atomic_write_na_read_race2.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: Undefined Behavior: Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>` at ALLOC
22
--> $DIR/atomic_write_na_read_race2.rs:LL:CC
33
|
4-
LL | atomic_store(c.0 as *mut usize, 32);
4+
LL | (&*c.0).store(32, Ordering::SeqCst);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Store on thread `<unnamed>` and Read on thread `<unnamed>` at ALLOC
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior

tests/fail/data_race/atomic_write_na_write_race1.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
// We want to control preemption here.
22
//@compile-flags: -Zmiri-preemption-rate=0
33
//@ignore-target-windows: Concurrency on Windows is not supported yet.
4-
#![feature(core_intrinsics)]
54

6-
use std::intrinsics::atomic_store;
7-
use std::sync::atomic::AtomicUsize;
5+
use std::sync::atomic::{AtomicUsize, Ordering};
86
use std::thread::spawn;
97

108
#[derive(Copy, Clone)]
@@ -23,8 +21,7 @@ pub fn main() {
2321
});
2422

2523
let j2 = spawn(move || {
26-
//Equivalent to: (&*c.0).store(64, Ordering::SeqCst)
27-
atomic_store(c.0 as *mut usize, 64); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>`
24+
(&*c.0).store(64, Ordering::SeqCst); //~ ERROR: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>`
2825
});
2926

3027
j1.join().unwrap();

tests/fail/data_race/atomic_write_na_write_race1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error: Undefined Behavior: Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
22
--> $DIR/atomic_write_na_write_race1.rs:LL:CC
33
|
4-
LL | atomic_store(c.0 as *mut usize, 64);
4+
LL | (&*c.0).store(64, Ordering::SeqCst);
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Data race detected between Atomic Store on thread `<unnamed>` and Write on thread `<unnamed>` at ALLOC
66
|
77
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior

tests/fail/weak_memory/racing_mixed_size_read.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
//@compile-flags: -Zmiri-preemption-rate=0
33
//@ignore-target-windows: Concurrency on Windows is not supported yet.
44

5-
#![feature(core_intrinsics)]
6-
7-
use std::sync::atomic::AtomicU32;
85
use std::sync::atomic::Ordering::*;
6+
use std::sync::atomic::{AtomicU16, AtomicU32};
97
use std::thread::spawn;
108

119
fn static_atomic(val: u32) -> &'static AtomicU32 {
@@ -31,8 +29,8 @@ pub fn main() {
3129
let x_ptr = x as *const AtomicU32 as *const u32;
3230
let x_split = split_u32_ptr(x_ptr);
3331
unsafe {
34-
let hi = &(*x_split)[0] as *const u16;
35-
std::intrinsics::atomic_load_relaxed(hi); //~ ERROR: imperfectly overlapping
32+
let hi = x_split as *const u16 as *const AtomicU16;
33+
(*hi).load(Relaxed); //~ ERROR: imperfectly overlapping
3634
}
3735
});
3836

tests/fail/weak_memory/racing_mixed_size_read.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
error: unsupported operation: racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
22
--> $DIR/racing_mixed_size_read.rs:LL:CC
33
|
4-
LL | std::intrinsics::atomic_load_relaxed(hi);
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
4+
LL | (*hi).load(Relaxed);
5+
| ^^^^^^^^^^^^^^^^^^^ racy imperfectly overlapping atomic access is not possible in the C++20 memory model, and not supported by Miri's weak memory emulation
66
|
77
= help: this is likely not a bug in the program; it indicates that the program performed an operation that the interpreter does not support
88
= note: backtrace:

tests/pass/weak_memory/extra_cpp.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
// but doable in safe (at least sound) Rust.
66

77
#![feature(atomic_from_mut)]
8-
#![feature(core_intrinsics)]
98

109
use std::sync::atomic::Ordering::*;
1110
use std::sync::atomic::{AtomicU16, AtomicU32};

tests/pass/weak_memory/extra_cpp_unsafe.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// memory model in the future.
88

99
#![feature(atomic_from_mut)]
10-
#![feature(core_intrinsics)]
1110

1211
use std::sync::atomic::AtomicU32;
1312
use std::sync::atomic::Ordering::*;
@@ -27,7 +26,7 @@ fn racing_mixed_atomicity_read() {
2726

2827
let j2 = spawn(move || {
2928
let x_ptr = x as *const AtomicU32 as *const u32;
30-
unsafe { std::intrinsics::atomic_load_relaxed(x_ptr) }
29+
unsafe { x_ptr.read() }
3130
});
3231

3332
let r1 = j1.join().unwrap();

0 commit comments

Comments
 (0)