about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-07-01 00:43:31 +0500
committerKivooeo <Kivooeo123@gmail.com>2025-07-05 01:25:48 +0500
commit62ada473281d86e9a7e19d2fe375171874f83cab (patch)
tree6ccf6ea307ad104848352ff83a9d46c7f6c712d6
parent9ad98f78d4485f6f7f9615c1961bb75b281bfceb (diff)
downloadrust-62ada473281d86e9a7e19d2fe375171874f83cab.tar.gz
rust-62ada473281d86e9a7e19d2fe375171874f83cab.zip
cleaned up some tests
-rw-r--r--tests/ui/closures/closure-no-copy-mut-env.rs2
-rw-r--r--tests/ui/closures/closure-no-copy-mut-env.stderr4
-rw-r--r--tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs9
-rw-r--r--tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr20
-rw-r--r--tests/ui/layout/null-pointer-optimization-sizes.rs (renamed from tests/ui/layout/null-pointer-size-optimization.rs)18
-rw-r--r--tests/ui/layout/null-pointer-optimization.rs44
-rw-r--r--tests/ui/str/nul-char-equivalence.rs13
-rw-r--r--tests/ui/traits/trait-object-method-receiver-rules.rs5
-rw-r--r--tests/ui/traits/trait-object-method-receiver-rules.stderr6
-rw-r--r--tests/ui/traits/trait-object-mut-to-shared-coercion.rs4
10 files changed, 70 insertions, 55 deletions
diff --git a/tests/ui/closures/closure-no-copy-mut-env.rs b/tests/ui/closures/closure-no-copy-mut-env.rs
index f6530f9a410..890e99c1ac7 100644
--- a/tests/ui/closures/closure-no-copy-mut-env.rs
+++ b/tests/ui/closures/closure-no-copy-mut-env.rs
@@ -1,4 +1,4 @@
-// Check that closures do not implement `Copy` if their environment is not `Copy`.
+//! Checks that closures do not implement `Copy` when they capture mutable references.
 
 fn main() {
     let mut a = 5;
diff --git a/tests/ui/closures/closure-no-copy-mut-env.stderr b/tests/ui/closures/closure-no-copy-mut-env.stderr
index 60cb1352313..1443366a477 100644
--- a/tests/ui/closures/closure-no-copy-mut-env.stderr
+++ b/tests/ui/closures/closure-no-copy-mut-env.stderr
@@ -1,5 +1,5 @@
 error[E0382]: use of moved value: `hello`
-  --> $DIR/not-copy-closure.rs:10:13
+  --> $DIR/closure-no-copy-mut-env.rs:10:13
    |
 LL |     let b = hello;
    |             ----- value moved here
@@ -7,7 +7,7 @@ LL |     let c = hello;
    |             ^^^^^ value used here after move
    |
 note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment
-  --> $DIR/not-copy-closure.rs:6:9
+  --> $DIR/closure-no-copy-mut-env.rs:6:9
    |
 LL |         a += 1;
    |         ^
diff --git a/tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs
index ec660a1de81..b2f80ba1bf6 100644
--- a/tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs
+++ b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs
@@ -1,15 +1,15 @@
+//! Checks clean diagnostics for argument count mismatches without unrelated errors.
+//!
+//! `delegate!` part related: <https://github.com/rust-lang/rust/pull/140591>
+
 //@ aux-build: delegate_macro.rs
 extern crate delegate_macro;
 use delegate_macro::delegate;
 
-// Check that the only error msg we report is the
-// mismatch between the # of params, and not other
-// unrelated errors.
 fn foo(a: isize, b: isize, c: isize, d: isize) {
     panic!();
 }
 
-// Check that all arguments are shown in the error message, even if they're across multiple lines.
 fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {
     println!("{}", a);
     println!("{}", b);
@@ -37,6 +37,7 @@ struct Bar;
 
 impl Bar {
     fn foo(a: u8, b: u8) {}
+
     fn bar() {
         delegate_local!(foo);
         delegate!(foo);
diff --git a/tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr
index 908d0273bbe..6af7671af03 100644
--- a/tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr
+++ b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr
@@ -1,5 +1,5 @@
 error[E0061]: this function takes 2 arguments but 1 argument was supplied
-  --> $DIR/not-enough-arguments.rs:24:9
+  --> $DIR/fn-arg-count-mismatch-diagnostics.rs:24:9
    |
 LL |         <Self>::$method(8)
    |         ^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing
@@ -8,7 +8,7 @@ LL |         delegate_local!(foo);
    |         -------------------- in this macro invocation
    |
 note: associated function defined here
-  --> $DIR/not-enough-arguments.rs:39:8
+  --> $DIR/fn-arg-count-mismatch-diagnostics.rs:39:8
    |
 LL |     fn foo(a: u8, b: u8) {}
    |        ^^^        -----
@@ -19,20 +19,20 @@ LL |         <Self>::$method(8, /* u8 */)
    |                          ++++++++++
 
 error[E0061]: this function takes 2 arguments but 1 argument was supplied
-  --> $DIR/not-enough-arguments.rs:42:9
+  --> $DIR/fn-arg-count-mismatch-diagnostics.rs:43:9
    |
 LL |         delegate!(foo);
    |         ^^^^^^^^^^^^^^ argument #2 of type `u8` is missing
    |
 note: associated function defined here
-  --> $DIR/not-enough-arguments.rs:39:8
+  --> $DIR/fn-arg-count-mismatch-diagnostics.rs:39:8
    |
 LL |     fn foo(a: u8, b: u8) {}
    |        ^^^        -----
    = note: this error originates in the macro `delegate` (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error[E0061]: this function takes 2 arguments but 1 argument was supplied
-  --> $DIR/not-enough-arguments.rs:31:9
+  --> $DIR/fn-arg-count-mismatch-diagnostics.rs:31:9
    |
 LL |         <$from>::$method(8)
    |         ^^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing
@@ -41,7 +41,7 @@ LL |         delegate_from!(Bar, foo);
    |         ------------------------ in this macro invocation
    |
 note: associated function defined here
-  --> $DIR/not-enough-arguments.rs:39:8
+  --> $DIR/fn-arg-count-mismatch-diagnostics.rs:39:8
    |
 LL |     fn foo(a: u8, b: u8) {}
    |        ^^^        -----
@@ -52,13 +52,13 @@ LL |         <$from>::$method(8, /* u8 */)
    |                           ++++++++++
 
 error[E0061]: this function takes 4 arguments but 3 arguments were supplied
-  --> $DIR/not-enough-arguments.rs:49:5
+  --> $DIR/fn-arg-count-mismatch-diagnostics.rs:50:5
    |
 LL |     foo(1, 2, 3);
    |     ^^^--------- argument #4 of type `isize` is missing
    |
 note: function defined here
-  --> $DIR/not-enough-arguments.rs:8:4
+  --> $DIR/fn-arg-count-mismatch-diagnostics.rs:9:4
    |
 LL | fn foo(a: isize, b: isize, c: isize, d: isize) {
    |    ^^^                               --------
@@ -68,13 +68,13 @@ LL |     foo(1, 2, 3, /* isize */);
    |                +++++++++++++
 
 error[E0061]: this function takes 6 arguments but 3 arguments were supplied
-  --> $DIR/not-enough-arguments.rs:51:5
+  --> $DIR/fn-arg-count-mismatch-diagnostics.rs:52:5
    |
 LL |     bar(1, 2, 3);
    |     ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing
    |
 note: function defined here
-  --> $DIR/not-enough-arguments.rs:13:4
+  --> $DIR/fn-arg-count-mismatch-diagnostics.rs:13:4
    |
 LL | fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) {
    |    ^^^                         ------  ------  ------
diff --git a/tests/ui/layout/null-pointer-size-optimization.rs b/tests/ui/layout/null-pointer-optimization-sizes.rs
index aabdfa140df..95310b32e25 100644
--- a/tests/ui/layout/null-pointer-size-optimization.rs
+++ b/tests/ui/layout/null-pointer-optimization-sizes.rs
@@ -1,10 +1,20 @@
+//! null pointer optimization preserves type sizes.
+//!
+//! Verifies that Option<T> has the same size as T for non-null pointer types,
+//! and for custom enums that have a niche.
+
 //@ run-pass
 
+// Needs for Nothing variat in Enum
 #![allow(dead_code)]
 
 use std::mem;
 
-enum E<T> { Thing(isize, T), Nothing((), ((), ()), [i8; 0]) }
+enum E<T> {
+    Thing(isize, T),
+    Nothing((), ((), ()), [i8; 0]),
+}
+
 struct S<T>(isize, T);
 
 // These are macros so we get useful assert messages.
@@ -12,20 +22,20 @@ struct S<T>(isize, T);
 macro_rules! check_option {
     ($T:ty) => {
         assert_eq!(mem::size_of::<Option<$T>>(), mem::size_of::<$T>());
-    }
+    };
 }
 
 macro_rules! check_fancy {
     ($T:ty) => {
         assert_eq!(mem::size_of::<E<$T>>(), mem::size_of::<S<$T>>());
-    }
+    };
 }
 
 macro_rules! check_type {
     ($T:ty) => {{
         check_option!($T);
         check_fancy!($T);
-    }}
+    }};
 }
 
 pub fn main() {
diff --git a/tests/ui/layout/null-pointer-optimization.rs b/tests/ui/layout/null-pointer-optimization.rs
index 1b73164c9fc..5e77c8d22ab 100644
--- a/tests/ui/layout/null-pointer-optimization.rs
+++ b/tests/ui/layout/null-pointer-optimization.rs
@@ -1,27 +1,34 @@
-//@ run-pass
+//! null pointer optimization with iota-reduction for enums.
+//!
+//! Iota-reduction is a rule from the Calculus of (Co-)Inductive Constructions:
+//! "a destructor applied to an object built from a constructor behaves as expected".
+//! See <https://coq.inria.fr/doc/language/core/conversion.html#iota-reduction>.
+//!
+//! This test verifies that null pointer optimization works correctly for both
+//! Option<T> and custom enums, accounting for pointers and regions.
 
-// Iota-reduction is a rule in the Calculus of (Co-)Inductive Constructions,
-// which "says that a destructor applied to an object built from a constructor
-// behaves as expected".  -- https://coq.inria.fr/doc/language/core/conversion.html#iota-reduction
-//
-// It's a little more complicated here, because of pointers and regions and
-// trying to get assert failure messages that at least identify which case
-// failed.
+//@ run-pass
 
 #![allow(unpredictable_function_pointer_comparisons)]
 
-enum E<T> { Thing(isize, T), #[allow(dead_code)] Nothing((), ((), ()), [i8; 0]) }
+enum E<T> {
+    Thing(isize, T),
+    #[allow(dead_code)]
+    Nothing((), ((), ()), [i8; 0]),
+}
+
 impl<T> E<T> {
     fn is_none(&self) -> bool {
         match *self {
             E::Thing(..) => false,
-            E::Nothing(..) => true
+            E::Nothing(..) => true,
         }
     }
+
     fn get_ref(&self) -> (isize, &T) {
         match *self {
-            E::Nothing(..) => panic!("E::get_ref(Nothing::<{}>)",  stringify!(T)),
-            E::Thing(x, ref y) => (x, y)
+            E::Nothing(..) => panic!("E::get_ref(Nothing::<{}>)", stringify!(T)),
+            E::Thing(x, ref y) => (x, y),
         }
     }
 }
@@ -36,7 +43,7 @@ macro_rules! check_option {
         let s_ = Some::<$T>(e);
         let $v = s_.as_ref().unwrap();
         $chk
-    }}
+    }};
 }
 
 macro_rules! check_fancy {
@@ -48,11 +55,10 @@ macro_rules! check_fancy {
         let e = $e;
         let t_ = E::Thing::<$T>(23, e);
         match t_.get_ref() {
-            (23, $v) => { $chk }
-            _ => panic!("Thing::<{}>(23, {}).get_ref() != (23, _)",
-                       stringify!($T), stringify!($e))
+            (23, $v) => $chk,
+            _ => panic!("Thing::<{}>(23, {}).get_ref() != (23, _)", stringify!($T), stringify!($e)),
         }
-    }}
+    }};
 }
 
 macro_rules! check_type {
@@ -67,7 +73,5 @@ pub fn main() {
     check_type!(Box::new(18), Box<isize>);
     check_type!("foo".to_string(), String);
     check_type!(vec![20, 22], Vec<isize>);
-    check_type!(main, fn(), |pthing| {
-        assert_eq!(main as fn(), *pthing as fn())
-    });
+    check_type!(main, fn(), |pthing| assert_eq!(main as fn(), *pthing as fn()));
 }
diff --git a/tests/ui/str/nul-char-equivalence.rs b/tests/ui/str/nul-char-equivalence.rs
index eb83f440d3e..2d4110de681 100644
--- a/tests/ui/str/nul-char-equivalence.rs
+++ b/tests/ui/str/nul-char-equivalence.rs
@@ -1,7 +1,8 @@
+//! Checks that different NUL character representations are equivalent in strings and chars.
+
 //@ run-pass
 
-pub fn main()
-{
+pub fn main() {
     let all_nuls1 = "\0\x00\u{0}\u{0}";
     let all_nuls2 = "\u{0}\u{0}\x00\0";
     let all_nuls3 = "\u{0}\u{0}\x00\0";
@@ -17,11 +18,9 @@ pub fn main()
     assert_eq!(all_nuls3, all_nuls4);
 
     // all extracted characters in all_nuls are equivalent to each other
-    for c1 in all_nuls1.chars()
-    {
-        for c2 in all_nuls1.chars()
-        {
-            assert_eq!(c1,c2);
+    for c1 in all_nuls1.chars() {
+        for c2 in all_nuls1.chars() {
+            assert_eq!(c1, c2);
         }
     }
 
diff --git a/tests/ui/traits/trait-object-method-receiver-rules.rs b/tests/ui/traits/trait-object-method-receiver-rules.rs
index 760a50e5b79..383e59c131a 100644
--- a/tests/ui/traits/trait-object-method-receiver-rules.rs
+++ b/tests/ui/traits/trait-object-method-receiver-rules.rs
@@ -1,7 +1,8 @@
+//! Checks that method availability rules for trait objects depend on receiver type.
+
 trait Foo {
     fn borrowed(&self);
     fn borrowed_mut(&mut self);
-
     fn owned(self: Box<Self>);
 }
 
@@ -20,7 +21,7 @@ fn borrowed_mut_receiver(x: &mut dyn Foo) {
 fn owned_receiver(x: Box<dyn Foo>) {
     x.borrowed();
     x.borrowed_mut(); // See [1]
-    x.managed();  //~ ERROR no method named `managed` found
+    x.managed(); //~ ERROR no method named `managed` found
     x.owned();
 }
 
diff --git a/tests/ui/traits/trait-object-method-receiver-rules.stderr b/tests/ui/traits/trait-object-method-receiver-rules.stderr
index 72b290f2ad9..83b61a2e6b5 100644
--- a/tests/ui/traits/trait-object-method-receiver-rules.stderr
+++ b/tests/ui/traits/trait-object-method-receiver-rules.stderr
@@ -1,5 +1,5 @@
 error[E0599]: no method named `owned` found for reference `&dyn Foo` in the current scope
-  --> $DIR/object-pointer-types.rs:11:7
+  --> $DIR/trait-object-method-receiver-rules.rs:12:7
    |
 LL |     fn owned(self: Box<Self>);
    |                    --------- the method might not be found because of this arbitrary self type
@@ -13,7 +13,7 @@ LL |     x.to_owned();
    |       +++
 
 error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo` in the current scope
-  --> $DIR/object-pointer-types.rs:17:7
+  --> $DIR/trait-object-method-receiver-rules.rs:18:7
    |
 LL |     fn owned(self: Box<Self>);
    |                    --------- the method might not be found because of this arbitrary self type
@@ -22,7 +22,7 @@ LL |     x.owned();
    |       ^^^^^ method not found in `&mut dyn Foo`
 
 error[E0599]: no method named `managed` found for struct `Box<(dyn Foo + 'static)>` in the current scope
-  --> $DIR/object-pointer-types.rs:23:7
+  --> $DIR/trait-object-method-receiver-rules.rs:24:7
    |
 LL |     x.managed();
    |       ^^^^^^^ method not found in `Box<(dyn Foo + 'static)>`
diff --git a/tests/ui/traits/trait-object-mut-to-shared-coercion.rs b/tests/ui/traits/trait-object-mut-to-shared-coercion.rs
index e122bb99380..26b5cc6d2df 100644
--- a/tests/ui/traits/trait-object-mut-to-shared-coercion.rs
+++ b/tests/ui/traits/trait-object-mut-to-shared-coercion.rs
@@ -1,6 +1,6 @@
-//@ run-pass
-// Test that we can coerce an `@Object` to an `&Object`
+//! Tests that coercion from `&mut dyn Trait` to `&dyn Trait` works correctly.
 
+//@ run-pass
 
 trait Foo {
     fn foo(&self) -> usize;