-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
3 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_matches.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
17 changes: 17 additions & 0 deletions
17
tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.alignment_mismatch.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |
26 changes: 23 additions & 3 deletions
26
tests/ui/stdlib-unit-tests/atomic-from-mut-not-available.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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` | ||
} |