diff options
| author | bors <bors@rust-lang.org> | 2022-04-16 19:15:02 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-04-16 19:15:02 +0000 |
| commit | 878c7833f6c1ff10e2fd89074e5bd4ef5ff15936 (patch) | |
| tree | 3775849e21447f36051ce13cbfa6620fba74fa8e /src/test | |
| parent | 2fa9789f596dd7639e1a242d466637b53179f4d1 (diff) | |
| parent | 10e0db5666c15ed58abb47aca1ee453e371c406f (diff) | |
Auto merge of #96123 - Dylan-DPC:rollup-qjog6n1, r=Dylan-DPC
Rollup of 7 pull requests Successful merges: - #94985 (Parse inner attributes on inline const block) - #95006 (Reject `#[thread_local]` attribute on non-static items) - #95426 (Include Refs in Valtree Creation) - #95908 (Inline `shallow_resolve_ty` into `ShallowResolver`) - #96058 (separate flock implementations into separate modules) - #96088 (Update mdbook) - #96118 (rustdoc: Rename `def_id` into `item_id` when the type is `ItemId` for readability) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/pretty/stmt_expr_attributes.rs | 9 | ||||
| -rw-r--r-- | src/test/ui/thread-local/non-static.rs | 30 | ||||
| -rw-r--r-- | src/test/ui/thread-local/non-static.stderr | 38 |
3 files changed, 77 insertions, 0 deletions
diff --git a/src/test/pretty/stmt_expr_attributes.rs b/src/test/pretty/stmt_expr_attributes.rs index 7ab22f1960c..c01379065d1 100644 --- a/src/test/pretty/stmt_expr_attributes.rs +++ b/src/test/pretty/stmt_expr_attributes.rs @@ -1,6 +1,8 @@ // pp-exact #![feature(box_syntax)] +#![feature(inline_const)] +#![feature(inline_const_pat)] #![feature(rustc_attrs)] #![feature(stmt_expr_attributes)] @@ -16,6 +18,7 @@ fn _1() { #[rustc_dummy] unsafe { + #![rustc_dummy] // code } } @@ -206,6 +209,12 @@ fn _11() { let _ = (); () }; + let const { + #![rustc_dummy] + } = + #[rustc_dummy] const { + #![rustc_dummy] + }; let mut x = 0; let _ = #[rustc_dummy] x = 15; let _ = #[rustc_dummy] x += 15; diff --git a/src/test/ui/thread-local/non-static.rs b/src/test/ui/thread-local/non-static.rs new file mode 100644 index 00000000000..f1c4273870b --- /dev/null +++ b/src/test/ui/thread-local/non-static.rs @@ -0,0 +1,30 @@ +// Check that #[thread_local] attribute is rejected on non-static items. +#![feature(thread_local)] + +#[thread_local] +//~^ ERROR attribute should be applied to a static +const A: u32 = 0; + +#[thread_local] +//~^ ERROR attribute should be applied to a static +fn main() { + #[thread_local] || {}; + //~^ ERROR attribute should be applied to a static +} + +struct S { + #[thread_local] + //~^ ERROR attribute should be applied to a static + a: String, + b: String, +} + +#[thread_local] +// Static. OK. +static B: u32 = 0; + +extern "C" { + #[thread_local] + // Foreign static. OK. + static C: u32; +} diff --git a/src/test/ui/thread-local/non-static.stderr b/src/test/ui/thread-local/non-static.stderr new file mode 100644 index 00000000000..09a1618d6e7 --- /dev/null +++ b/src/test/ui/thread-local/non-static.stderr @@ -0,0 +1,38 @@ +error: attribute should be applied to a static + --> $DIR/non-static.rs:4:1 + | +LL | #[thread_local] + | ^^^^^^^^^^^^^^^ +LL | +LL | const A: u32 = 0; + | ----------------- not a static + +error: attribute should be applied to a static + --> $DIR/non-static.rs:8:1 + | +LL | #[thread_local] + | ^^^^^^^^^^^^^^^ +LL | +LL | / fn main() { +LL | | #[thread_local] || {}; +LL | | +LL | | } + | |_- not a static + +error: attribute should be applied to a static + --> $DIR/non-static.rs:11:5 + | +LL | #[thread_local] || {}; + | ^^^^^^^^^^^^^^^ ----- not a static + +error: attribute should be applied to a static + --> $DIR/non-static.rs:16:5 + | +LL | #[thread_local] + | ^^^^^^^^^^^^^^^ +LL | +LL | a: String, + | --------- not a static + +error: aborting due to 4 previous errors + |
