File tree Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Expand file tree Collapse file tree 2 files changed +9
-7
lines changed Original file line number Diff line number Diff line change 1
- // Issue #8380
1
+ //! Check that atomic types from `std::sync::atomic` are not `Copy`
2
+ //! and cannot be moved out of a shared reference.
3
+ //!
4
+ //! Regression test for <https://github.com/rust-lang/rust/issues/8380>.
2
5
3
-
4
- use std:: sync:: atomic:: * ;
5
6
use std:: ptr;
7
+ use std:: sync:: atomic:: * ;
6
8
7
9
fn main ( ) {
8
10
let x = AtomicBool :: new ( false ) ;
Original file line number Diff line number Diff line change 1
1
error[E0507]: cannot move out of a shared reference
2
- --> $DIR/std-uncopyable-atomics .rs:9 :13
2
+ --> $DIR/atomic-types-not-copyable .rs:10 :13
3
3
|
4
4
LL | let x = *&x;
5
5
| ^^^ move occurs because value has type `std::sync::atomic::AtomicBool`, which does not implement the `Copy` trait
@@ -11,7 +11,7 @@ LL + let x = &x;
11
11
|
12
12
13
13
error[E0507]: cannot move out of a shared reference
14
- --> $DIR/std-uncopyable-atomics .rs:11 :13
14
+ --> $DIR/atomic-types-not-copyable .rs:12 :13
15
15
|
16
16
LL | let x = *&x;
17
17
| ^^^ move occurs because value has type `std::sync::atomic::AtomicIsize`, which does not implement the `Copy` trait
@@ -23,7 +23,7 @@ LL + let x = &x;
23
23
|
24
24
25
25
error[E0507]: cannot move out of a shared reference
26
- --> $DIR/std-uncopyable-atomics .rs:13 :13
26
+ --> $DIR/atomic-types-not-copyable .rs:14 :13
27
27
|
28
28
LL | let x = *&x;
29
29
| ^^^ move occurs because value has type `std::sync::atomic::AtomicUsize`, which does not implement the `Copy` trait
@@ -35,7 +35,7 @@ LL + let x = &x;
35
35
|
36
36
37
37
error[E0507]: cannot move out of a shared reference
38
- --> $DIR/std-uncopyable-atomics .rs:15 :13
38
+ --> $DIR/atomic-types-not-copyable .rs:16 :13
39
39
|
40
40
LL | let x = *&x;
41
41
| ^^^ move occurs because value has type `std::sync::atomic::AtomicPtr<usize>`, which does not implement the `Copy` trait
You can’t perform that action at this time.
0 commit comments