cleaned up some tests
This commit is contained in:
parent
8072811356
commit
f4502b8f0e
17 changed files with 83 additions and 74 deletions
|
|
@ -1,3 +1,7 @@
|
|||
//! Check that the default global Rust allocator produces non-null Box allocations for ZSTs.
|
||||
//!
|
||||
//! See https://github.com/rust-lang/rust/issues/11998
|
||||
|
||||
//@ run-pass
|
||||
|
||||
pub fn main() {
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
fn assert_sizeof() -> ! {
|
||||
unsafe {
|
||||
::std::mem::transmute::<f64, [u8; 8]>(panic!())
|
||||
//~^ ERROR mismatched types
|
||||
}
|
||||
}
|
||||
|
||||
fn main() { }
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
#![allow(unreachable_code)]
|
||||
|
||||
use std::ops::Add;
|
||||
|
||||
fn wsucc<T:Add<Output=T> + Copy>(n: T) -> T { n + { return n } }
|
||||
|
||||
pub fn main() { }
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
// Hide irrelevant E0277 errors (#50333)
|
||||
|
||||
trait T {}
|
||||
|
||||
struct A;
|
||||
impl T for A {}
|
||||
impl A {
|
||||
fn new() -> Self {
|
||||
Self {}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three
|
||||
//~^ ERROR mismatched types
|
||||
let ts: Vec<&dyn T> = vec![&a, &b, &c];
|
||||
// There is no E0277 error above, as `a`, `b` and `c` are `TyErr`
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
// Since we're not compiling a test runner this function should be elided
|
||||
// and the build will fail because main doesn't exist
|
||||
#[test]
|
||||
fn main() {
|
||||
} //~ ERROR `main` function not found in crate `elided_test`
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
error[E0601]: `main` function not found in crate `elided_test`
|
||||
--> $DIR/elided-test.rs:5:2
|
||||
|
|
||||
LL | }
|
||||
| ^ consider adding a `main` function to `$DIR/elided-test.rs`
|
||||
|
||||
error: aborting due to 1 previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0601`.
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
//@ run-pass
|
||||
|
||||
pub fn main() {
|
||||
if 1 == 2 {
|
||||
assert!((false));
|
||||
} else if 2 == 3 {
|
||||
assert!((false));
|
||||
} else if 3 == 4 { assert!((false)); } else { assert!((true)); }
|
||||
if 1 == 2 { assert!((false)); } else if 2 == 2 { assert!((true)); }
|
||||
if 1 == 2 {
|
||||
assert!((false));
|
||||
} else if 2 == 2 {
|
||||
if 1 == 1 {
|
||||
assert!((true));
|
||||
} else { if 2 == 1 { assert!((false)); } else { assert!((false)); } }
|
||||
}
|
||||
if 1 == 2 {
|
||||
assert!((false));
|
||||
} else { if 1 == 2 { assert!((false)); } else { assert!((true)); } }
|
||||
}
|
||||
19
tests/ui/expr/early-return-in-binop.rs
Normal file
19
tests/ui/expr/early-return-in-binop.rs
Normal file
|
|
@ -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);
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
@ -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
|
||||
25
tests/ui/mismatched_types/elide-on-tuple-mismatch.rs
Normal file
25
tests/ui/mismatched_types/elide-on-tuple-mismatch.rs
Normal file
|
|
@ -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];
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
//! Test parsing of multiple references with various whitespace arrangements
|
||||
|
||||
//@ run-pass
|
||||
|
||||
#![allow(dead_code)]
|
||||
8
tests/ui/test-attrs/test-function-elided-no-main.rs
Normal file
8
tests/ui/test-attrs/test-function-elided-no-main.rs
Normal file
|
|
@ -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
tests/ui/test-attrs/test-function-elided-no-main.stderr
Normal file
9
tests/ui/test-attrs/test-function-elided-no-main.stderr
Normal file
|
|
@ -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
tests/ui/transmute/diverging-fn-transmute.rs
Normal file
10
tests/ui/transmute/diverging-fn-transmute.rs
Normal file
|
|
@ -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() {}
|
||||
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue