Skip to content

Commit ff0a5f5

Browse files
Rollup merge of #143210 - Kivooeo:tf19, r=tgross35
`tests/ui`: A New Order [19/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 #133895. r? `@tgross35`
2 parents 1f88117 + bf5910d commit ff0a5f5

26 files changed

+265
-222
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
//! Test basic closure syntax and usage with generic functions.
2+
//!
3+
//! This test checks that closure syntax works correctly for:
4+
//! - Closures with parameters and return values
5+
//! - Closures without parameters (both expression and block forms)
6+
//! - Integration with generic functions and FnOnce trait bounds
7+
8+
//@ run-pass
9+
10+
fn f<F>(i: isize, f: F) -> isize
11+
where
12+
F: FnOnce(isize) -> isize,
13+
{
14+
f(i)
15+
}
16+
17+
fn g<G>(_g: G)
18+
where
19+
G: FnOnce(),
20+
{
21+
}
22+
23+
pub fn main() {
24+
// Closure with parameter that returns the same value
25+
assert_eq!(f(10, |a| a), 10);
26+
27+
// Closure without parameters - expression form
28+
g(|| ());
29+
30+
// Test closure reuse in generic context
31+
assert_eq!(f(10, |a| a), 10);
32+
33+
// Closure without parameters - block form
34+
g(|| {});
35+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! Test newtype pattern with generic parameters.
2+
3+
//@ run-pass
4+
5+
#[derive(Clone)]
6+
struct MyVec<T>(Vec<T>);
7+
8+
fn extract_inner_vec<T: Clone>(wrapper: MyVec<T>) -> Vec<T> {
9+
let MyVec(inner_vec) = wrapper;
10+
inner_vec.clone()
11+
}
12+
13+
fn get_first_element<T>(wrapper: MyVec<T>) -> T {
14+
let MyVec(inner_vec) = wrapper;
15+
inner_vec.into_iter().next().unwrap()
16+
}
17+
18+
pub fn main() {
19+
let my_vec = MyVec(vec![1, 2, 3]);
20+
let cloned_vec = my_vec.clone();
21+
22+
// Test extracting inner vector
23+
let extracted = extract_inner_vec(cloned_vec);
24+
assert_eq!(extracted[1], 2);
25+
26+
// Test getting first element
27+
assert_eq!(get_first_element(my_vec.clone()), 1);
28+
29+
// Test direct destructuring
30+
let MyVec(inner) = my_vec;
31+
assert_eq!(inner[2], 3);
32+
}

tests/ui/new-impl-syntax.rs renamed to tests/ui/impl-trait/basic-trait-impl.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
//! Test basic trait implementation syntax for both simple and generic types.
2+
13
//@ run-pass
24

35
use std::fmt;
46

57
struct Thingy {
68
x: isize,
7-
y: isize
9+
y: isize,
810
}
911

1012
impl fmt::Debug for Thingy {
@@ -14,10 +16,10 @@ impl fmt::Debug for Thingy {
1416
}
1517

1618
struct PolymorphicThingy<T> {
17-
x: T
19+
x: T,
1820
}
1921

20-
impl<T:fmt::Debug> fmt::Debug for PolymorphicThingy<T> {
22+
impl<T: fmt::Debug> fmt::Debug for PolymorphicThingy<T> {
2123
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2224
write!(f, "{:?}", self.x)
2325
}

tests/ui/new-import-syntax.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/ui/new-style-constants.rs

Lines changed: 0 additions & 7 deletions
This file was deleted.

tests/ui/newlambdas.rs

Lines changed: 0 additions & 14 deletions
This file was deleted.

tests/ui/newtype-polymorphic.rs

Lines changed: 0 additions & 27 deletions
This file was deleted.

tests/ui/newtype.rs

Lines changed: 0 additions & 23 deletions
This file was deleted.

tests/ui/no_send-enum.rs

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/ui/no_send-enum.stderr

Lines changed: 0 additions & 23 deletions
This file was deleted.

0 commit comments

Comments
 (0)