about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKivooeo <Kivooeo123@gmail.com>2025-06-29 23:13:37 +0500
committerKivooeo <Kivooeo123@gmail.com>2025-06-30 11:50:19 +0500
commitbf5910d9bb0c5cc3e4fb1a1a9ed3d73e26793c71 (patch)
treeeeec900b449e7889d0b828c9aca5f6676c943770
parent4b6c3d923f9c9ec869bfc77e6c08e98f9de87ac8 (diff)
downloadrust-bf5910d9bb0c5cc3e4fb1a1a9ed3d73e26793c71.tar.gz
rust-bf5910d9bb0c5cc3e4fb1a1a9ed3d73e26793c71.zip
cleaned up some tests
-rw-r--r--tests/ui/closures/basic-closure-syntax.rs33
-rw-r--r--tests/ui/generics/newtype-with-generics.rs39
-rw-r--r--tests/ui/impl-trait/basic-trait-impl.rs8
-rw-r--r--tests/ui/parser/unicode-escape-sequences.rs6
-rw-r--r--tests/ui/structs/basic-newtype-pattern.rs24
-rw-r--r--tests/ui/traits/enum-negative-send-impl.rs14
-rw-r--r--tests/ui/traits/enum-negative-send-impl.stderr24
-rw-r--r--tests/ui/traits/enum-negative-sync-impl.rs14
-rw-r--r--tests/ui/traits/enum-negative-sync-impl.stderr24
-rw-r--r--tests/ui/traits/rc-not-send.rs8
-rw-r--r--tests/ui/traits/rc-not-send.stderr18
-rw-r--r--tests/ui/traits/struct-negative-sync-impl.rs19
-rw-r--r--tests/ui/traits/struct-negative-sync-impl.stderr18
13 files changed, 152 insertions, 97 deletions
diff --git a/tests/ui/closures/basic-closure-syntax.rs b/tests/ui/closures/basic-closure-syntax.rs
index 75e851fb73a..1d968f8cf4a 100644
--- a/tests/ui/closures/basic-closure-syntax.rs
+++ b/tests/ui/closures/basic-closure-syntax.rs
@@ -1,14 +1,35 @@
-//@ run-pass
-// Tests for the new |args| expr lambda syntax
+//! Test basic closure syntax and usage with generic functions.
+//!
+//! This test checks that closure syntax works correctly for:
+//! - Closures with parameters and return values
+//! - Closures without parameters (both expression and block forms)
+//! - Integration with generic functions and FnOnce trait bounds
 
+//@ run-pass
 
-fn f<F>(i: isize, f: F) -> isize where F: FnOnce(isize) -> isize { f(i) }
+fn f<F>(i: isize, f: F) -> isize
+where
+    F: FnOnce(isize) -> isize,
+{
+    f(i)
+}
 
-fn g<G>(_g: G) where G: FnOnce() { }
+fn g<G>(_g: G)
+where
+    G: FnOnce(),
+{
+}
 
 pub fn main() {
+    // Closure with parameter that returns the same value
     assert_eq!(f(10, |a| a), 10);
-    g(||());
+
+    // Closure without parameters - expression form
+    g(|| ());
+
+    // Test closure reuse in generic context
     assert_eq!(f(10, |a| a), 10);
-    g(||{});
+
+    // Closure without parameters - block form
+    g(|| {});
 }
diff --git a/tests/ui/generics/newtype-with-generics.rs b/tests/ui/generics/newtype-with-generics.rs
index 146d49fdf68..c5e200e4bc4 100644
--- a/tests/ui/generics/newtype-with-generics.rs
+++ b/tests/ui/generics/newtype-with-generics.rs
@@ -1,27 +1,32 @@
-//@ run-pass
-
-#![allow(non_camel_case_types)]
+//! Test newtype pattern with generic parameters.
 
+//@ run-pass
 
 #[derive(Clone)]
-struct myvec<X>(Vec<X> );
+struct MyVec<T>(Vec<T>);
 
