From 246f239d9f40f633160f0c18f87a20922d4e77bb Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:06:37 +0200 Subject: Merging debian version 1.65.0+dfsg1-2. Signed-off-by: Daniel Baumann --- .../ui/attributes/collapse-debuginfo-invalid.rs | 110 ++++++++++ .../attributes/collapse-debuginfo-invalid.stderr | 222 +++++++++++++++++++++ src/test/ui/attributes/issue-100631.rs | 8 + src/test/ui/attributes/issue-100631.stderr | 12 ++ src/test/ui/attributes/issue-90873.stderr | 4 +- src/test/ui/attributes/register-attr-tool-fail.rs | 13 -- .../ui/attributes/register-attr-tool-fail.stderr | 42 ---- .../ui/attributes/register-attr-tool-import.rs | 17 -- .../ui/attributes/register-attr-tool-import.stderr | 38 ---- .../ui/attributes/register-attr-tool-prelude.rs | 14 -- .../attributes/register-attr-tool-prelude.stderr | 15 -- .../ui/attributes/register-attr-tool-unused.rs | 8 - .../ui/attributes/register-attr-tool-unused.stderr | 21 -- src/test/ui/attributes/register-attr-tool.rs | 19 -- .../unix_sigpipe/auxiliary/sigpipe-utils.rs | 31 +++ .../attributes/unix_sigpipe/unix_sigpipe-crate.rs | 4 + .../unix_sigpipe/unix_sigpipe-crate.stderr | 13 ++ .../unix_sigpipe/unix_sigpipe-duplicates.rs | 5 + .../unix_sigpipe/unix_sigpipe-duplicates.stderr | 14 ++ .../attributes/unix_sigpipe/unix_sigpipe-error.rs | 13 ++ .../unix_sigpipe/unix_sigpipe-inherit.rs | 14 ++ .../attributes/unix_sigpipe/unix_sigpipe-list.rs | 4 + .../unix_sigpipe/unix_sigpipe-list.stderr | 15 ++ .../unix_sigpipe/unix_sigpipe-non-main-fn.rs | 6 + .../unix_sigpipe/unix_sigpipe-non-main-fn.stderr | 8 + .../unix_sigpipe/unix_sigpipe-non-root-main.rs | 8 + .../unix_sigpipe/unix_sigpipe-non-root-main.stderr | 8 + .../unix_sigpipe/unix_sigpipe-not-used.rs | 9 + .../unix_sigpipe/unix_sigpipe-only-feature.rs | 13 ++ .../unix_sigpipe/unix_sigpipe-rustc_main.rs | 15 ++ .../unix_sigpipe/unix_sigpipe-sig_dfl.rs | 13 ++ .../attributes/unix_sigpipe/unix_sigpipe-start.rs | 6 + .../unix_sigpipe/unix_sigpipe-start.stderr | 8 + .../attributes/unix_sigpipe/unix_sigpipe-struct.rs | 6 + .../unix_sigpipe/unix_sigpipe-struct.stderr | 8 + .../attributes/unix_sigpipe/unix_sigpipe-wrong.rs | 4 + .../unix_sigpipe/unix_sigpipe-wrong.stderr | 8 + .../ui/attributes/unix_sigpipe/unix_sigpipe.rs | 4 + .../ui/attributes/unix_sigpipe/unix_sigpipe.stderr | 8 + 39 files changed, 599 insertions(+), 189 deletions(-) create mode 100644 src/test/ui/attributes/collapse-debuginfo-invalid.rs create mode 100644 src/test/ui/attributes/collapse-debuginfo-invalid.stderr create mode 100644 src/test/ui/attributes/issue-100631.rs create mode 100644 src/test/ui/attributes/issue-100631.stderr delete mode 100644 src/test/ui/attributes/register-attr-tool-fail.rs delete mode 100644 src/test/ui/attributes/register-attr-tool-fail.stderr delete mode 100644 src/test/ui/attributes/register-attr-tool-import.rs delete mode 100644 src/test/ui/attributes/register-attr-tool-import.stderr delete mode 100644 src/test/ui/attributes/register-attr-tool-prelude.rs delete mode 100644 src/test/ui/attributes/register-attr-tool-prelude.stderr delete mode 100644 src/test/ui/attributes/register-attr-tool-unused.rs delete mode 100644 src/test/ui/attributes/register-attr-tool-unused.stderr delete mode 100644 src/test/ui/attributes/register-attr-tool.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-crate.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-crate.stderr create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.stderr create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-error.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-inherit.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-list.stderr create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.stderr create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.stderr create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-not-used.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-only-feature.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-rustc_main.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-sig_dfl.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-start.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-start.stderr create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-struct.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-struct.stderr create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-wrong.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe-wrong.stderr create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe.rs create mode 100644 src/test/ui/attributes/unix_sigpipe/unix_sigpipe.stderr (limited to 'src/test/ui/attributes') diff --git a/src/test/ui/attributes/collapse-debuginfo-invalid.rs b/src/test/ui/attributes/collapse-debuginfo-invalid.rs new file mode 100644 index 000000000..42d8982c1 --- /dev/null +++ b/src/test/ui/attributes/collapse-debuginfo-invalid.rs @@ -0,0 +1,110 @@ +#![feature(collapse_debuginfo)] +#![feature(stmt_expr_attributes)] +#![feature(type_alias_impl_trait)] +#![no_std] + +// Test that the `#[collapse_debuginfo]` attribute can only be used on macro definitions. + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +extern crate std; + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +use std::collections::HashMap; + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +static FOO: u32 = 3; + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +const BAR: u32 = 3; + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +fn foo() { + let _ = #[collapse_debuginfo] || { }; +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions + #[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions + let _ = 3; + let _ = #[collapse_debuginfo] 3; +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions + match (3, 4) { + #[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions + _ => (), + } +} + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +mod bar { +} + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +type Map = HashMap; + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +enum Foo { + #[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions + Variant, +} + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +struct Bar { + #[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions + field: u32, +} + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +union Qux { + a: u32, + b: u16 +} + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +trait Foobar { + #[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions + type Bar; +} + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +type AFoobar = impl Foobar; + +impl Foobar for Bar { + type Bar = u32; +} + +fn constraining() -> AFoobar { + Bar { field: 3 } +} + +#[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions +impl Bar { + #[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions + const FOO: u32 = 3; + + #[collapse_debuginfo] +//~^ ERROR `collapse_debuginfo` attribute should be applied to macro definitions + fn bar(&self) {} +} + +#[collapse_debuginfo] +macro_rules! finally { + ($e:expr) => { $e } +} + +fn main() {} diff --git a/src/test/ui/attributes/collapse-debuginfo-invalid.stderr b/src/test/ui/attributes/collapse-debuginfo-invalid.stderr new file mode 100644 index 000000000..01c476091 --- /dev/null +++ b/src/test/ui/attributes/collapse-debuginfo-invalid.stderr @@ -0,0 +1,222 @@ +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:8:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | extern crate std; + | ----------------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:12:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | use std::collections::HashMap; + | ------------------------------ not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:16:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | static FOO: u32 = 3; + | -------------------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:20:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | const BAR: u32 = 3; + | ------------------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:24:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | / fn foo() { +LL | | let _ = #[collapse_debuginfo] || { }; +LL | | +LL | | #[collapse_debuginfo] +... | +LL | | } +LL | | } + | |_- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:27:13 + | +LL | let _ = #[collapse_debuginfo] || { }; + | ^^^^^^^^^^^^^^^^^^^^^ ------ not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:29:5 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | let _ = 3; + | ---------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:32:13 + | +LL | let _ = #[collapse_debuginfo] 3; + | ^^^^^^^^^^^^^^^^^^^^^ - not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:35:9 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | _ => (), + | ------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:41:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | / mod bar { +LL | | } + | |_- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:46:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | type Map = HashMap; + | ----------------------------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:50:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | / enum Foo { +LL | | #[collapse_debuginfo] +LL | | +LL | | Variant, +LL | | } + | |_- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:53:5 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | Variant, + | ------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:58:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | / struct Bar { +LL | | #[collapse_debuginfo] +LL | | +LL | | field: u32, +LL | | } + | |_- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:61:5 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | field: u32, + | ---------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:66:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | / union Qux { +LL | | a: u32, +LL | | b: u16 +LL | | } + | |_- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:73:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | / trait Foobar { +LL | | #[collapse_debuginfo] +LL | | +LL | | type Bar; +LL | | } + | |_- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:81:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | type AFoobar = impl Foobar; + | --------------------------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:93:1 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | / impl Bar { +LL | | #[collapse_debuginfo] +LL | | +LL | | const FOO: u32 = 3; +... | +LL | | fn bar(&self) {} +LL | | } + | |_- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:76:5 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | type Bar; + | --------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:96:5 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | const FOO: u32 = 3; + | ------------------- not a macro definition + +error: `collapse_debuginfo` attribute should be applied to macro definitions + --> $DIR/collapse-debuginfo-invalid.rs:100:5 + | +LL | #[collapse_debuginfo] + | ^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | fn bar(&self) {} + | ---------------- not a macro definition + +error: aborting due to 22 previous errors + diff --git a/src/test/ui/attributes/issue-100631.rs b/src/test/ui/attributes/issue-100631.rs new file mode 100644 index 000000000..0fefcf83f --- /dev/null +++ b/src/test/ui/attributes/issue-100631.rs @@ -0,0 +1,8 @@ +// issue #100631, make sure `TyCtxt::get_attr` only called by case that compiler +// can reasonably deal with multiple attributes. +// `repr` will use `TyCtxt::get_attrs` since it's `DuplicatesOk`. +#[repr(C)] //~ ERROR: unsupported representation for zero-variant enum [E0084] +#[repr(C)] +enum Foo {} + +fn main() {} diff --git a/src/test/ui/attributes/issue-100631.stderr b/src/test/ui/attributes/issue-100631.stderr new file mode 100644 index 000000000..caa5351dd --- /dev/null +++ b/src/test/ui/attributes/issue-100631.stderr @@ -0,0 +1,12 @@ +error[E0084]: unsupported representation for zero-variant enum + --> $DIR/issue-100631.rs:4:1 + | +LL | #[repr(C)] + | ^^^^^^^^^^ +LL | #[repr(C)] +LL | enum Foo {} + | -------- zero-variant enum + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0084`. diff --git a/src/test/ui/attributes/issue-90873.stderr b/src/test/ui/attributes/issue-90873.stderr index 0852bb7ca..894ec8341 100644 --- a/src/test/ui/attributes/issue-90873.stderr +++ b/src/test/ui/attributes/issue-90873.stderr @@ -34,10 +34,10 @@ LL | #![a={impl std::ops::Neg for i8 {}}] | ^ consider adding a `main` function to `$DIR/issue-90873.rs` error: missing type for `static` item - --> $DIR/issue-90873.rs:1:16 + --> $DIR/issue-90873.rs:1:17 | LL | #![u=||{static d=||1;}] - | ^ help: provide a type for the item: `d: ` + | ^ help: provide a type for the item: `: ` error: aborting due to 6 previous errors diff --git a/src/test/ui/attributes/register-attr-tool-fail.rs b/src/test/ui/attributes/register-attr-tool-fail.rs deleted file mode 100644 index 84736be84..000000000 --- a/src/test/ui/attributes/register-attr-tool-fail.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(register_attr)] -#![feature(register_tool)] - -#![register_attr] //~ ERROR malformed `register_attr` attribute input -#![register_tool] //~ ERROR malformed `register_tool` attribute input - -#![register_attr(a::b)] //~ ERROR `register_attr` only accepts identifiers -#![register_tool(a::b)] //~ ERROR `register_tool` only accepts identifiers - -#![register_attr(attr, attr)] //~ ERROR attribute `attr` was already registered -#![register_tool(tool, tool)] //~ ERROR tool `tool` was already registered - -fn main() {} diff --git a/src/test/ui/attributes/register-attr-tool-fail.stderr b/src/test/ui/attributes/register-attr-tool-fail.stderr deleted file mode 100644 index 8f6977cb5..000000000 --- a/src/test/ui/attributes/register-attr-tool-fail.stderr +++ /dev/null @@ -1,42 +0,0 @@ -error: `register_attr` only accepts identifiers - --> $DIR/register-attr-tool-fail.rs:7:18 - | -LL | #![register_attr(a::b)] - | ^^^^ not an identifier - -error: attribute `attr` was already registered - --> $DIR/register-attr-tool-fail.rs:10:24 - | -LL | #![register_attr(attr, attr)] - | ---- ^^^^ - | | - | already registered here - -error: `register_tool` only accepts identifiers - --> $DIR/register-attr-tool-fail.rs:8:18 - | -LL | #![register_tool(a::b)] - | ^^^^ not an identifier - -error: tool `tool` was already registered - --> $DIR/register-attr-tool-fail.rs:11:24 - | -LL | #![register_tool(tool, tool)] - | ---- ^^^^ - | | - | already registered here - -error: malformed `register_attr` attribute input - --> $DIR/register-attr-tool-fail.rs:4:1 - | -LL | #![register_attr] - | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#![register_attr(attr1, attr2, ...)]` - -error: malformed `register_tool` attribute input - --> $DIR/register-attr-tool-fail.rs:5:1 - | -LL | #![register_tool] - | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#![register_tool(tool1, tool2, ...)]` - -error: aborting due to 6 previous errors - diff --git a/src/test/ui/attributes/register-attr-tool-import.rs b/src/test/ui/attributes/register-attr-tool-import.rs deleted file mode 100644 index d3502c71f..000000000 --- a/src/test/ui/attributes/register-attr-tool-import.rs +++ /dev/null @@ -1,17 +0,0 @@ -// edition:2018 -// compile-flags: -Zsave-analysis -// ~^ Also regression test for #69588 - -#![feature(register_attr)] -#![feature(register_tool)] - -#![register_attr(attr)] -#![register_tool(tool)] - -use attr as renamed_attr; // OK -use tool as renamed_tool; // OK - -#[renamed_attr] //~ ERROR cannot use an explicitly registered attribute through an import -#[renamed_tool::attr] //~ ERROR cannot use a tool module through an import - //~| ERROR cannot use a tool module through an import -fn main() {} diff --git a/src/test/ui/attributes/register-attr-tool-import.stderr b/src/test/ui/attributes/register-attr-tool-import.stderr deleted file mode 100644 index 90b7e169a..000000000 --- a/src/test/ui/attributes/register-attr-tool-import.stderr +++ /dev/null @@ -1,38 +0,0 @@ -error: cannot use an explicitly registered attribute through an import - --> $DIR/register-attr-tool-import.rs:14:3 - | -LL | #[renamed_attr] - | ^^^^^^^^^^^^ - | -note: the explicitly registered attribute imported here - --> $DIR/register-attr-tool-import.rs:11:5 - | -LL | use attr as renamed_attr; // OK - | ^^^^^^^^^^^^^^^^^^^^ - -error: cannot use a tool module through an import - --> $DIR/register-attr-tool-import.rs:15:3 - | -LL | #[renamed_tool::attr] - | ^^^^^^^^^^^^ - | -note: the tool module imported here - --> $DIR/register-attr-tool-import.rs:12:5 - | -LL | use tool as renamed_tool; // OK - | ^^^^^^^^^^^^^^^^^^^^ - -error: cannot use a tool module through an import - --> $DIR/register-attr-tool-import.rs:15:3 - | -LL | #[renamed_tool::attr] - | ^^^^^^^^^^^^ - | -note: the tool module imported here - --> $DIR/register-attr-tool-import.rs:12:5 - | -LL | use tool as renamed_tool; // OK - | ^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - diff --git a/src/test/ui/attributes/register-attr-tool-prelude.rs b/src/test/ui/attributes/register-attr-tool-prelude.rs deleted file mode 100644 index d217a8146..000000000 --- a/src/test/ui/attributes/register-attr-tool-prelude.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(register_attr)] -#![feature(register_tool)] - -#![register_attr(attr)] -#![register_tool(tool)] - -#[no_implicit_prelude] -mod m { - #[attr] //~ ERROR cannot find attribute `attr` in this scope - #[tool::attr] //~ ERROR failed to resolve: use of undeclared crate or module `tool` - fn check() {} -} - -fn main() {} diff --git a/src/test/ui/attributes/register-attr-tool-prelude.stderr b/src/test/ui/attributes/register-attr-tool-prelude.stderr deleted file mode 100644 index 905b66120..000000000 --- a/src/test/ui/attributes/register-attr-tool-prelude.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0433]: failed to resolve: use of undeclared crate or module `tool` - --> $DIR/register-attr-tool-prelude.rs:10:7 - | -LL | #[tool::attr] - | ^^^^ use of undeclared crate or module `tool` - -error: cannot find attribute `attr` in this scope - --> $DIR/register-attr-tool-prelude.rs:9:7 - | -LL | #[attr] - | ^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0433`. diff --git a/src/test/ui/attributes/register-attr-tool-unused.rs b/src/test/ui/attributes/register-attr-tool-unused.rs deleted file mode 100644 index 680614656..000000000 --- a/src/test/ui/attributes/register-attr-tool-unused.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![deny(unused)] - -#![feature(register_attr)] -#![feature(register_tool)] - -#[register_attr(attr)] //~ ERROR crate-level attribute should be an inner attribute -#[register_tool(tool)] //~ ERROR crate-level attribute should be an inner attribute -fn main() {} diff --git a/src/test/ui/attributes/register-attr-tool-unused.stderr b/src/test/ui/attributes/register-attr-tool-unused.stderr deleted file mode 100644 index 8d2e1b6bc..000000000 --- a/src/test/ui/attributes/register-attr-tool-unused.stderr +++ /dev/null @@ -1,21 +0,0 @@ -error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/register-attr-tool-unused.rs:6:1 - | -LL | #[register_attr(attr)] - | ^^^^^^^^^^^^^^^^^^^^^^ - | -note: the lint level is defined here - --> $DIR/register-attr-tool-unused.rs:1:9 - | -LL | #![deny(unused)] - | ^^^^^^ - = note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]` - -error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/register-attr-tool-unused.rs:7:1 - | -LL | #[register_tool(tool)] - | ^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors - diff --git a/src/test/ui/attributes/register-attr-tool.rs b/src/test/ui/attributes/register-attr-tool.rs deleted file mode 100644 index ee9da74d4..000000000 --- a/src/test/ui/attributes/register-attr-tool.rs +++ /dev/null @@ -1,19 +0,0 @@ -// check-pass -// compile-flags: --cfg foo - -#![feature(register_attr)] -#![feature(register_tool)] - -#![register_attr(attr)] -#![register_tool(tool)] -#![register_tool(rustfmt, clippy)] // OK -#![cfg_attr(foo, register_attr(conditional_attr))] -#![cfg_attr(foo, register_tool(conditional_tool))] - -#[attr] -#[tool::attr] -#[rustfmt::attr] -#[clippy::attr] -#[conditional_attr] -#[conditional_tool::attr] -fn main() {} diff --git a/src/test/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs b/src/test/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs new file mode 100644 index 000000000..e8b4fe7ae --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/auxiliary/sigpipe-utils.rs @@ -0,0 +1,31 @@ +#![feature(rustc_private)] +extern crate libc; + +/// So tests don't have to bring libc in scope themselves +pub enum SignalHandler { + Ignore, + Default, +} + +/// Helper to assert that [`libc::SIGPIPE`] has the expected signal handler. +pub fn assert_sigpipe_handler(expected_handler: SignalHandler) { + #[cfg(unix)] + #[cfg(not(any( + target_os = "emscripten", + target_os = "fuchsia", + target_os = "horizon", + target_os = "android", + )))] + { + let prev = unsafe { libc::signal(libc::SIGPIPE, libc::SIG_IGN) }; + + let expected = match expected_handler { + SignalHandler::Ignore => libc::SIG_IGN, + SignalHandler::Default => libc::SIG_DFL, + }; + assert_eq!(prev, expected); + + // Unlikely to matter, but restore the old value anyway + unsafe { libc::signal(libc::SIGPIPE, prev); }; + } +} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-crate.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-crate.rs new file mode 100644 index 000000000..d6d020c52 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-crate.rs @@ -0,0 +1,4 @@ +#![feature(unix_sigpipe)] +#![unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute cannot be used at crate level + +fn main() {} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-crate.stderr b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-crate.stderr new file mode 100644 index 000000000..a1fb4d678 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-crate.stderr @@ -0,0 +1,13 @@ +error: `unix_sigpipe` attribute cannot be used at crate level + --> $DIR/unix_sigpipe-crate.rs:2:1 + | +LL | #![unix_sigpipe = "inherit"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: perhaps you meant to use an outer attribute + | +LL | #[unix_sigpipe = "inherit"] + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to previous error + diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.rs new file mode 100644 index 000000000..294cb3852 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.rs @@ -0,0 +1,5 @@ +#![feature(unix_sigpipe)] + +#[unix_sigpipe = "sig_ign"] +#[unix_sigpipe = "inherit"] //~ error: multiple `unix_sigpipe` attributes +fn main() {} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.stderr b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.stderr new file mode 100644 index 000000000..2362c17a0 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-duplicates.stderr @@ -0,0 +1,14 @@ +error: multiple `unix_sigpipe` attributes + --> $DIR/unix_sigpipe-duplicates.rs:4:1 + | +LL | #[unix_sigpipe = "inherit"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unix_sigpipe-duplicates.rs:3:1 + | +LL | #[unix_sigpipe = "sig_ign"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-error.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-error.rs new file mode 100644 index 000000000..0a42a5b5e --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-error.rs @@ -0,0 +1,13 @@ +// run-pass +// aux-build:sigpipe-utils.rs + +#![feature(unix_sigpipe)] + +#[unix_sigpipe = "sig_ign"] +fn main() { + extern crate sigpipe_utils; + + // #[unix_sigpipe = "sig_ign"] is active, so the legacy behavior of ignoring + // SIGPIPE shall be in effect + sigpipe_utils::assert_sigpipe_handler(sigpipe_utils::SignalHandler::Ignore); +} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-inherit.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-inherit.rs new file mode 100644 index 000000000..4f8648077 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-inherit.rs @@ -0,0 +1,14 @@ +// run-pass +// aux-build:sigpipe-utils.rs + +#![feature(unix_sigpipe)] + +#[unix_sigpipe = "inherit"] +fn main() { + extern crate sigpipe_utils; + + // #[unix_sigpipe = "inherit"] is active, so SIGPIPE shall NOT be ignored, + // instead the default handler shall be installed. (We assume that the + // process that runs these tests have the default handler.) + sigpipe_utils::assert_sigpipe_handler(sigpipe_utils::SignalHandler::Default); +} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs new file mode 100644 index 000000000..b5ebc07a0 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-list.rs @@ -0,0 +1,4 @@ +#![feature(unix_sigpipe)] + +#[unix_sigpipe(inherit)] //~ error: malformed `unix_sigpipe` attribute input +fn main() {} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-list.stderr b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-list.stderr new file mode 100644 index 000000000..59a87e139 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-list.stderr @@ -0,0 +1,15 @@ +error: malformed `unix_sigpipe` attribute input + --> $DIR/unix_sigpipe-list.rs:3:1 + | +LL | #[unix_sigpipe(inherit)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[unix_sigpipe = "inherit|sig_ign|sig_dfl"] + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | #[unix_sigpipe] + | ~~~~~~~~~~~~~~~ + +error: aborting due to previous error + diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs new file mode 100644 index 000000000..cde6719fc --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.rs @@ -0,0 +1,6 @@ +#![feature(unix_sigpipe)] + +#[unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()` +fn f() {} + +fn main() {} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.stderr b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.stderr new file mode 100644 index 000000000..c4b81118c --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-main-fn.stderr @@ -0,0 +1,8 @@ +error: `unix_sigpipe` attribute can only be used on `fn main()` + --> $DIR/unix_sigpipe-non-main-fn.rs:3:1 + | +LL | #[unix_sigpipe = "inherit"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.rs new file mode 100644 index 000000000..16f727639 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.rs @@ -0,0 +1,8 @@ +#![feature(unix_sigpipe)] + +mod m { + #[unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute can only be used on root `fn main()` + fn main() {} +} + +fn main() {} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.stderr b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.stderr new file mode 100644 index 000000000..a04f605ed --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-non-root-main.stderr @@ -0,0 +1,8 @@ +error: `unix_sigpipe` attribute can only be used on root `fn main()` + --> $DIR/unix_sigpipe-non-root-main.rs:4:5 + | +LL | #[unix_sigpipe = "inherit"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-not-used.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-not-used.rs new file mode 100644 index 000000000..100b4ce9f --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-not-used.rs @@ -0,0 +1,9 @@ +// run-pass +// aux-build:sigpipe-utils.rs + +fn main() { + extern crate sigpipe_utils; + + // SIGPIPE shall be ignored since #[unix_sigpipe = "..."] is not used + sigpipe_utils::assert_sigpipe_handler(sigpipe_utils::SignalHandler::Ignore); +} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-only-feature.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-only-feature.rs new file mode 100644 index 000000000..b5adc2e55 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-only-feature.rs @@ -0,0 +1,13 @@ +// run-pass +// aux-build:sigpipe-utils.rs + +#![feature(unix_sigpipe)] + +fn main() { + extern crate sigpipe_utils; + + // Only #![feature(unix_sigpipe)] is enabled, not #[unix_sigpipe = "..."]. + // This shall not change any behavior, so we still expect SIGPIPE to be + // ignored + sigpipe_utils::assert_sigpipe_handler(sigpipe_utils::SignalHandler::Ignore); +} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-rustc_main.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-rustc_main.rs new file mode 100644 index 000000000..6befb9e95 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-rustc_main.rs @@ -0,0 +1,15 @@ +// run-pass +// aux-build:sigpipe-utils.rs + +#![feature(unix_sigpipe)] +#![feature(rustc_attrs)] + +#[unix_sigpipe = "sig_dfl"] +#[rustc_main] +fn rustc_main() { + extern crate sigpipe_utils; + + // #[unix_sigpipe = "sig_dfl"] is active, so SIGPIPE handler shall be + // SIG_DFL. Note that we have a #[rustc_main], but it should still work. + sigpipe_utils::assert_sigpipe_handler(sigpipe_utils::SignalHandler::Default); +} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-sig_dfl.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-sig_dfl.rs new file mode 100644 index 000000000..238c0d57a --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-sig_dfl.rs @@ -0,0 +1,13 @@ +// run-pass +// aux-build:sigpipe-utils.rs + +#![feature(unix_sigpipe)] + +#[unix_sigpipe = "sig_dfl"] +fn main() { + extern crate sigpipe_utils; + + // #[unix_sigpipe = "sig_dfl"] is active, so SIGPIPE shall NOT be ignored, instead + // the default handler shall be installed + sigpipe_utils::assert_sigpipe_handler(sigpipe_utils::SignalHandler::Default); +} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-start.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-start.rs new file mode 100644 index 000000000..64fd5ec4f --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-start.rs @@ -0,0 +1,6 @@ +#![feature(start)] +#![feature(unix_sigpipe)] + +#[start] +#[unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()` +fn custom_start(argc: isize, argv: *const *const u8) -> isize { 0 } diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-start.stderr b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-start.stderr new file mode 100644 index 000000000..2c9ce479b --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-start.stderr @@ -0,0 +1,8 @@ +error: `unix_sigpipe` attribute can only be used on `fn main()` + --> $DIR/unix_sigpipe-start.rs:5:1 + | +LL | #[unix_sigpipe = "inherit"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-struct.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-struct.rs new file mode 100644 index 000000000..a5e47cfeb --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-struct.rs @@ -0,0 +1,6 @@ +#![feature(unix_sigpipe)] + +#[unix_sigpipe = "inherit"] //~ error: `unix_sigpipe` attribute can only be used on `fn main()` +struct S; + +fn main() {} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-struct.stderr b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-struct.stderr new file mode 100644 index 000000000..c56ee60bb --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-struct.stderr @@ -0,0 +1,8 @@ +error: `unix_sigpipe` attribute can only be used on `fn main()` + --> $DIR/unix_sigpipe-struct.rs:3:1 + | +LL | #[unix_sigpipe = "inherit"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-wrong.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-wrong.rs new file mode 100644 index 000000000..4ec25de00 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-wrong.rs @@ -0,0 +1,4 @@ +#![feature(unix_sigpipe)] + +#[unix_sigpipe = "wrong"] //~ error: valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl` +fn main() {} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-wrong.stderr b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-wrong.stderr new file mode 100644 index 000000000..a66e45aa2 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe-wrong.stderr @@ -0,0 +1,8 @@ +error: valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl` + --> $DIR/unix_sigpipe-wrong.rs:3:1 + | +LL | #[unix_sigpipe = "wrong"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe.rs b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe.rs new file mode 100644 index 000000000..7bf1c7350 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe.rs @@ -0,0 +1,4 @@ +#![feature(unix_sigpipe)] + +#[unix_sigpipe] //~ error: valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl` +fn main() {} diff --git a/src/test/ui/attributes/unix_sigpipe/unix_sigpipe.stderr b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe.stderr new file mode 100644 index 000000000..1b1eda825 --- /dev/null +++ b/src/test/ui/attributes/unix_sigpipe/unix_sigpipe.stderr @@ -0,0 +1,8 @@ +error: valid values for `#[unix_sigpipe = "..."]` are `inherit`, `sig_ign`, or `sig_dfl` + --> $DIR/unix_sigpipe.rs:3:1 + | +LL | #[unix_sigpipe] + | ^^^^^^^^^^^^^^^ + +error: aborting due to previous error + -- cgit v1.2.3