From 30f5a039f07f830427fec693cdaff8724042cb12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:09:00 +0800 Subject: [PATCH 1/7] Move `tests/ui/associated-path-shl.rs` to `tests/ui/parser/` --- tests/ui/{ => parser}/associated-path-shl.rs | 0 tests/ui/{ => parser}/associated-path-shl.stderr | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{ => parser}/associated-path-shl.rs (100%) rename tests/ui/{ => parser}/associated-path-shl.stderr (100%) 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 From 4ca2d9f7f5f158187e8ffcdfe82a1b1c39fc8733 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:10:56 +0800 Subject: [PATCH 2/7] Move `tests/ui/attempted-access-non-fatal.rs` to `tests/ui/typeck/` --- tests/ui/{ => typeck}/attempted-access-non-fatal.rs | 0 tests/ui/{ => typeck}/attempted-access-non-fatal.stderr | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename tests/ui/{ => typeck}/attempted-access-non-fatal.rs (100%) rename tests/ui/{ => typeck}/attempted-access-non-fatal.stderr (100%) 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 From 0fc6be7898578e7d0c915f14f9ddb3ac71673796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:18:30 +0800 Subject: [PATCH 3/7] Adjust `tests/ui/attr-bad-crate-attr.rs` - Move `tests/ui/attr-bad-crate-attr.rs` to `tests/ui/attributes/`. - Briefly document test intent add link to relevant Reference docs. --- tests/ui/attr-bad-crate-attr.rs | 4 ---- tests/ui/attributes/attr-bad-crate-attr.rs | 9 +++++++++ tests/ui/{ => attributes}/attr-bad-crate-attr.stderr | 2 +- 3 files changed, 10 insertions(+), 5 deletions(-) delete mode 100644 tests/ui/attr-bad-crate-attr.rs create mode 100644 tests/ui/attributes/attr-bad-crate-attr.rs rename tests/ui/{ => attributes}/attr-bad-crate-attr.stderr (79%) 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/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 | ^^^^^^^^^^^^^^^ From 88f8bf7e560f5ea9c2efe2f587b2586f95984c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:22:21 +0800 Subject: [PATCH 4/7] Adjust `tests/ui/attr-shebang.rs` - Move `tests/ui/attr-shebang.rs` to `tests/ui/attributes/`. - Downgrade test to `check-pass`, this would fail very early if the parser did not accept `#![..]` attributes. - Briefly document test intent. --- tests/ui/attr-shebang.rs | 5 ----- tests/ui/attributes/attr-shebang.rs | 7 +++++++ 2 files changed, 7 insertions(+), 5 deletions(-) delete mode 100644 tests/ui/attr-shebang.rs create mode 100644 tests/ui/attributes/attr-shebang.rs 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-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() { } From 7424b898e94b019b49e0854ec061abfdc071e61e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:29:14 +0800 Subject: [PATCH 5/7] Adjust `tests/ui/attr-usage-inline.rs` - Move `tests/ui/attr-usage-inline.rs` to `tests/ui/attributes/inline/`. - Briefly document test intent. - Drop unnecessary `#[allow(dead_code)]` as this is allowed-by-default for ui test suite. --- tests/ui/{ => attributes/inline}/attr-usage-inline.rs | 3 ++- tests/ui/{ => attributes/inline}/attr-usage-inline.stderr | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) rename tests/ui/{ => attributes/inline}/attr-usage-inline.rs (66%) rename tests/ui/{ => attributes/inline}/attr-usage-inline.stderr (84%) 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 From 836a0e00e5d29b845748cf42713445076418473b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:40:31 +0800 Subject: [PATCH 6/7] Adjust `tests/ui/attrs-resolution-errors.rs` - Move `tests/ui/attrs-resolution-errors.rs` to `tests/ui/resolve/`. - Document test intent. - Rename test to `attr-macros-positional-rejection.rs` to better reflect test intent. --- .../attr-macros-positional-rejection.rs} | 11 ++++++++++- .../attr-macros-positional-rejection.stderr} | 10 +++++----- 2 files changed, 15 insertions(+), 6 deletions(-) rename tests/ui/{attrs-resolution-errors.rs => resolve/attr-macros-positional-rejection.rs} (73%) rename tests/ui/{attrs-resolution-errors.stderr => resolve/attr-macros-positional-rejection.stderr} (73%) 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 From 47ad3b2be42790a54840f5aec9a3526244bedc55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=9D=B0=E5=8F=8B=20Jieyou=20Xu=20=28Joe=29?= <39484203+jieyouxu@users.noreply.github.com> Date: Tue, 17 Dec 2024 19:43:05 +0800 Subject: [PATCH 7/7] Adjust `tests/ui/attrs-resolution.rs` - Move `tests/ui/attrs-resolution.rs` to `tests/ui/resolve/`. - Document test intent. - Rename test to `non-macro-attrs-accepted.rs` to better reflect test intent. --- .../non-macro-attrs-accepted.rs} | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) rename tests/ui/{attrs-resolution.rs => resolve/non-macro-attrs-accepted.rs} (66%) 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, };