Skip to content

Commit 15b227f

Browse files
Rollup merge of #142214 - Kivooeo:tf9, r=jieyouxu
`tests/ui`: A New Order [9/N] Some `tests/ui/` housekeeping, to trim down number of tests directly under `tests/ui/`. Part of #133895.
2 parents 66ad1f2 + f4502b8 commit 15b227f

17 files changed

+83
-74
lines changed

tests/ui/empty-allocation-non-null.rs renamed to tests/ui/allocator/empty-alloc-nonnull-guarantee.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! Check that the default global Rust allocator produces non-null Box allocations for ZSTs.
2+
//!
3+
//! See https://github.com/rust-lang/rust/issues/11998
4+
15
//@ run-pass
26

37
pub fn main() {

tests/ui/diverging-fn-tail-35849.rs

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

tests/ui/early-ret-binop-add.rs

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

tests/ui/elide-errors-on-mismatched-tuple.rs

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

tests/ui/elided-test.rs

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

tests/ui/elided-test.stderr

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

tests/ui/else-if.rs

Lines changed: 0 additions & 20 deletions
This file was deleted.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//! Test early return within binary operation expressions
2+
3+
//@ run-pass
4+
5+
#![allow(dead_code)]
6+
#![allow(unreachable_code)]
7+
8+
use std::ops::Add;
9+
10+
/// Function that performs addition with an early return in the right operand
11+
fn add_with_early_return<T: Add<Output = T> + Copy>(n: T) -> T {
12+
n + { return n }
13+
}
14+
15+
pub fn main() {
16+
// Test with different numeric types to ensure generic behavior works
17+
let _result1 = add_with_early_return(42i32);
18+
let _result2 = add_with_early_return(3.14f64);
19+
}

tests/ui/double-type-import.rs renamed to tests/ui/imports/duplicate-use-bindings.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Test that duplicate use bindings in same namespace produce error
2+
13
mod foo {
24
pub use self::bar::X;
35
use self::bar::X;

tests/ui/double-type-import.stderr renamed to tests/ui/imports/duplicate-use-bindings.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0252]: the name `X` is defined multiple times
2-
--> $DIR/double-type-import.rs:3:9
2+
--> $DIR/duplicate-use-bindings.rs:5:9
33
|
44
LL | pub use self::bar::X;
55
| ------------ previous import of the type `X` here
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//! Regression test for issue #50333: elide irrelevant E0277 errors on tuple mismatch
2+
3+
// Hide irrelevant E0277 errors (#50333)
4+
5+
trait T {}
6+
7+
struct A;
8+
9+
impl T for A {}
10+
11+
impl A {
12+
fn new() -> Self {
13+
Self {}
14+
}
15+
}
16+
17+
fn main() {
18+
// This creates a tuple type mismatch: 2-element tuple destructured into 3 variables
19+
let (a, b, c) = (A::new(), A::new());
20+
//~^ ERROR mismatched types
21+
22+
// This line should NOT produce an E0277 error about `Sized` trait bounds,
23+
// because `a`, `b`, and `c` are `TyErr` due to the mismatch above
24+
let _ts: Vec<&dyn T> = vec![&a, &b, &c];
25+
}

tests/ui/elide-errors-on-mismatched-tuple.stderr renamed to tests/ui/mismatched_types/elide-on-tuple-mismatch.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
error[E0308]: mismatched types
2-
--> $DIR/elide-errors-on-mismatched-tuple.rs:14:9
2+
--> $DIR/elide-on-tuple-mismatch.rs:19:9
33
|
4-
LL | let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
4+
LL | let (a, b, c) = (A::new(), A::new());
55
| ^^^^^^^^^ -------------------- this expression has type `(A, A)`
66
| |
77
| expected a tuple with 2 elements, found one with 3 elements

tests/ui/double-ref.rs renamed to tests/ui/parser/reference-whitespace-parsing.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Test parsing of multiple references with various whitespace arrangements
2+
13
//@ run-pass
24

35
#![allow(dead_code)]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//! Test that #[test] functions are elided when not running tests, causing missing main error
2+
3+
#[test]
4+
fn main() {
5+
// This function would normally serve as main, but since it's marked with #[test],
6+
// it gets elided when not running tests
7+
}
8+
//~^ ERROR `main` function not found in crate `test_function_elided_no_main`
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
error[E0601]: `main` function not found in crate `test_function_elided_no_main`
2+
--> $DIR/test-function-elided-no-main.rs:7:2
3+
|
4+
LL | }
5+
| ^ consider adding a `main` function to `$DIR/test-function-elided-no-main.rs`
6+
7+
error: aborting due to 1 previous error
8+
9+
For more information about this error, try `rustc --explain E0601`.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
//! Regression test for issue #35849: transmute with panic in diverging function
2+
3+
fn assert_sizeof() -> ! {
4+
unsafe {
5+
::std::mem::transmute::<f64, [u8; 8]>(panic!())
6+
//~^ ERROR mismatched types
7+
}
8+
}
9+
10+
fn main() {}

tests/ui/diverging-fn-tail-35849.stderr renamed to tests/ui/transmute/diverging-fn-transmute.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0308]: mismatched types
2-
--> $DIR/diverging-fn-tail-35849.rs:3:9
2+
--> $DIR/diverging-fn-transmute.rs:5:9
33
|
44
LL | fn assert_sizeof() -> ! {
55
| - expected `!` because of return type

0 commit comments

Comments
 (0)