about summary refs log tree commit diff
diff options
context:
space:
mode:
authordianqk <dianqk@dianqk.net>2025-06-30 19:23:18 +0800
committerGitHub <noreply@github.com>2025-06-30 19:23:18 +0800
commit8ccffc987a90f1b24f1156a5d04884ed80f055ea (patch)
tree7d8f5d17a7b18649d6da6090665940df774a195a
parent3a35f36ae848290fbdc7b3e18555a0f94d1ce7a2 (diff)
parentc240566561b1b819e102618dcf9347b1745f3c92 (diff)
downloadrust-8ccffc987a90f1b24f1156a5d04884ed80f055ea.tar.gz
rust-8ccffc987a90f1b24f1156a5d04884ed80f055ea.zip
Rollup merge of #143168 - Kivooeo:tf16, r=tgross35
`tests/ui`: A New Order [16/N]

> [!NOTE]
>
> Intermediate commits are intended to help review, but will be squashed prior to merge.

Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of rust-lang/rust#133895.

r? `@tgross35`

(just small one to test new method, also I should squash all this commits except move commit, so we after review will end up having like one move commit and one commit with changes, right?)
-rw-r--r--tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs12
-rw-r--r--tests/ui/lint/missing-debug-implementations-lint.rs (renamed from tests/ui/missing_debug_impls.rs)8
-rw-r--r--tests/ui/lint/missing-debug-implementations-lint.stderr (renamed from tests/ui/missing_debug_impls.stderr)6
-rw-r--r--tests/ui/maximal_mir_to_hir_coverage.rs10
-rw-r--r--tests/ui/maybe-bounds.rs9
-rw-r--r--tests/ui/method-output-diff-issue-127263.rs8
-rw-r--r--tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs16
-rw-r--r--tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.stderr (renamed from tests/ui/method-output-diff-issue-127263.stderr)4
-rw-r--r--tests/ui/mod-subitem-as-enum-variant.rs9
-rw-r--r--tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs18
-rw-r--r--tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr (renamed from tests/ui/maybe-bounds.stderr)6
-rw-r--r--tests/ui/type-alias-enum-variants/module-type-args-error.rs16
-rw-r--r--tests/ui/type-alias-enum-variants/module-type-args-error.stderr (renamed from tests/ui/mod-subitem-as-enum-variant.stderr)2
13 files changed, 76 insertions, 48 deletions
diff --git a/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs b/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs
new file mode 100644
index 00000000000..64c31beba28
--- /dev/null
+++ b/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs
@@ -0,0 +1,12 @@
+//! Test that -Z maximal-hir-to-mir-coverage flag is accepted.
+//!
+//! Original PR: https://github.com/rust-lang/rust/pull/105286
+
+//@ compile-flags: -Zmaximal-hir-to-mir-coverage
+//@ run-pass
+
+fn main() {
+    let x = 1;
+    let y = x + 1;
+    println!("{y}");
+}
diff --git a/tests/ui/missing_debug_impls.rs b/tests/ui/lint/missing-debug-implementations-lint.rs
index 3abc0706887..8a93f052f9c 100644
--- a/tests/ui/missing_debug_impls.rs
+++ b/tests/ui/lint/missing-debug-implementations-lint.rs
@@ -1,3 +1,7 @@
+//! Test the `missing_debug_implementations` lint that warns about public types without Debug.
+//!
+//! See https://github.com/rust-lang/rust/issues/20855
+
 //@ compile-flags: --crate-type lib
 #![deny(missing_debug_implementations)]
 #![allow(unused)]
@@ -10,7 +14,6 @@ pub enum A {} //~ ERROR type does not implement `Debug`
 pub enum B {}
 
 pub enum C {}
-
 impl fmt::Debug for C {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         Ok(())
@@ -23,15 +26,14 @@ pub struct Foo; //~ ERROR type does not implement `Debug`
 pub struct Bar;
 
 pub struct Baz;
-
 impl fmt::Debug for Baz {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         Ok(())
     }
 }
 
+// Private types should not trigger the lint
 struct PrivateStruct;
-
 enum PrivateEnum {}
 
 #[derive(Debug)]
diff --git a/tests/ui/missing_debug_impls.stderr b/tests/ui/lint/missing-debug-implementations-lint.stderr
index 0538f207b44..288ab981034 100644
--- a/tests/ui/missing_debug_impls.stderr
+++ b/tests/ui/lint/missing-debug-implementations-lint.stderr
@@ -1,17 +1,17 @@
 error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
-  --> $DIR/missing_debug_impls.rs:7:1
+  --> $DIR/missing-debug-implementations-lint.rs:11:1
    |
 LL | pub enum A {}
    | ^^^^^^^^^^^^^
    |
 note: the lint level is defined here
-  --> $DIR/missing_debug_impls.rs:2:9
+  --> $DIR/missing-debug-implementations-lint.rs:6:9
    |
 LL | #![deny(missing_debug_implementations)]
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation
-  --> $DIR/missing_debug_impls.rs:20:1
+  --> $DIR/missing-debug-implementations-lint.rs:23:1
    |
 LL | pub struct Foo;
    | ^^^^^^^^^^^^^^^
diff --git a/tests/ui/maximal_mir_to_hir_coverage.rs b/tests/ui/maximal_mir_to_hir_coverage.rs
deleted file mode 100644
index e57c83d007e..00000000000
--- a/tests/ui/maximal_mir_to_hir_coverage.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-//@ compile-flags: -Zmaximal-hir-to-mir-coverage
-//@ run-pass
-
-// Just making sure this flag is accepted and doesn't crash the compiler
-
-fn main() {
-  let x = 1;
-  let y = x + 1;
-  println!("{y}");
-}
diff --git a/tests/ui/maybe-bounds.rs b/tests/ui/maybe-bounds.rs
deleted file mode 100644
index 02ed45c656f..00000000000
--- a/tests/ui/maybe-bounds.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-trait Tr: ?Sized {}
-//~^ ERROR `?Trait` is not permitted in supertraits
-
-type A1 = dyn Tr + (?Sized);
-//~^ ERROR `?Trait` is not permitted in trait object types
-type A2 = dyn for<'a> Tr + (?Sized);
-//~^ ERROR `?Trait` is not permitted in trait object types
-
-fn main() {}
diff --git a/tests/ui/method-output-diff-issue-127263.rs b/tests/ui/method-output-diff-issue-127263.rs
deleted file mode 100644
index 85a903e2453..00000000000
--- a/tests/ui/method-output-diff-issue-127263.rs
+++ /dev/null
@@ -1,8 +0,0 @@
-fn bar() {}
-fn foo(x: i32) -> u32 {
-    0
-}
-fn main() {
-    let b: fn() -> u32 = bar; //~ ERROR mismatched types [E0308]
-    let f: fn(i32) = foo; //~ ERROR mismatched types [E0308]
-}
diff --git a/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs
new file mode 100644
index 00000000000..e28ca3e55b5
--- /dev/null
+++ b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs
@@ -0,0 +1,16 @@
+//! This test checks that when there's a type mismatch between a function item and
+//! a function pointer, the error message focuses on the actual type difference
+//! (return types, argument types) rather than the confusing "pointer vs item" distinction.
+//!
+//! See https://github.com/rust-lang/rust/issues/127263
+
+fn bar() {}
+
+fn foo(x: i32) -> u32 {
+    0
+}
+
+fn main() {
+    let b: fn() -> u32 = bar; //~ ERROR mismatched types [E0308]
+    let f: fn(i32) = foo; //~ ERROR mismatched types [E0308]
+}
diff --git a/tests/ui/method-output-diff-issue-127263.stderr b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.stderr
index 35b86114f16..8d63f2ea2d3 100644
--- a/tests/ui/method-output-diff-issue-127263.stderr
+++ b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.stderr
@@ -1,5 +1,5 @@
 error[E0308]: mismatched types
-  --> $DIR/method-output-diff-issue-127263.rs:6:26
+  --> $DIR/fn-pointer-mismatch-diagnostics.rs:14:26
    |
 LL |     let b: fn() -> u32 = bar;
    |            -----------   ^^^ expected fn pointer, found fn item
@@ -10,7 +10,7 @@ LL |     let b: fn() -> u32 = bar;
                  found fn item `fn() -> () {bar}`
 
 error[E0308]: mismatched types
-  --> $DIR/method-output-diff-issue-127263.rs:7:22
+  --> $DIR/fn-pointer-mismatch-diagnostics.rs:15:22
    |
 LL |     let f: fn(i32) = foo;
    |            -------   ^^^ expected fn pointer, found fn item
