about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJacob Pratt <jacob@jhpratt.dev>2024-12-18 21:38:10 -0500
committerGitHub <noreply@github.com>2024-12-18 21:38:10 -0500
commit871c2d81a9fbea2b993efc10279a6f73ca9ac986 (patch)
treeb876742bc2593ef04285c95a2b42fab7e20d4c32
parentfa75b4d04798702309960d120548e8804f83f5b9 (diff)
parent47ad3b2be42790a54840f5aec9a3526244bedc55 (diff)
downloadrust-871c2d81a9fbea2b993efc10279a6f73ca9ac986.tar.gz
rust-871c2d81a9fbea2b993efc10279a6f73ca9ac986.zip
Rollup merge of #134418 - jieyouxu:ui-cleanup-3, r=compiler-errors
Advent of `tests/ui` (misc cleanups and improvements) [3/N]

Part of #133895.

Misc improvements to some ui tests immediately under `tests/ui/`.

Best reviewed commit-by-commit. Each commit's commit message contains further elaboration and rationale for changes.

r? compiler
-rw-r--r--tests/ui/attr-bad-crate-attr.rs4
-rw-r--r--tests/ui/attr-shebang.rs5
-rw-r--r--tests/ui/attributes/attr-bad-crate-attr.rs9
-rw-r--r--tests/ui/attributes/attr-bad-crate-attr.stderr (renamed from tests/ui/attr-bad-crate-attr.stderr)2
-rw-r--r--tests/ui/attributes/attr-shebang.rs7
-rw-r--r--tests/ui/attributes/inline/attr-usage-inline.rs (renamed from tests/ui/attr-usage-inline.rs)3
-rw-r--r--tests/ui/attributes/inline/attr-usage-inline.stderr (renamed from tests/ui/attr-usage-inline.stderr)4
-rw-r--r--tests/ui/parser/associated-path-shl.rs (renamed from tests/ui/associated-path-shl.rs)0
-rw-r--r--tests/ui/parser/associated-path-shl.stderr (renamed from tests/ui/associated-path-shl.stderr)0
-rw-r--r--tests/ui/resolve/attr-macros-positional-rejection.rs (renamed from tests/ui/attrs-resolution-errors.rs)11
-rw-r--r--tests/ui/resolve/attr-macros-positional-rejection.stderr (renamed from tests/ui/attrs-resolution-errors.stderr)10
-rw-r--r--tests/ui/resolve/non-macro-attrs-accepted.rs (renamed from tests/ui/attrs-resolution.rs)10
-rw-r--r--tests/ui/typeck/attempted-access-non-fatal.rs (renamed from tests/ui/attempted-access-non-fatal.rs)0
-rw-r--r--tests/ui/typeck/attempted-access-non-fatal.stderr (renamed from tests/ui/attempted-access-non-fatal.stderr)0
14 files changed, 45 insertions, 20 deletions
diff --git a/tests/ui/attr-bad-crate-attr.rs b/tests/ui/attr-bad-crate-attr.rs
deleted file mode 100644
index b9100ecfb67..00000000000
--- 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 67c371aeaac..00000000000
--- 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 00000000000..9de0abca9a7
--- /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 <https://doc.rust-lang.org/reference/attributes.html>.
+
+//@ 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
index 9df991f71b3..69eabd32230 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 00000000000..af446dc56e3
--- /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
index 674c12454cd..d8ca0fce163 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
index 22a0bf47e20..2123438032c 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
index 20a6fd83faa..20a6fd83faa 100644
--- a/tests/ui/associated-path-shl.rs
+++ b/tests/ui/parser/associated-path-shl.rs
diff --git a/tests/ui/associated-path-shl.stderr b/tests/ui/parser/associated-path-shl.stderr
index 71ee93f4835..71ee93f4835 100644
--- a/tests/ui/associated-path-shl.stderr
+++ b/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
index 8770fb1ded8..11382ff1399 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
index 883f96e5c19..faea511f315 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
index 38dd3812d68..76a04b2e837 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
index 15deb9e2f60..15deb9e2f60 100644
--- a/tests/ui/attempted-access-non-fatal.rs
+++ b/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
index bff669727a1..bff669727a1 100644
--- a/tests/ui/attempted-access-non-fatal.stderr
+++ b/tests/ui/typeck/attempted-access-non-fatal.stderr