-fn myvec_deref<X:Clone>(mv: myvec<X>) -> Vec<X> {
-    let myvec(v) = mv;
-    return v.clone();
+fn extract_inner_vec<T: Clone>(wrapper: MyVec<T>) -> Vec<T> {
+    let MyVec(inner_vec) = wrapper;
+    inner_vec.clone()
 }
 
-fn myvec_elt<X>(mv: myvec<X>) -> X {
-    let myvec(v) = mv;
-    return v.into_iter().next().unwrap();
+fn get_first_element<T>(wrapper: MyVec<T>) -> T {
+    let MyVec(inner_vec) = wrapper;
+    inner_vec.into_iter().next().unwrap()
 }
 
 pub fn main() {
-    let mv = myvec(vec![1, 2, 3]);
-    let mv_clone = mv.clone();
-    let mv_clone = myvec_deref(mv_clone);
-    assert_eq!(mv_clone[1], 2);
-    assert_eq!(myvec_elt(mv.clone()), 1);
-    let myvec(v) = mv;
-    assert_eq!(v[2], 3);
+    let my_vec = MyVec(vec![1, 2, 3]);
+    let cloned_vec = my_vec.clone();
+
+    // Test extracting inner vector
+    let extracted = extract_inner_vec(cloned_vec);
+    assert_eq!(extracted[1], 2);
+
+    // Test getting first element
+    assert_eq!(get_first_element(my_vec.clone()), 1);
+
+    // Test direct destructuring
+    let MyVec(inner) = my_vec;
+    assert_eq!(inner[2], 3);
 }
diff --git a/tests/ui/impl-trait/basic-trait-impl.rs b/tests/ui/impl-trait/basic-trait-impl.rs
index 124d604e6a8..2706c9c1798 100644
--- a/tests/ui/impl-trait/basic-trait-impl.rs
+++ b/tests/ui/impl-trait/basic-trait-impl.rs
@@ -1,10 +1,12 @@
+//! Test basic trait implementation syntax for both simple and generic types.
+
 //@ run-pass
 
 use std::fmt;
 
 struct Thingy {
     x: isize,
-    y: isize
+    y: isize,
 }
 
 impl fmt::Debug for Thingy {
@@ -14,10 +16,10 @@ impl fmt::Debug for Thingy {
 }
 
 struct PolymorphicThingy<T> {
-    x: T
+    x: T,
 }
 
-impl<T:fmt::Debug> fmt::Debug for PolymorphicThingy<T> {
+impl<T: fmt::Debug> fmt::Debug for PolymorphicThingy<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{:?}", self.x)
     }
diff --git a/tests/ui/parser/unicode-escape-sequences.rs b/tests/ui/parser/unicode-escape-sequences.rs
index 867a50da081..8b084866f19 100644
--- a/tests/ui/parser/unicode-escape-sequences.rs
+++ b/tests/ui/parser/unicode-escape-sequences.rs
@@ -1,6 +1,12 @@
+//! Test ES6-style Unicode escape sequences in string literals.
+//!
+//! Regression test for RFC 446 implementation.
+//! See <https://github.com/rust-lang/rust/pull/19480>.
+
 //@ run-pass
 
 pub fn main() {
+    // Basic Unicode escape - snowman character
     let s = "\u{2603}";
     assert_eq!(s, "☃");
 
diff --git a/tests/ui/structs/basic-newtype-pattern.rs b/tests/ui/structs/basic-newtype-pattern.rs
index 8a07c67eb4f..38ccd0ea8e0 100644
--- a/tests/ui/structs/basic-newtype-pattern.rs
+++ b/tests/ui/structs/basic-newtype-pattern.rs
@@ -1,23 +1,25 @@
+//! Test basic newtype pattern functionality.
+
 //@ run-pass
 
-#![allow(non_camel_case_types)]
 #[derive(Copy, Clone)]
-struct mytype(Mytype);
+struct Counter(CounterData);
 
 #[derive(Copy, Clone)]
-struct Mytype {
-    compute: fn(mytype) -> isize,
+struct CounterData {
+    compute: fn(Counter) -> isize,
     val: isize,
 }
 
-fn compute(i: mytype) -> isize {
-    let mytype(m) = i;
-    return m.val + 20;
+fn compute_value(counter: Counter) -> isize {
+    let Counter(data) = counter;
+    data.val + 20
 }
 
 pub fn main() {
-    let myval = mytype(Mytype{compute: compute, val: 30});
-    println!("{}", compute(myval));
-    let mytype(m) = myval;
-    assert_eq!((m.compute)(myval), 50);
+    let my_counter = Counter(CounterData { compute: compute_value, val: 30 });
+
+    // Test destructuring and function pointer call
+    let Counter(data) = my_counter;
+    assert_eq!((data.compute)(my_counter), 50);
 }
diff --git a/tests/ui/traits/enum-negative-send-impl.rs b/tests/ui/traits/enum-negative-send-impl.rs
index bd560649b99..6bff42e9999 100644
--- a/tests/ui/traits/enum-negative-send-impl.rs
+++ b/tests/ui/traits/enum-negative-send-impl.rs
@@ -1,3 +1,7 @@
+//! Test that enums inherit Send/!Send properties from their variants.
+//!
+//! Uses the unstable `negative_impls` feature to explicitly opt-out of Send.
+
 #![feature(negative_impls)]
 
 use std::marker::Send;
@@ -5,14 +9,14 @@ use std::marker::Send;
 struct NoSend;
 impl !Send for NoSend {}
 
-enum Foo {
-    A(NoSend)
+enum Container {
+    WithNoSend(NoSend),
 }
 
-fn bar<T: Send>(_: T) {}
+fn requires_send<T: Send>(_: T) {}
 
 fn main() {
-    let x = Foo::A(NoSend);
-    bar(x);
+    let container = Container::WithNoSend(NoSend);
+    requires_send(container);
     //~^ ERROR `NoSend` cannot be sent between threads safely
 }
diff --git a/tests/ui/traits/enum-negative-send-impl.stderr b/tests/ui/traits/enum-negative-send-impl.stderr
index 3b66c7db545..1992becccf4 100644
--- a/tests/ui/traits/enum-negative-send-impl.stderr
+++ b/tests/ui/traits/enum-negative-send-impl.stderr
@@ -1,22 +1,22 @@
 error[E0277]: `NoSend` cannot be sent between threads safely
-  --> $DIR/no_send-enum.rs:16:9
+  --> $DIR/enum-negative-send-impl.rs:20:19
    |
-LL |     bar(x);
-   |     --- ^ `NoSend` cannot be sent between threads safely
+LL |     requires_send(container);
+   |     ------------- ^^^^^^^^^ `NoSend` cannot be sent between threads safely
    |     |
    |     required by a bound introduced by this call
    |
-   = help: within `Foo`, the trait `Send` is not implemented for `NoSend`
-note: required because it appears within the type `Foo`
-  --> $DIR/no_send-enum.rs:8:6
+   = help: within `Container`, the trait `Send` is not implemented for `NoSend`
+note: required because it appears within the type `Container`
+  --> $DIR/enum-negative-send-impl.rs:12:6
    |
-LL | enum Foo {
-   |      ^^^
-note: required by a bound in `bar`
-  --> $DIR/no_send-enum.rs:12:11
+LL | enum Container {
+   |      ^^^^^^^^^
+note: required by a bound in `requires_send`
+  --> $DIR/enum-negative-send-impl.rs:16:21
    |
-LL | fn bar<T: Send>(_: T) {}
-   |           ^^^^ required by this bound in `bar`
+LL | fn requires_send<T: Send>(_: T) {}
+   |                     ^^^^ required by this bound in `requires_send`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/traits/enum-negative-sync-impl.rs b/tests/ui/traits/enum-negative-sync-impl.rs
index 44bf1913e7a..aa81a9fbbf9 100644
--- a/tests/ui/traits/enum-negative-sync-impl.rs
+++ b/tests/ui/traits/enum-negative-sync-impl.rs
@@ -1,3 +1,7 @@
+//! Test that enums inherit Sync/!Sync properties from their variants.
+//!
+//! Uses the unstable `negative_impls` feature to explicitly opt-out of Sync.
+
 #![feature(negative_impls)]
 
 use std::marker::Sync;
@@ -5,12 +9,14 @@ use std::marker::Sync;
 struct NoSync;
 impl !Sync for NoSync {}
 
-enum Foo { A(NoSync) }
+enum Container {
+    WithNoSync(NoSync),
+}
 
-fn bar<T: Sync>(_: T) {}
+fn requires_sync<T: Sync>(_: T) {}
 
 fn main() {
-    let x = Foo::A(NoSync);
-    bar(x);
+    let container = Container::WithNoSync(NoSync);
+    requires_sync(container);
     //~^ ERROR `NoSync` cannot be shared between threads safely [E0277]
 }
diff --git a/tests/ui/traits/enum-negative-sync-impl.stderr b/tests/ui/traits/enum-negative-sync-impl.stderr
index 89939216d5b..a97b7a36a7b 100644
--- a/tests/ui/traits/enum-negative-sync-impl.stderr
+++ b/tests/ui/traits/enum-negative-sync-impl.stderr
@@ -1,22 +1,22 @@
 error[E0277]: `NoSync` cannot be shared between threads safely
-  --> $DIR/no_share-enum.rs:14:9
+  --> $DIR/enum-negative-sync-impl.rs:20:19
    |
-LL |     bar(x);
-   |     --- ^ `NoSync` cannot be shared between threads safely
+LL |     requires_sync(container);
+   |     ------------- ^^^^^^^^^ `NoSync` cannot be shared between threads safely
    |     |
    |     required by a bound introduced by this call
    |
-   = help: within `Foo`, the trait `Sync` is not implemented for `NoSync`
-note: required because it appears within the type `Foo`
-  --> $DIR/no_share-enum.rs:8:6
+   = help: within `Container`, the trait `Sync` is not implemented for `NoSync`
+note: required because it appears within the type `Container`
+  --> $DIR/enum-negative-sync-impl.rs:12:6
    |
-LL | enum Foo { A(NoSync) }
-   |      ^^^
-note: required by a bound in `bar`
-  --> $DIR/no_share-enum.rs:10:11
+LL | enum Container {
+   |      ^^^^^^^^^
+note: required by a bound in `requires_sync`
+  --> $DIR/enum-negative-sync-impl.rs:16:21
    |
-LL | fn bar<T: Sync>(_: T) {}
-   |           ^^^^ required by this bound in `bar`
+LL | fn requires_sync<T: Sync>(_: T) {}
+   |                     ^^^^ required by this bound in `requires_sync`
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/traits/rc-not-send.rs b/tests/ui/traits/rc-not-send.rs
index f31db15ef2e..83084c6173a 100644
--- a/tests/ui/traits/rc-not-send.rs
+++ b/tests/ui/traits/rc-not-send.rs
@@ -1,9 +1,11 @@
+//! Test that `Rc<T>` does not implement `Send`.
+
 use std::rc::Rc;
 
-fn bar<T: Send>(_: T) {}
+fn requires_send<T: Send>(_: T) {}
 
 fn main() {
-    let x = Rc::new(5);
-    bar(x);
+    let rc_value = Rc::new(5);
+    requires_send(rc_value);
     //~^ ERROR `Rc<{integer}>` cannot be sent between threads safely
 }
diff --git a/tests/ui/traits/rc-not-send.stderr b/tests/ui/traits/rc-not-send.stderr
index 1430a7a29ea..d6171a39ad0 100644
--- a/tests/ui/traits/rc-not-send.stderr
+++ b/tests/ui/traits/rc-not-send.stderr
@@ -1,21 +1,21 @@
 error[E0277]: `Rc<{integer}>` cannot be sent between threads safely
-  --> $DIR/no_send-rc.rs:7:9
+  --> $DIR/rc-not-send.rs:9:19
    |
-LL |     bar(x);
-   |     --- ^ `Rc<{integer}>` cannot be sent between threads safely
+LL |     requires_send(rc_value);
+   |     ------------- ^^^^^^^^ `Rc<{integer}>` cannot be sent between threads safely
    |     |
    |     required by a bound introduced by this call
    |
    = help: the trait `Send` is not implemented for `Rc<{integer}>`
-note: required by a bound in `bar`
-  --> $DIR/no_send-rc.rs:3:11
+note: required by a bound in `requires_send`
+  --> $DIR/rc-not-send.rs:5:21
    |
-LL | fn bar<T: Send>(_: T) {}
-   |           ^^^^ required by this bound in `bar`
+LL | fn requires_send<T: Send>(_: T) {}
+   |                     ^^^^ required by this bound in `requires_send`
 help: consider dereferencing here
    |
-LL |     bar(*x);
-   |         +
+LL |     requires_send(*rc_value);
+   |                   +
 
 error: aborting due to 1 previous error
 
diff --git a/tests/ui/traits/struct-negative-sync-impl.rs b/tests/ui/traits/struct-negative-sync-impl.rs
index 7d8a36a76f2..d32846276f6 100644
--- a/tests/ui/traits/struct-negative-sync-impl.rs
+++ b/tests/ui/traits/struct-negative-sync-impl.rs
@@ -1,14 +1,21 @@
+//! Test negative Sync implementation on structs.
+//!
+//! Uses the unstable `negative_impls` feature to explicitly opt-out of Sync.
+
 #![feature(negative_impls)]
 
 use std::marker::Sync;
 
-struct Foo { a: isize }
-impl !Sync for Foo {}
+struct NotSync {
+    value: isize,
+}
+
+impl !Sync for NotSync {}
 
-fn bar<T: Sync>(_: T) {}
+fn requires_sync<T: Sync>(_: T) {}
 
 fn main() {
-    let x = Foo { a: 5 };
-    bar(x);
-    //~^ ERROR `Foo` cannot be shared between threads safely [E0277]
+    let not_sync = NotSync { value: 5 };
+    requires_sync(not_sync);
+    //~^ ERROR `NotSync` cannot be shared between threads safely [E0277]
 }
diff --git a/tests/ui/traits/struct-negative-sync-impl.stderr b/tests/ui/traits/struct-negative-sync-impl.stderr
index 9c7a921b8d8..c5fd13f42e5 100644
--- a/tests/ui/traits/struct-negative-sync-impl.stderr
+++ b/tests/ui/traits/struct-negative-sync-impl.stderr
@@ -1,17 +1,17 @@
-error[E0277]: `Foo` cannot be shared between threads safely
-  --> $DIR/no_share-struct.rs:12:9
+error[E0277]: `NotSync` cannot be shared between threads safely
+  --> $DIR/struct-negative-sync-impl.rs:19:19
    |
-LL |     bar(x);
-   |     --- ^ `Foo` cannot be shared between threads safely
+LL |     requires_sync(not_sync);
+   |     ------------- ^^^^^^^^ `NotSync` cannot be shared between threads safely
    |     |
    |     required by a bound introduced by this call
    |
-   = help: the trait `Sync` is not implemented for `Foo`
-note: required by a bound in `bar`
-  --> $DIR/no_share-struct.rs:8:11
+   = help: the trait `Sync` is not implemented for `NotSync`
+note: required by a bound in `requires_sync`
+  --> $DIR/struct-negative-sync-impl.rs:15:21
    |
-LL | fn bar<T: Sync>(_: T) {}
-   |           ^^^^ required by this bound in `bar`
+LL | fn requires_sync<T: Sync>(_: T) {}
+   |                     ^^^^ required by this bound in `requires_sync`
 
 error: aborting due to 1 previous error