Adjust atomic-from-mut-not-available.rs
- Introduce two revisions: one for 32-bit x86 vs one for 64-bit x86_64 and compare & contrast the errors. - Document the test intention and note its limitations.
This commit is contained in:
parent
1247f01a3c
commit
754dec3fbc
3 changed files with 53 additions and 3 deletions
|
@ -0,0 +1,13 @@
|
|||
error[E0658]: use of unstable library feature `atomic_from_mut`
|
||||
--> $DIR/atomic-from-mut-not-available.rs:24:5
|
||||
|
|
||||
LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64);
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: see issue #76314 <https://github.com/rust-lang/rust/issues/76314> for more information
|
||||
= help: add `#![feature(atomic_from_mut)]` to the crate attributes to enable
|
||||
= note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
|
@ -0,0 +1,17 @@
|
|||
error[E0599]: no function or associated item named `from_mut` found for struct `AtomicU64` in the current scope
|
||||
--> $DIR/atomic-from-mut-not-available.rs:24:36
|
||||
|
|
||||
LL | core::sync::atomic::AtomicU64::from_mut(&mut 0u64);
|
||||
| ^^^^^^^^ function or associated item not found in `AtomicU64`
|
||||
|
|
||||
note: if you're trying to build a new `AtomicU64`, consider using `AtomicU64::new` which returns `AtomicU64`
|
||||
--> $SRC_DIR/core/src/sync/atomic.rs:LL:COL
|
||||
= note: this error originates in the macro `atomic_int` (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
help: there is an associated function `from` with a similar name
|
||||
|
|
||||
LL | core::sync::atomic::AtomicU64::from(&mut 0u64);
|
||||
| ~~~~
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0599`.
|
|
@ -1,7 +1,27 @@
|
|||
//@ only-x86
|
||||
//@ only-linux
|
||||
//! This test exercises the combined effect of the `cfg(target_has_atomic_equal_alignment = "...")`
|
||||
//! implementation in the compiler plus usage of said `cfg(target_has_atomic_equal_alignment)` in
|
||||
//! `core` for the `Atomic64::from_mut` API.
|
||||
//!
|
||||
//! This test is a basic smoke test: that `AtomicU64::from_mut` is gated by
|
||||
//! `#[cfg(target_has_atomic_equal_alignment = "8")]`, which is only available on platforms where
|
||||
//! `AtomicU64` has the same alignment as `u64`. This is notably *not* satisfied by `x86_32`, where
|
||||
//! they have differing alignments. Thus, `AtomicU64::from_mut` should *not* be available on
|
||||
//! `x86_32` linux and should report assoc item not found, if the `cfg` is working correctly.
|
||||
//! Conversely, `AtomicU64::from_mut` *should* be available on `x86_64` linux where the alignment
|
||||
//! matches.
|
||||
|
||||
//@ revisions: alignment_mismatch alignment_matches
|
||||
|
||||
// This should fail on 32-bit x86 linux...
|
||||
//@[alignment_mismatch] only-x86
|
||||
//@[alignment_mismatch] only-linux
|
||||
|
||||
// ... but pass on 64-bit x86_64 linux.
|
||||
//@[alignment_matches] only-x86_64
|
||||
//@[alignment_matches] only-linux
|
||||
|
||||
fn main() {
|
||||
core::sync::atomic::AtomicU64::from_mut(&mut 0u64);
|
||||
//~^ ERROR: no function or associated item named `from_mut` found for struct `AtomicU64`
|
||||
//[alignment_mismatch]~^ ERROR no function or associated item named `from_mut` found for struct `AtomicU64`
|
||||
//[alignment_matches]~^^ ERROR use of unstable library feature `atomic_from_mut`
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue