From 6d4c642968d81db3291561b3f304f4197642d893 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Sat, 29 Jun 2019 19:25:25 +0200 Subject: [PATCH] Use ignore/keep-wasm32 where appropriate. --- src/test/ui/imports/empty-extern-arg-wasm.rs | 5 ++++ .../ui/imports/empty-extern-arg-wasm.stderr | 9 ++++++ src/test/ui/imports/empty-extern-arg.rs | 1 + .../ui/thread-local/issue-43733-2-wasm.rs | 30 +++++++++++++++++++ .../ui/thread-local/issue-43733-2-wasm.stderr | 23 ++++++++++++++ src/test/ui/thread-local/issue-43733-2.rs | 2 ++ src/test/ui/thread-local/issue-43733-2.stderr | 4 +-- 7 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 src/test/ui/imports/empty-extern-arg-wasm.rs create mode 100644 src/test/ui/imports/empty-extern-arg-wasm.stderr create mode 100644 src/test/ui/thread-local/issue-43733-2-wasm.rs create mode 100644 src/test/ui/thread-local/issue-43733-2-wasm.stderr diff --git a/src/test/ui/imports/empty-extern-arg-wasm.rs b/src/test/ui/imports/empty-extern-arg-wasm.rs new file mode 100644 index 0000000000000..572fb85c24599 --- /dev/null +++ b/src/test/ui/imports/empty-extern-arg-wasm.rs @@ -0,0 +1,5 @@ +// compile-flags: --extern std= +// error-pattern: can't find crate for `std` +// only-wasm32 + +fn main() {} diff --git a/src/test/ui/imports/empty-extern-arg-wasm.stderr b/src/test/ui/imports/empty-extern-arg-wasm.stderr new file mode 100644 index 0000000000000..26dba1c2363ef --- /dev/null +++ b/src/test/ui/imports/empty-extern-arg-wasm.stderr @@ -0,0 +1,9 @@ +error: extern location for std does not exist: + +error[E0463]: can't find crate for `std` + | + = note: the `wasm32-unknown-unknown` target may not be installed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0463`. diff --git a/src/test/ui/imports/empty-extern-arg.rs b/src/test/ui/imports/empty-extern-arg.rs index ae28fcad903be..730a0225516f9 100644 --- a/src/test/ui/imports/empty-extern-arg.rs +++ b/src/test/ui/imports/empty-extern-arg.rs @@ -1,4 +1,5 @@ // compile-flags: --extern std= // error-pattern: can't find crate for `std` +// ignore-wasm32 fn main() {} diff --git a/src/test/ui/thread-local/issue-43733-2-wasm.rs b/src/test/ui/thread-local/issue-43733-2-wasm.rs new file mode 100644 index 0000000000000..69d8762e91862 --- /dev/null +++ b/src/test/ui/thread-local/issue-43733-2-wasm.rs @@ -0,0 +1,30 @@ +// only-wasm32 + +#![feature(cfg_target_thread_local, thread_local_internals)] + +// On platforms *without* `#[thread_local]`, use +// a custom non-`Sync` type to fake the same error. +#[cfg(not(target_thread_local))] +struct Key { + _data: std::cell::UnsafeCell>, + _flag: std::cell::Cell<()>, +} + +#[cfg(not(target_thread_local))] +impl Key { + const fn new() -> Self { + Key { + _data: std::cell::UnsafeCell::new(None), + _flag: std::cell::Cell::new(()), + } + } +} + +#[cfg(target_thread_local)] +use std::thread::__FastLocalKeyInner as Key; + +static __KEY: Key<()> = Key::new(); +//~^ ERROR `std::cell::UnsafeCell>` cannot be shared between threads +//~| ERROR cannot be shared between threads safely [E0277] + +fn main() {} diff --git a/src/test/ui/thread-local/issue-43733-2-wasm.stderr b/src/test/ui/thread-local/issue-43733-2-wasm.stderr new file mode 100644 index 0000000000000..123d3dab9b8f6 --- /dev/null +++ b/src/test/ui/thread-local/issue-43733-2-wasm.stderr @@ -0,0 +1,23 @@ +error[E0277]: `std::cell::UnsafeCell>` cannot be shared between threads safely + --> $DIR/issue-43733-2-wasm.rs:26:1 + | +LL | static __KEY: Key<()> = Key::new(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell>` cannot be shared between threads safely + | + = help: within `Key<()>`, the trait `std::marker::Sync` is not implemented for `std::cell::UnsafeCell>` + = note: required because it appears within the type `Key<()>` + = note: shared static variables must have a type that implements `Sync` + +error[E0277]: `std::cell::Cell<()>` cannot be shared between threads safely + --> $DIR/issue-43733-2-wasm.rs:26:1 + | +LL | static __KEY: Key<()> = Key::new(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::Cell<()>` cannot be shared between threads safely + | + = help: within `Key<()>`, the trait `std::marker::Sync` is not implemented for `std::cell::Cell<()>` + = note: required because it appears within the type `Key<()>` + = note: shared static variables must have a type that implements `Sync` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/src/test/ui/thread-local/issue-43733-2.rs b/src/test/ui/thread-local/issue-43733-2.rs index dae27c4785f15..2ed81da8e9b64 100644 --- a/src/test/ui/thread-local/issue-43733-2.rs +++ b/src/test/ui/thread-local/issue-43733-2.rs @@ -1,3 +1,5 @@ +// ignore-wasm32 + #![feature(cfg_target_thread_local, thread_local_internals)] // On platforms *without* `#[thread_local]`, use diff --git a/src/test/ui/thread-local/issue-43733-2.stderr b/src/test/ui/thread-local/issue-43733-2.stderr index ae8ccf1e9f1a1..7d97a9086590c 100644 --- a/src/test/ui/thread-local/issue-43733-2.stderr +++ b/src/test/ui/thread-local/issue-43733-2.stderr @@ -1,5 +1,5 @@ error[E0277]: `std::cell::Cell` cannot be shared between threads safely - --> $DIR/issue-43733-2.rs:24:1 + --> $DIR/issue-43733-2.rs:26:1 | LL | static __KEY: Key<()> = Key::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::Cell` cannot be shared between threads safely @@ -9,7 +9,7 @@ LL | static __KEY: Key<()> = Key::new(); = note: shared static variables must have a type that implements `Sync` error[E0277]: `std::cell::UnsafeCell>` cannot be shared between threads safely - --> $DIR/issue-43733-2.rs:24:1 + --> $DIR/issue-43733-2.rs:26:1 | LL | static __KEY: Key<()> = Key::new(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `std::cell::UnsafeCell>` cannot be shared between threads safely