diff --git a/tests/ui/attr-bad-crate-attr.rs b/tests/ui/attr-bad-crate-attr.rs deleted file mode 100644 index b9100ecfb6761..0000000000000 --- a/tests/ui/attr-bad-crate-attr.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ error-pattern: expected item - -#![attr = "val"] -#[attr = "val"] // Unterminated diff --git a/tests/ui/attr-shebang.rs b/tests/ui/attr-shebang.rs deleted file mode 100644 index 67c371aeaace3..0000000000000 --- a/tests/ui/attr-shebang.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ run-pass - -#![allow(stable_features)] -#![feature(rust1)] -pub fn main() { } diff --git a/tests/ui/attributes/attr-bad-crate-attr.rs b/tests/ui/attributes/attr-bad-crate-attr.rs new file mode 100644 index 0000000000000..9de0abca9a75e --- /dev/null +++ b/tests/ui/attributes/attr-bad-crate-attr.rs @@ -0,0 +1,9 @@ +//! Check that we permit a crate-level inner attribute but reject a dangling outer attribute which +//! does not have a following thing that it can target. +//! +//! See . + +//@ error-pattern: expected item + +#![attr = "val"] +#[attr = "val"] // Unterminated diff --git a/tests/ui/attr-bad-crate-attr.stderr b/tests/ui/attributes/attr-bad-crate-attr.stderr similarity index 79% rename from tests/ui/attr-bad-crate-attr.stderr rename to tests/ui/attributes/attr-bad-crate-attr.stderr index 9df991f71b3fb..69eabd32230f4 100644 --- a/tests/ui/attr-bad-crate-attr.stderr +++ b/tests/ui/attributes/attr-bad-crate-attr.stderr @@ -1,5 +1,5 @@ error: expected item after attributes - --> $DIR/attr-bad-crate-attr.rs:4:1 + --> $DIR/attr-bad-crate-attr.rs:9:1 | LL | #[attr = "val"] // Unterminated | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/attributes/attr-shebang.rs b/tests/ui/attributes/attr-shebang.rs new file mode 100644 index 0000000000000..af446dc56e39d --- /dev/null +++ b/tests/ui/attributes/attr-shebang.rs @@ -0,0 +1,7 @@ +//! Check that we accept crate-level inner attributes with the `#![..]` shebang syntax. + +//@ check-pass + +#![allow(stable_features)] +#![feature(rust1)] +pub fn main() { } diff --git a/tests/ui/attr-usage-inline.rs b/tests/ui/attributes/inline/attr-usage-inline.rs similarity index 66% rename from tests/ui/attr-usage-inline.rs rename to tests/ui/attributes/inline/attr-usage-inline.rs index 674c12454cdaa..d8ca0fce1631d 100644 --- a/tests/ui/attr-usage-inline.rs +++ b/tests/ui/attributes/inline/attr-usage-inline.rs @@ -1,4 +1,5 @@ -#![allow(dead_code)] +//! Check that `#[inline]` attribute can only be applied to fn-like targets (e.g. function or +//! closure), and when misapplied to other targets an error is emitted. #[inline] fn f() {} diff --git a/tests/ui/attr-usage-inline.stderr b/tests/ui/attributes/inline/attr-usage-inline.stderr similarity index 84% rename from tests/ui/attr-usage-inline.stderr rename to tests/ui/attributes/inline/attr-usage-inline.stderr index 22a0bf47e2026..2123438032cb3 100644 --- a/tests/ui/attr-usage-inline.stderr +++ b/tests/ui/attributes/inline/attr-usage-inline.stderr @@ -1,5 +1,5 @@ error[E0518]: attribute should be applied to function or closure - --> $DIR/attr-usage-inline.rs:6:1 + --> $DIR/attr-usage-inline.rs:7:1 | LL | #[inline] | ^^^^^^^^^ @@ -7,7 +7,7 @@ LL | struct S; | --------- not a function or closure error[E0518]: attribute should be applied to function or closure - --> $DIR/attr-usage-inline.rs:20:1 + --> $DIR/attr-usage-inline.rs:21:1 | LL | #[inline] | ^^^^^^^^^ not a function or closure diff --git a/tests/ui/associated-path-shl.rs b/tests/ui/parser/associated-path-shl.rs similarity index 100% rename from tests/ui/associated-path-shl.rs rename to tests/ui/parser/associated-path-shl.rs diff --git a/tests/ui/associated-path-shl.stderr b/tests/ui/parser/associated-path-shl.stderr similarity index 100% rename from tests/ui/associated-path-shl.stderr rename to tests/ui/parser/associated-path-shl.stderr diff --git a/tests/ui/attrs-resolution-errors.rs b/tests/ui/resolve/attr-macros-positional-rejection.rs similarity index 73% rename from tests/ui/attrs-resolution-errors.rs rename to tests/ui/resolve/attr-macros-positional-rejection.rs index 8770fb1ded8eb..11382ff13998d 100644 --- a/tests/ui/attrs-resolution-errors.rs +++ b/tests/ui/resolve/attr-macros-positional-rejection.rs @@ -1,3 +1,12 @@ +//! Check that certain positions (listed below) only permit *non-macro* attributes and reject +//! attribute macros: +//! +//! - Enum variants +//! - Struct fields +//! - Field in a struct pattern +//! - Match arm +//! - Field in struct initialization expression + enum FooEnum { #[test] //~^ ERROR expected non-macro attribute, found attribute macro @@ -32,7 +41,7 @@ fn main() { _ => {} } - let _another_foo_strunct = FooStruct { + let _another_foo_struct = FooStruct { #[test] //~^ ERROR expected non-macro attribute, found attribute macro bar: 1, diff --git a/tests/ui/attrs-resolution-errors.stderr b/tests/ui/resolve/attr-macros-positional-rejection.stderr similarity index 73% rename from tests/ui/attrs-resolution-errors.stderr rename to tests/ui/resolve/attr-macros-positional-rejection.stderr index 883f96e5c1931..faea511f31507 100644 --- a/tests/ui/attrs-resolution-errors.stderr +++ b/tests/ui/resolve/attr-macros-positional-rejection.stderr @@ -1,29 +1,29 @@ error: expected non-macro attribute, found attribute macro `test` - --> $DIR/attrs-resolution-errors.rs:2:7 + --> $DIR/attr-macros-positional-rejection.rs:11:7 | LL | #[test] | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/attrs-resolution-errors.rs:8:7 + --> $DIR/attr-macros-positional-rejection.rs:17:7 | LL | #[test] | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/attrs-resolution-errors.rs:23:15 + --> $DIR/attr-macros-positional-rejection.rs:32:15 | LL | #[test] bar | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/attrs-resolution-errors.rs:30:11 + --> $DIR/attr-macros-positional-rejection.rs:39:11 | LL | #[test] | ^^^^ not a non-macro attribute error: expected non-macro attribute, found attribute macro `test` - --> $DIR/attrs-resolution-errors.rs:36:11 + --> $DIR/attr-macros-positional-rejection.rs:45:11 | LL | #[test] | ^^^^ not a non-macro attribute diff --git a/tests/ui/attrs-resolution.rs b/tests/ui/resolve/non-macro-attrs-accepted.rs similarity index 66% rename from tests/ui/attrs-resolution.rs rename to tests/ui/resolve/non-macro-attrs-accepted.rs index 38dd3812d6892..76a04b2e83749 100644 --- a/tests/ui/attrs-resolution.rs +++ b/tests/ui/resolve/non-macro-attrs-accepted.rs @@ -1,3 +1,11 @@ +//! Check that certain positions (listed below) permit *non-macro* attributes. +//! +//! - Enum variants +//! - Struct fields +//! - Field in a struct pattern +//! - Match arm +//! - Field in struct initialization expression + //@ check-pass enum FooEnum { @@ -30,7 +38,7 @@ fn main() { _ => {} } - let _another_foo_strunct = FooStruct { + let _another_foo_struct = FooStruct { #[rustfmt::skip] bar: 1, }; diff --git a/tests/ui/attempted-access-non-fatal.rs b/tests/ui/typeck/attempted-access-non-fatal.rs similarity index 100% rename from tests/ui/attempted-access-non-fatal.rs rename to tests/ui/typeck/attempted-access-non-fatal.rs diff --git a/tests/ui/attempted-access-non-fatal.stderr b/tests/ui/typeck/attempted-access-non-fatal.stderr similarity index 100% rename from tests/ui/attempted-access-non-fatal.stderr rename to tests/ui/typeck/attempted-access-non-fatal.stderr