mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Support atomic fence intrinsic
This commit is contained in:
parent
b7d91ca5b2
commit
17cc813e92
5 changed files with 24 additions and 6 deletions
|
@ -2521,12 +2521,16 @@ fn const_trait_assoc() {
|
|||
);
|
||||
check_number(
|
||||
r#"
|
||||
//- minicore: size_of
|
||||
//- minicore: size_of, fn
|
||||
//- /a/lib.rs crate:a
|
||||
use core::mem::size_of;
|
||||
pub struct S<T>(T);
|
||||
impl<T> S<T> {
|
||||
pub const X: usize = core::mem::size_of::<T>();
|
||||
pub const X: usize = {
|
||||
let k: T;
|
||||
let f = || core::mem::size_of::<T>();
|
||||
f()
|
||||
};
|
||||
}
|
||||
//- /main.rs crate:main deps:a
|
||||
use a::{S};
|
||||
|
|
|
@ -438,6 +438,8 @@ fn atomic() {
|
|||
pub fn atomic_nand_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
|
||||
pub fn atomic_or_release<T: Copy>(dst: *mut T, src: T) -> T;
|
||||
pub fn atomic_xor_seqcst<T: Copy>(dst: *mut T, src: T) -> T;
|
||||
pub fn atomic_fence_seqcst();
|
||||
pub fn atomic_singlethreadfence_acqrel();
|
||||
}
|
||||
|
||||
fn should_not_reach() {
|
||||
|
@ -452,6 +454,7 @@ fn atomic() {
|
|||
if (30, true) != atomic_cxchg_release_seqcst(&mut y, 30, 40) {
|
||||
should_not_reach();
|
||||
}
|
||||
atomic_fence_seqcst();
|
||||
if (40, false) != atomic_cxchg_release_seqcst(&mut y, 30, 50) {
|
||||
should_not_reach();
|
||||
}
|
||||
|
@ -459,6 +462,7 @@ fn atomic() {
|
|||
should_not_reach();
|
||||
}
|
||||
let mut z = atomic_xsub_seqcst(&mut x, -200);
|
||||
atomic_singlethreadfence_acqrel();
|
||||
atomic_xor_seqcst(&mut x, 1024);
|
||||
atomic_load_seqcst(&x) + z * 3 + atomic_load_seqcst(&y) * 2
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue