check that even referencing a TLS static during CTFE fails

This commit is contained in:
Ralf Jung 2020-07-26 11:12:22 +02:00
parent 1d9efbbd8f
commit debe597a9a
2 changed files with 19 additions and 1 deletions

View File

@ -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() {}

View File

@ -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`.