Adjust atomic-from-mut-not-available.rs
· rust-lang/rust@754dec3 (original) (raw)
File tree
3 files changed
lines changed
- tests/ui/stdlib-unit-tests
3 files changed
lines changed
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
1 | +error[E0658]: use of unstable library feature `atomic_from_mut` | |
2 | + --> $DIR/atomic-from-mut-not-available.rs:24:5 | |
3 | + | | |
4 | +LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64); | |
5 | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | |
6 | + | | |
7 | + = note: see issue #76314 https://github.com/rust-lang/rust/issues/76314 for more information | |
8 | + = help: add `#![feature(atomic_from_mut)]` to the crate attributes to enable | |
9 | + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date | |
10 | + | |
11 | +error: aborting due to 1 previous error | |
12 | + | |
13 | +For more information about this error, try `rustc --explain E0658`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
1 | +error[E0599]: no function or associated item named `from_mut` found for struct `AtomicU64` in the current scope | |
2 | + --> $DIR/atomic-from-mut-not-available.rs:24:36 | |
3 | + | | |
4 | +LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64); | |
5 | + | ^^^^^^^^ function or associated item not found in `AtomicU64` | |
6 | + | | |
7 | +note: if you're trying to build a new `AtomicU64`, consider using `AtomicU64::new` which returns `AtomicU64` | |
8 | + --> $SRC_DIR/core/src/sync/atomic.rs:LL:COL | |
9 | + = note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info) | |
10 | +help: there is an associated function `from` with a similar name | |
11 | + | | |
12 | +LL | core::sync::atomic::AtomicU64::from(&mut 0u64); | |
13 | + | ~~~~ | |
14 | + | |
15 | +error: aborting due to 1 previous error | |
16 | + | |
17 | +For more information about this error, try `rustc --explain E0599`. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
1 | -//@ only-x86 | |
2 | -//@ only-linux | |
1 | +//! This test exercises the combined effect of the `cfg(target_has_atomic_equal_alignment = "...")` | |
2 | +//! implementation in the compiler plus usage of said `cfg(target_has_atomic_equal_alignment)` in | |
3 | +//! `core` for the `Atomic64::from_mut` API. | |
4 | +//! | |
5 | +//! This test is a basic smoke test: that `AtomicU64::from_mut` is gated by | |
6 | +//! `#[cfg(target_has_atomic_equal_alignment = "8")]`, which is only available on platforms where | |
7 | +//! `AtomicU64` has the same alignment as `u64`. This is notably *not* satisfied by `x86_32`, where | |
8 | +//! they have differing alignments. Thus, `AtomicU64::from_mut` should *not* be available on | |
9 | +//! `x86_32` linux and should report assoc item not found, if the `cfg` is working correctly. | |
10 | +//! Conversely, `AtomicU64::from_mut` *should* be available on `x86_64` linux where the alignment | |
11 | +//! matches. | |
12 | + | |
13 | +//@ revisions: alignment_mismatch alignment_matches | |
14 | + | |
15 | +// This should fail on 32-bit x86 linux... | |
16 | +//@[alignment_mismatch] only-x86 | |
17 | +//@[alignment_mismatch] only-linux | |
18 | + | |
19 | +// ... but pass on 64-bit x86_64 linux. | |
20 | +//@[alignment_matches] only-x86_64 | |
21 | +//@[alignment_matches] only-linux | |
3 | 22 | |
4 | 23 | fn main() { |
5 | 24 | core::sync::atomic::AtomicU64::from_mut(&mut 0u64); |
6 | -//~^ ERROR: no function or associated item named `from_mut` found for struct `AtomicU64` | |
25 | +//[alignment_mismatch]~^ ERROR no function or associated item named `from_mut` found for struct `AtomicU64` | |
26 | +//[alignment_matches]~^^ ERROR use of unstable library feature `atomic_from_mut` | |
7 | 27 | } |