diff --git a/src/test/ui/consts/miri_unleashed/tls.rs b/src/test/ui/consts/miri_unleashed/tls.rs index ba86a554bbb6..7d4f8962a192 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 d3e87f319acd..27d2b2df4d8a 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`.