Skip to content

Commit 036f7cb

Browse files
authored
Unrolled build for #143210
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 4e97337 + bf5910d commit 036f7cb

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.

tests/ui/no_send-rc.rs

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

tests/ui/no_send-rc.stderr

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

tests/ui/no_share-enum.rs

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

tests/ui/no_share-enum.stderr

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

tests/ui/no_share-struct.rs

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

tests/ui/no_share-struct.stderr

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

tests/ui/new-unicode-escapes.rs renamed to tests/ui/parser/unicode-escape-sequences.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
//! Test ES6-style Unicode escape sequences in string literals.
2+
//!
3+
//! Regression test for RFC 446 implementation.
4+
//! See <https://github.com/rust-lang/rust/pull/19480>.
5+
16
//@ run-pass
27

38
pub fn main() {
9+
// Basic Unicode escape - snowman character
410
let s = "\u{2603}";
511
assert_eq!(s, "☃");
612

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//! Test basic newtype pattern functionality.
2+
3+
//@ run-pass
4+
5+
#[derive(Copy, Clone)]
6+
struct Counter(CounterData);
7+
8+
#[derive(Copy, Clone)]
9+
struct CounterData {
10+
compute: fn(Counter) -> isize,
11+
val: isize,
12+
}
13+
14+
fn compute_value(counter: Counter) -> isize {
15+
let Counter(data) = counter;
16+
data.val + 20
17+
}
18+
19+
pub fn main() {
20+
let my_counter = Counter(CounterData { compute: compute_value, val: 30 });
21+
22+
// Test destructuring and function pointer call
23+
let Counter(data) = my_counter;
24+
assert_eq!((data.compute)(my_counter), 50);
25+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//! Test that enums inherit Send/!Send properties from their variants.
2+
//!
3+
//! Uses the unstable `negative_impls` feature to explicitly opt-out of Send.
4+
5+
#![feature(negative_impls)]
6+
7+
use std::marker::Send;
8+
9+
struct NoSend;
10+
impl !Send for NoSend {}
11+
12+
enum Container {
13+
WithNoSend(NoSend),
14+
}
15+
16+
fn requires_send<T: Send>(_: T) {}
17+
18+
fn main() {
19+
let container = Container::WithNoSend(NoSend);
20+
requires_send(container);
21+
//~^ ERROR `NoSend` cannot be sent between threads safely
22+
}

0 commit comments

Comments
 (0)