about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDylan DPC <dylan.dpc@gmail.com>2020-09-23 14:54:04 +0200
committerGitHub <noreply@github.com>2020-09-23 14:54:04 +0200
commiteaaf5d7e38b1ee2306cac1ccbcbf3b18bdc6235c (patch)
tree54a4256f3d5f33ca005db987915e4d2db0365feb /src
parent98e5ee7df02c7812441ac31338819cb3f788f4f9 (diff)
parentbcc1d56917fe061071ebc539b5d2e304a44a7b00 (diff)
Rollup merge of #76965 - fusion-engineering-forks:fix-atomic-from-mut, r=Amanieu
Add cfg(target_has_atomic_equal_alignment) and use it for Atomic::from_mut.

Fixes some platform-specific problems with #74532 by using the actual alignment of the types instead of hardcoding a few `target_arch`s.

r? @RalfJung
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/atomic-from-mut-not-available.rs7
-rw-r--r--src/test/ui/atomic-from-mut-not-available.stderr9
-rw-r--r--src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs24
-rw-r--r--src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr110
4 files changed, 149 insertions, 1 deletions
diff --git a/src/test/ui/atomic-from-mut-not-available.rs b/src/test/ui/atomic-from-mut-not-available.rs
new file mode 100644
index 00000000000..bf946160075
--- /dev/null
+++ b/src/test/ui/atomic-from-mut-not-available.rs
@@ -0,0 +1,7 @@
+// only-x86
+// 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`
+}
diff --git a/src/test/ui/atomic-from-mut-not-available.stderr b/src/test/ui/atomic-from-mut-not-available.stderr
new file mode 100644
index 00000000000..d1ebca8a29e
--- /dev/null
+++ b/src/test/ui/atomic-from-mut-not-available.stderr
@@ -0,0 +1,9 @@
+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:5:36
+   |
+LL |     core::sync::atomic::AtomicU64::from_mut(&mut 0u64);
+   |                                    ^^^^^^^^ function or associated item not found in `AtomicU64`
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0599`.
diff --git a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs
index 506b21dc7d5..049fdd84d8c 100644
--- a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs
+++ b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.rs
@@ -87,6 +87,30 @@ fn main() {
     //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change
     cfg!(target_has_atomic = "ptr");
     //~^ ERROR `cfg(target_has_atomic)` is experimental and subject to change
+    cfg!(target_has_atomic_load_store = "8");
+    //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change
+    cfg!(target_has_atomic_load_store = "16");
+    //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change
+    cfg!(target_has_atomic_load_store = "32");
+    //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change
+    cfg!(target_has_atomic_load_store = "64");
+    //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change
+    cfg!(target_has_atomic_load_store = "128");
+    //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change
+    cfg!(target_has_atomic_load_store = "ptr");
+    //~^ ERROR `cfg(target_has_atomic_load_store)` is experimental and subject to change
+    cfg!(target_has_atomic_equal_alignment = "8");
+    //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+    cfg!(target_has_atomic_equal_alignment = "16");
+    //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+    cfg!(target_has_atomic_equal_alignment = "32");
+    //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+    cfg!(target_has_atomic_equal_alignment = "64");
+    //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+    cfg!(target_has_atomic_equal_alignment = "128");
+    //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+    cfg!(target_has_atomic_equal_alignment = "ptr");
+    //~^ ERROR `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
 }
 
 #[macro_export]
diff --git a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr
index 6132c530878..16e1dc64400 100644
--- a/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr
+++ b/src/test/ui/feature-gates/feature-gate-cfg-target-has-atomic.stderr
@@ -160,6 +160,114 @@ LL |     cfg!(target_has_atomic = "ptr");
    = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
    = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
 
-error: aborting due to 18 previous errors
+error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:90:10
+   |
+LL |     cfg!(target_has_atomic_load_store = "8");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:92:10
+   |
+LL |     cfg!(target_has_atomic_load_store = "16");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:94:10
+   |
+LL |     cfg!(target_has_atomic_load_store = "32");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:96:10
+   |
+LL |     cfg!(target_has_atomic_load_store = "64");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:98:10
+   |
+LL |     cfg!(target_has_atomic_load_store = "128");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_load_store)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:100:10
+   |
+LL |     cfg!(target_has_atomic_load_store = "ptr");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:102:10
+   |
+LL |     cfg!(target_has_atomic_equal_alignment = "8");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:104:10
+   |
+LL |     cfg!(target_has_atomic_equal_alignment = "16");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:106:10
+   |
+LL |     cfg!(target_has_atomic_equal_alignment = "32");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:108:10
+   |
+LL |     cfg!(target_has_atomic_equal_alignment = "64");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:110:10
+   |
+LL |     cfg!(target_has_atomic_equal_alignment = "128");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error[E0658]: `cfg(target_has_atomic_equal_alignment)` is experimental and subject to change
+  --> $DIR/feature-gate-cfg-target-has-atomic.rs:112:10
+   |
+LL |     cfg!(target_has_atomic_equal_alignment = "ptr");
+   |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #32976 <https://github.com/rust-lang/rust/issues/32976> for more information
+   = help: add `#![feature(cfg_target_has_atomic)]` to the crate attributes to enable
+
+error: aborting due to 30 previous errors
 
 For more information about this error, try `rustc --explain E0658`.