Skip to content

tests/ui: A New Order [9/N] #142214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
//! Test that empty allocations produce non-null pointers
//!
//! This test ensures that Rust's allocator maintains the invariant that
//! Box<T> is always non-null, even for zero-sized types and empty allocations.
//! This is crucial for memory safety guarantees in Rust.

//@ run-pass

pub fn main() {
Expand Down
8 changes: 0 additions & 8 deletions tests/ui/diverging-fn-tail-35849.rs

This file was deleted.

10 changes: 0 additions & 10 deletions tests/ui/early-ret-binop-add.rs

This file was deleted.

18 changes: 0 additions & 18 deletions tests/ui/elide-errors-on-mismatched-tuple.rs

This file was deleted.

5 changes: 0 additions & 5 deletions tests/ui/elided-test.rs

This file was deleted.

9 changes: 0 additions & 9 deletions tests/ui/elided-test.stderr

This file was deleted.

20 changes: 0 additions & 20 deletions tests/ui/else-if.rs

This file was deleted.

19 changes: 19 additions & 0 deletions tests/ui/expr/early-return-in-binop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//! Test early return within binary operation expressions

//@ run-pass

#![allow(dead_code)]
#![allow(unreachable_code)]

use std::ops::Add;

/// Function that performs addition with an early return in the right operand
fn add_with_early_return<T: Add<Output = T> + Copy>(n: T) -> T {
n + { return n }
}

pub fn main() {
// Test with different numeric types to ensure generic behavior works
let _result1 = add_with_early_return(42i32);
let _result2 = add_with_early_return(3.14f64);
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Test that duplicate use bindings in same namespace produce error

mod foo {
pub use self::bar::X;
use self::bar::X;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0252]: the name `X` is defined multiple times
--> $DIR/double-type-import.rs:3:9
--> $DIR/duplicate-use-bindings.rs:5:9
|
LL | pub use self::bar::X;
| ------------ previous import of the type `X` here
Expand Down
25 changes: 25 additions & 0 deletions tests/ui/mismatched_types/elide-on-tuple-mismatch.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! Regression test for issue #50333: elide irrelevant E0277 errors on tuple mismatch

// Hide irrelevant E0277 errors (#50333)

trait T {}

struct A;

impl T for A {}

impl A {
fn new() -> Self {
Self {}
}
}

fn main() {
// This creates a tuple type mismatch: 2-element tuple destructured into 3 variables
let (a, b, c) = (A::new(), A::new());
//~^ ERROR mismatched types

// This line should NOT produce an E0277 error about `Sized` trait bounds,
// because `a`, `b`, and `c` are `TyErr` due to the mismatch above
let _ts: Vec<&dyn T> = vec![&a, &b, &c];
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error[E0308]: mismatched types
--> $DIR/elide-errors-on-mismatched-tuple.rs:14:9
--> $DIR/elide-on-tuple-mismatch.rs:19:9
|
LL | let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
LL | let (a, b, c) = (A::new(), A::new());
| ^^^^^^^^^ -------------------- this expression has type `(A, A)`
| |
| expected a tuple with 2 elements, found one with 3 elements
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
//! Test parsing of multiple references with various whitespace arrangements

//@ run-pass

#![allow(dead_code)]
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/test-attrs/test-function-elided-no-main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//! Test that #[test] functions are elided when not running tests, causing missing main error

#[test]
fn main() {
// This function would normally serve as main, but since it's marked with #[test],
// it gets elided when not running tests
}
//~^ ERROR `main` function not found in crate `test_function_elided_no_main`
9 changes: 9 additions & 0 deletions tests/ui/test-attrs/test-function-elided-no-main.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
error[E0601]: `main` function not found in crate `test_function_elided_no_main`
--> $DIR/test-function-elided-no-main.rs:7:2
|
LL | }
| ^ consider adding a `main` function to `$DIR/test-function-elided-no-main.rs`

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0601`.
10 changes: 10 additions & 0 deletions tests/ui/transmute/diverging-fn-transmute.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//! Regression test for issue #35849: transmute with panic in diverging function

fn assert_sizeof() -> ! {
unsafe {
::std::mem::transmute::<f64, [u8; 8]>(panic!())
//~^ ERROR mismatched types
}
}

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/diverging-fn-tail-35849.rs:3:9
--> $DIR/diverging-fn-transmute.rs:5:9
|
LL | fn assert_sizeof() -> ! {
| - expected `!` because of return type
Expand Down
Loading