diff --git a/tests/ui/mod-subitem-as-enum-variant.rs b/tests/ui/mod-subitem-as-enum-variant.rs
deleted file mode 100644
index 959024c46f4..00000000000
--- a/tests/ui/mod-subitem-as-enum-variant.rs
+++ /dev/null
@@ -1,9 +0,0 @@
-mod Mod {
-    pub struct FakeVariant<T>(pub T);
-}
-
-fn main() {
-    Mod::FakeVariant::<i32>(0);
-    Mod::<i32>::FakeVariant(0);
-    //~^ ERROR type arguments are not allowed on module `Mod` [E0109]
-}
diff --git a/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs
new file mode 100644
index 00000000000..04963c98765
--- /dev/null
+++ b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs
@@ -0,0 +1,18 @@
+//! Test that ?Trait bounds are forbidden in supertraits and trait object types.
+//!
+//! While `?Sized` and other maybe bounds are allowed in type parameter bounds and where clauses,
+//! they are explicitly forbidden in certain syntactic positions:
+//! - As supertraits in trait definitions
+//! - In trait object type expressions
+//!
+//! See https://github.com/rust-lang/rust/issues/20503
+
+trait Tr: ?Sized {}
+//~^ ERROR `?Trait` is not permitted in supertraits
+
+type A1 = dyn Tr + (?Sized);
+//~^ ERROR `?Trait` is not permitted in trait object types
+type A2 = dyn for<'a> Tr + (?Sized);
+//~^ ERROR `?Trait` is not permitted in trait object types
+
+fn main() {}
diff --git a/tests/ui/maybe-bounds.stderr b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr
index 230d11fd0ae..bd0baa580bd 100644
--- a/tests/ui/maybe-bounds.stderr
+++ b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr
@@ -1,5 +1,5 @@
 error[E0658]: `?Trait` is not permitted in supertraits
-  --> $DIR/maybe-bounds.rs:1:11
+  --> $DIR/maybe-trait-bounds-forbidden-locations.rs:10:11
    |
 LL | trait Tr: ?Sized {}
    |           ^^^^^^
@@ -9,7 +9,7 @@ LL | trait Tr: ?Sized {}
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error[E0658]: `?Trait` is not permitted in trait object types
-  --> $DIR/maybe-bounds.rs:4:20
+  --> $DIR/maybe-trait-bounds-forbidden-locations.rs:13:20
    |
 LL | type A1 = dyn Tr + (?Sized);
    |                    ^^^^^^^^
@@ -18,7 +18,7 @@ LL | type A1 = dyn Tr + (?Sized);
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error[E0658]: `?Trait` is not permitted in trait object types
-  --> $DIR/maybe-bounds.rs:6:28
+  --> $DIR/maybe-trait-bounds-forbidden-locations.rs:15:28
    |
 LL | type A2 = dyn for<'a> Tr + (?Sized);
    |                            ^^^^^^^^
diff --git a/tests/ui/type-alias-enum-variants/module-type-args-error.rs b/tests/ui/type-alias-enum-variants/module-type-args-error.rs
new file mode 100644
index 00000000000..9f7dae4f4f5
--- /dev/null
+++ b/tests/ui/type-alias-enum-variants/module-type-args-error.rs
@@ -0,0 +1,16 @@
+//! Test that type arguments are properly rejected on modules.
+//!
+//! Related PR: https://github.com/rust-lang/rust/pull/56225 (RFC 2338 implementation)
+
+mod Mod {
+    pub struct FakeVariant<T>(pub T);
+}
+
+fn main() {
+    // This should work fine - normal generic struct constructor
+    Mod::FakeVariant::<i32>(0);
+
+    // This should error - type arguments not allowed on modules
+    Mod::<i32>::FakeVariant(0);
+    //~^ ERROR type arguments are not allowed on module `Mod` [E0109]
+}
diff --git a/tests/ui/mod-subitem-as-enum-variant.stderr b/tests/ui/type-alias-enum-variants/module-type-args-error.stderr
index 92d972eba42..4c59d19eaa7 100644
--- a/tests/ui/mod-subitem-as-enum-variant.stderr
+++ b/tests/ui/type-alias-enum-variants/module-type-args-error.stderr
@@ -1,5 +1,5 @@
 error[E0109]: type arguments are not allowed on module `Mod`
-  --> $DIR/mod-subitem-as-enum-variant.rs:7:11
+  --> $DIR/module-type-args-error.rs:14:11
    |
 LL |     Mod::<i32>::FakeVariant(0);
    |     ---   ^^^ type argument not allowed