about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-07-26 11:12:22 +0200
committerRalf Jung <post@ralfj.de>2020-07-26 11:12:22 +0200
commitdebe597a9a4339f7ea7dc58fbfe8196aadacc593 (patch)
treeb6b4f12bbfab961674fe376f4868971aac3aa89b
parent1d9efbbd8f618b1618840c2ab677feed52eac138 (diff)
downloadrust-debe597a9a4339f7ea7dc58fbfe8196aadacc593.tar.gz
rust-debe597a9a4339f7ea7dc58fbfe8196aadacc593.zip
check that even referencing a TLS static during CTFE fails
-rw-r--r--src/test/ui/consts/miri_unleashed/tls.rs7
-rw-r--r--src/test/ui/consts/miri_unleashed/tls.stderr13
2 files changed, 19 insertions, 1 deletions
diff --git a/src/test/ui/consts/miri_unleashed/tls.rs b/src/test/ui/consts/miri_unleashed/tls.rs
index ba86a554bbb..7d4f8962a19 100644
--- a/src/test/ui/consts/miri_unleashed/tls.rs
+++ b/src/test/ui/consts/miri_unleashed/tls.rs
@@ -14,4 +14,11 @@ static TEST_BAD: () = {
     //~| NOTE cannot access thread local static
 };
 
+// Make sure we catch taking a reference to thread-local storage.
+static TEST_BAD_REF: () = {
+    unsafe { let _val = &A; }
+    //~^ ERROR could not evaluate static initializer
+    //~| NOTE cannot access thread local static
+};
+
 fn main() {}
diff --git a/src/test/ui/consts/miri_unleashed/tls.stderr b/src/test/ui/consts/miri_unleashed/tls.stderr
index d3e87f319ac..27d2b2df4d8 100644
--- a/src/test/ui/consts/miri_unleashed/tls.stderr
+++ b/src/test/ui/consts/miri_unleashed/tls.stderr
@@ -4,6 +4,12 @@ error[E0080]: could not evaluate static initializer
 LL |     unsafe { let _val = A; }
    |                         ^ cannot access thread local static (DefId(0:4 ~ tls[317d]::A[0]))
 
+error[E0080]: could not evaluate static initializer
+  --> $DIR/tls.rs:19:26
+   |
+LL |     unsafe { let _val = &A; }
+   |                          ^ cannot access thread local static (DefId(0:4 ~ tls[317d]::A[0]))
+
 warning: skipping const checks
    |
 help: skipping check that does not even have a feature gate
@@ -11,7 +17,12 @@ help: skipping check that does not even have a feature gate
    |
 LL |     unsafe { let _val = A; }
    |                         ^
+help: skipping check that does not even have a feature gate
+  --> $DIR/tls.rs:19:26
+   |
+LL |     unsafe { let _val = &A; }
+   |                          ^
 
-error: aborting due to previous error; 1 warning emitted
+error: aborting due to 2 previous errors; 1 warning emitted
 
 For more information about this error, try `rustc --explain E0080`.