Skip to content

Commit 6d4c642

Browse files
committed
Use ignore/keep-wasm32 where appropriate.
1 parent b2aeb0f commit 6d4c642

7 files changed

+72
-2
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// compile-flags: --extern std=
2+
// error-pattern: can't find crate for `std`
3+
// only-wasm32
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error: extern location for std does not exist:
2+
3+
error[E0463]: can't find crate for `std`
4+
|
5+
= note: the `wasm32-unknown-unknown` target may not be installed
6+
7+
error: aborting due to 2 previous errors
8+
9+
For more information about this error, try `rustc --explain E0463`.
+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// compile-flags: --extern std=
22
// error-pattern: can't find crate for `std`
3+
// ignore-wasm32
34

45
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// only-wasm32
2+
3+
#![feature(cfg_target_thread_local, thread_local_internals)]
4+
5+
// On platforms *without* `#[thread_local]`, use
6+
// a custom non-`Sync` type to fake the same error.
7+
#[cfg(not(target_thread_local))]
8+
struct Key<T> {
9+
_data: std::cell::UnsafeCell<Option<T>>,
10+
_flag: std::cell::Cell<()>,
11+
}
12+
13+
#[cfg(not(target_thread_local))]
14+
impl<T> Key<T> {
15+
const fn new() -> Self {
16+
Key {
17+
_data: std::cell::UnsafeCell::new(None),
18+
_flag: std::cell::Cell::new(()),
19+
}
20+
}
21+
}
22+
23+
#[cfg(target_thread_local)]
24+
use std::thread::__FastLocalKeyInner as Key;
25+
26+
static __KEY: Key<()> = Key::new();
27+
//~^ ERROR `std::cell::UnsafeCell<std::option::Option<()>>` cannot be shared between threads
28+
//~| ERROR cannot be shared between threads safely [E0277]
29+
30+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0277]: `std::cell::UnsafeCell<std::option::Option<()>>` cannot be shared between threads safely
2+
--> $DIR/issue-43733-2-wasm.rs:26:1
3+
|
4+
LL | static __KEY: Key<()> = Key::new();
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<std::option::Option<()>>` cannot be shared between threads safely
6+
|
7+
= help: within `Key<()>`, the trait `std::marker::Sync` is not implemented for `std::cell::UnsafeCell<std::option::Option<()>>`
8+
= note: required because it appears within the type `Key<()>`
9+
= note: shared static variables must have a type that implements `Sync`
10+
11+
error[E0277]: `std::cell::Cell<()>` cannot be shared between threads safely
12+
--> $DIR/issue-43733-2-wasm.rs:26:1
13+
|
14+
LL | static __KEY: Key<()> = Key::new();
15+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::Cell<()>` cannot be shared between threads safely
16+
|
17+
= help: within `Key<()>`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell<()>`
18+
= note: required because it appears within the type `Key<()>`
19+
= note: shared static variables must have a type that implements `Sync`
20+
21+
error: aborting due to 2 previous errors
22+
23+
For more information about this error, try `rustc --explain E0277`.

src/test/ui/thread-local/issue-43733-2.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// ignore-wasm32
2+
13
#![feature(cfg_target_thread_local, thread_local_internals)]
24

35
// On platforms *without* `#[thread_local]`, use

src/test/ui/thread-local/issue-43733-2.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0277]: `std::cell::Cell<std::thread::local::fast::DtorState>` cannot be shared between threads safely
2-
--> $DIR/issue-43733-2.rs:24:1
2+
--> $DIR/issue-43733-2.rs:26:1
33
|
44
LL | static __KEY: Key<()> = Key::new();
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::Cell<std::thread::local::fast::DtorState>` cannot be shared between threads safely
@@ -9,7 +9,7 @@ LL | static __KEY: Key<()> = Key::new();
99
= note: shared static variables must have a type that implements `Sync`
1010

1111
error[E0277]: `std::cell::UnsafeCell<std::option::Option<()>>` cannot be shared between threads safely
12-
--> $DIR/issue-43733-2.rs:24:1
12+
--> $DIR/issue-43733-2.rs:26:1
1313
|
1414
LL | static __KEY: Key<()> = Key::new();
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell<std::option::Option<()>>` cannot be shared between threads safely

0 commit comments

Comments
 (0)