Cleaned up some tests

Split invalid-compile-flags into run-pass & invalid

Update tests/ui/README.md
This commit is contained in:
reddevilmidzy
2025-12-10 10:52:37 +09:00
parent 92f21a806d
commit 1bd997a452
98 changed files with 139 additions and 126 deletions
+14 -8
View File
@@ -256,6 +256,10 @@ Some traits' implementation must be compared with their definition, checking for
This subdirectory is *not* intended comparison traits (`PartialEq`, `Eq`, `PartialOrd`, `Ord`).
## `tests/ui/compile-flags/`
Tests for compile flags.
## `tests/ui/compiletest-self-test/`: compiletest "meta" tests
Meta test suite of the test harness `compiletest` itself.
@@ -548,6 +552,8 @@ A broad directory for tests on expressions.
Tests on the `extern` keyword and `extern` blocks and functions.
**FIXME**: Merge with `tests/ui/abi/extern`.
## `tests/ui/extern-flag/`: `--extern` command line flag
Tests for the `--extern` CLI flag.
@@ -556,6 +562,12 @@ Tests for the `--extern` CLI flag.
Tests on feature-gating, and the `#![feature(..)]` mechanism itself.
## `tests/ui/ffi/`: Foreign Function Interface
Tests for the `std::ffi` module.
See [`std::ffi`](https://doc.rust-lang.org/std/ffi/index.html)
## `tests/ui/ffi-attrs/`: `#![feature(ffi_const, ffi_pure)]`
The `#[ffi_const]` and `#[ffi_pure]` attributes applies clang's `const` and `pure` attributes to foreign functions declarations, respectively. These attributes are the core element of the tests in this category.
@@ -733,15 +745,9 @@ Various tests related to rejecting invalid inputs.
**FIXME**: This is rather uninformative, possibly rehome into more meaningful directories.
## `tests/ui/invalid-compile-flags/`
## `tests/ui/io-checks/`: Input Output
Tests for checking that invalid usage of compiler flags are rejected.
## `tests/ui/io-checks/`
Contains a single test. The test tries to output a file into an invalid directory with `-o`, then checks that the result is an error, not an internal compiler error.
**FIXME**: Rehome to invalid compiler flags maybe.
Tests for I/O related behaviour, covering stdout/stderr handling and error propagation.
## `tests/ui/issues/`: Tests directly related to GitHub issues
+2 -1
View File
@@ -1,6 +1,7 @@
//! regression test for issue https://github.com/rust-lang/rust/issues/46472
fn bar<'a>() -> &'a mut u32 {
&mut 4
//~^ ERROR cannot return reference to temporary value [E0515]
}
fn main() { }
fn main() {}
@@ -1,5 +1,5 @@
error[E0515]: cannot return reference to temporary value
--> $DIR/issue-46472.rs:2:5
--> $DIR/return-ref-to-temporary.rs:3:5
|
LL | &mut 4
| ^^^^^-
@@ -7,8 +7,9 @@
// reasonable examples) let to ambiguity errors about not being able
// to infer sufficient type information.
fn main() {
let n = 0;
let it = Some(1_usize).into_iter().inspect(|_| {n;});
let it = Some(1_usize).into_iter().inspect(|_| {
n;
});
}
+2 -1
View File
@@ -1,4 +1,5 @@
//! regression test for https://github.com/rust-lang/rust/issues/24779
//@ run-pass
fn main() {
assert_eq!((||||42)()(), 42);
assert_eq!((|| || 42)()(), 42);
}
@@ -1,3 +1,4 @@
//! regression test for https://github.com/rust-lang/rust/issues/24945
//@ run-pass
// This test is just checking that we continue to accept `-g -g -O -O`
// as options to the compiler.
+4 -1
View File
@@ -1,4 +1,7 @@
enum Foo { Bar }
//! regression test for https://github.com/rust-lang/rust/issues/23253
enum Foo {
Bar,
}
fn main() {
Foo::Bar.a;
+1 -1
View File
@@ -1,5 +1,5 @@
error[E0609]: no field `a` on type `Foo`
--> $DIR/issue-23253.rs:4:14
--> $DIR/enum-variant-no-field.rs:7:14
|
LL | Foo::Bar.a;
| ^ unknown field
@@ -1,3 +1,4 @@
//! regression test for issue https://github.com/rust-lang/rust/issues/50442
//@ run-pass
#![allow(dead_code)]
enum Void {}
@@ -5,7 +6,7 @@ enum Void {}
enum Foo {
A(i32),
B(Void),
C(i32)
C(i32),
}
fn main() {
+2 -1
View File
@@ -1,6 +1,7 @@
//! regression test for https://github.com/rust-lang/rust/issues/18110
//@ run-pass
#![allow(unreachable_code)]
fn main() {
({return},);
({ return },);
}
+1
View File
@@ -1,3 +1,4 @@
//! Regression test for https://github.com/rust-lang/rust/issues/19398
//@ check-pass
trait T {
+1
View File
@@ -1,3 +1,4 @@
//! regression test for https://github.com/rust-lang/rust/issues/11382
//@ run-pass
fn main() {
println!("{}", 1.2);
+3 -2
View File
@@ -1,5 +1,6 @@
//! regression test for https://github.com/rust-lang/rust/issues/43205
//@ run-pass
fn main() {
let _ = &&[()][0];
println!("{:?}", &[(),()][1]);
let _ = &&[()][0];
println!("{:?}", &[(), ()][1]);
}
-6
View File
@@ -1,6 +0,0 @@
mod MyMod {}
fn main() {
let myVar = MyMod { T: 0 };
//~^ ERROR expected struct, variant or union type, found module `MyMod`
}
-9
View File
@@ -1,9 +0,0 @@
error[E0574]: expected struct, variant or union type, found module `MyMod`
--> $DIR/issue-21449.rs:4:17
|
LL | let myVar = MyMod { T: 0 };
| ^^^^^ not a struct, variant or union type
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0574`.
-5
View File
@@ -1,5 +0,0 @@
mod module {}
fn main() {
let _ = module { x: 0 }; //~ERROR expected struct
}
-9
View File
@@ -1,9 +0,0 @@
error[E0574]: expected struct, variant or union type, found module `module`
--> $DIR/issue-23189.rs:4:13
|
LL | let _ = module { x: 0 };
| ^^^^^^ not a struct, variant or union type
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0574`.
@@ -1,5 +1,6 @@
// Test that regionck suggestions in a provided method of a trait
// don't ICE
//! regression test for https://github.com/rust-lang/rust/issues/17758
//! Test that regionck suggestions in a provided method of a trait
//! don't ICE
trait Foo<'a> {
fn foo(&'a self);
@@ -1,5 +1,5 @@
error: lifetime may not live long enough
--> $DIR/issue-17758.rs:7:9
--> $DIR/trait-method-lifetime-suggestion.rs:8:9
|
LL | trait Foo<'a> {
| -- lifetime `'a` defined here
@@ -0,0 +1,4 @@
// regression test for https://github.com/rust-lang/rust/issues/10656
#![deny(missing_docs)]
//~^ ERROR missing documentation for the crate
#![crate_type = "lib"]
@@ -1,12 +1,13 @@
error: missing documentation for the crate
--> $DIR/issue-10656.rs:1:1
--> $DIR/lint-missing-doc-crate-attr.rs:2:1
|
LL | / #![deny(missing_docs)]
LL | | #![crate_type="lib"]
| |____________________^
LL | |
LL | | #![crate_type = "lib"]
| |______________________^
|
note: the lint level is defined here
--> $DIR/issue-10656.rs:1:9
--> $DIR/lint-missing-doc-crate-attr.rs:2:9
|
LL | #![deny(missing_docs)]
| ^^^^^^^^^^^^
@@ -1,5 +1,5 @@
error: missing documentation for the crate
--> $DIR/lint-missing-doc-crate.rs:4:47
--> $DIR/lint-missing-doc-crate-flags.rs:4:47
|
LL |
| ^
@@ -1,3 +0,0 @@
#![deny(missing_docs)]
#![crate_type="lib"]
//~^^ ERROR missing documentation for the crate
@@ -1,3 +1,4 @@
//! regression test for https://github.com/rust-lang/rust/issues/19734
fn main() {}
struct Type;
@@ -1,5 +1,5 @@
error: cannot find macro `undef` in this scope
--> $DIR/issue-19734.rs:6:5
--> $DIR/undefined-macro-in-impl.rs:7:5
|
LL | undef!();
| ^^^^^
@@ -1,12 +1,13 @@
// Regression test for issue #4968
//! Regression test for issue https://github.com/rust-lang/rust/issues/4968
//@ dont-require-annotations: NOTE
const A: (isize,isize) = (4,2);
const A: (isize, isize) = (4, 2);
fn main() {
match 42 { A => () }
//~^ ERROR mismatched types
//~| NOTE expected type `{integer}`
//~| NOTE found tuple `(isize, isize)`
//~| NOTE expected integer, found `(isize, isize)`
match 42 {
A => (),
//~^ ERROR mismatched types
//~| NOTE expected type `{integer}`
//~| NOTE found tuple `(isize, isize)`
//~| NOTE expected integer, found `(isize, isize)`
}
}
@@ -1,16 +1,17 @@
error[E0308]: mismatched types
--> $DIR/issue-4968.rs:7:16
--> $DIR/match-const-tuple-type-mismatch.rs:7:9
|
LL | const A: (isize,isize) = (4,2);
| ---------------------- constant defined here
LL | const A: (isize, isize) = (4, 2);
| ----------------------- constant defined here
LL | fn main() {
LL | match 42 { A => () }
| -- ^
| | |
| | expected integer, found `(isize, isize)`
| | `A` is interpreted as a constant, not a new binding
| | help: introduce a new binding instead: `other_a`
| this expression has type `{integer}`
LL | match 42 {
| -- this expression has type `{integer}`
LL | A => (),
| ^
| |
| expected integer, found `(isize, isize)`
| `A` is interpreted as a constant, not a new binding
| help: introduce a new binding instead: `other_a`
|
= note: expected type `{integer}`
found tuple `(isize, isize)`
+2 -1
View File
@@ -1,3 +1,4 @@
//! Regression test for https://github.com/rust-lang/rust/issues/18464
//@ run-pass
#![deny(dead_code)]
@@ -7,6 +8,6 @@
fn main() {
match '5' {
LOW_RANGE..=HIGH_RANGE => (),
_ => ()
_ => (),
};
}
+3 -2
View File
@@ -1,9 +1,10 @@
//! regression test for issue https://github.com/rust-lang/rust/issues/17933
pub static X: usize = 1;
fn main() {
match 1 {
self::X => { },
self::X => {}
//~^ ERROR expected unit struct, unit variant or constant, found static `self::X`
_ => { },
_ => {}
}
}
+2 -2
View File
@@ -1,7 +1,7 @@
error[E0532]: expected unit struct, unit variant or constant, found static `self::X`
--> $DIR/issue-17933.rs:5:9
--> $DIR/match-static-pattern.rs:6:9
|
LL | self::X => { },
LL | self::X => {}
| ^^^^^^^ not a unit struct, unit variant or constant
error: aborting due to 1 previous error
+1
View File
@@ -1,3 +1,4 @@
//! regression test for issue https://github.com/rust-lang/rust/issues/16783
//@ run-pass
#![allow(unused_variables)]
+1
View File
@@ -1,3 +1,4 @@
//! regression test for https://github.com/rust-lang/rust/issues/17373
fn main() {
*return //~ ERROR type `!` cannot be dereferenced
;
+1 -1
View File
@@ -1,5 +1,5 @@
error[E0614]: type `!` cannot be dereferenced
--> $DIR/issue-17373.rs:2:5
--> $DIR/never-deref.rs:3:5
|
LL | *return
| ^^^^^^^ can't be dereferenced
@@ -1,3 +1,5 @@
//! regression test for https://github.com/rust-lang/rust/issues/22644
fn main() {
let a: usize = 0;
let long_name: usize = 0;
@@ -1,5 +1,5 @@
error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
--> $DIR/issue-22644.rs:6:31
--> $DIR/cast-angle-bracket-precedence.rs:8:31
|
LL | println!("{}", a as usize < long_name);
| ^ --------- interpreted as generic arguments
@@ -12,7 +12,7 @@ LL | println!("{}", (a as usize) < long_name);
| + +
error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
--> $DIR/issue-22644.rs:7:33
--> $DIR/cast-angle-bracket-precedence.rs:9:33
|
LL | println!("{}{}", a as usize < long_name, long_name);
| ^ -------------------- interpreted as generic arguments
@@ -25,7 +25,7 @@ LL | println!("{}{}", (a as usize) < long_name, long_name);
| + +
error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
--> $DIR/issue-22644.rs:9:31
--> $DIR/cast-angle-bracket-precedence.rs:11:31
|
LL | println!("{}", a as usize < 4);
| ^ - interpreted as generic arguments
@@ -38,7 +38,7 @@ LL | println!("{}", (a as usize) < 4);
| + +
error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
--> $DIR/issue-22644.rs:14:20
--> $DIR/cast-angle-bracket-precedence.rs:16:20
|
LL | <
| ^ not interpreted as comparison
@@ -53,7 +53,7 @@ LL ~ usize)
|
error: `<` is interpreted as a start of generic arguments for `usize`, not a comparison
--> $DIR/issue-22644.rs:23:20
--> $DIR/cast-angle-bracket-precedence.rs:25:20
|
LL | <
| ^ not interpreted as comparison
@@ -70,7 +70,7 @@ LL ~ usize)
|
error: `<<` is interpreted as a start of generic arguments for `usize`, not a shift
--> $DIR/issue-22644.rs:26:31
--> $DIR/cast-angle-bracket-precedence.rs:28:31
|
LL | println!("{}", a as usize << long_name);
| ^^ --------- interpreted as generic arguments
@@ -1,10 +1,12 @@
//! regression test for https://github.com/rust-lang/rust/issues/27033
fn main() {
match Some(1) {
None @ _ => {} //~ ERROR match bindings cannot shadow unit variants
};
const C: u8 = 1;
match 1 {
C @ 2 => { //~ ERROR match bindings cannot shadow constant
C @ 2 => {
//~^ ERROR match bindings cannot shadow constant
println!("{}", C);
}
_ => {}
@@ -1,5 +1,5 @@
error[E0530]: match bindings cannot shadow unit variants
--> $DIR/issue-27033.rs:3:9
--> $DIR/match-at-pattern-shadows-name.rs:4:9
|
LL | None @ _ => {}
| ^^^^ cannot be named the same as a unit variant
@@ -9,7 +9,7 @@ LL | None @ _ => {}
= note: the unit variant `None` is defined here
error[E0530]: match bindings cannot shadow constants
--> $DIR/issue-27033.rs:7:9
--> $DIR/match-at-pattern-shadows-name.rs:8:9
|
LL | const C: u8 = 1;
| ---------------- the constant `C` is defined here
@@ -1,3 +1,4 @@
//! regression test for https://github.com/rust-lang/rust/issues/17001, https://github.com/rust-lang/rust/issues/21449, https://github.com/rust-lang/rust/issues/23189
mod foo {}
fn main() {
@@ -1,5 +1,5 @@
error[E0574]: expected struct, variant or union type, found module `foo`
--> $DIR/issue-17001.rs:4:13
--> $DIR/module-used-as-struct-constructor.rs:5:13
|
LL | let p = foo { x: () };
| ^^^ not a struct, variant or union type
@@ -1,3 +1,4 @@
//! regression test for https://github.com/rust-lang/rust/issues/34047
const C: u8 = 0;
fn main() {
@@ -1,5 +1,5 @@
error[E0530]: match bindings cannot shadow constants
--> $DIR/issue-34047.rs:5:13
--> $DIR/match-binding-shadows-const.rs:6:13
|
LL | const C: u8 = 0;
| ---------------- the constant `C` is defined here
+4 -3
View File
@@ -1,7 +1,8 @@
//! regression test for https://github.com/rust-lang/rust/issues/17450
//@ build-pass
#![allow(dead_code, warnings)]
#![allow(dead_code)]
static mut x: isize = 3;
static mut y: isize = unsafe { x };
static mut X: isize = 3;
static mut Y: isize = unsafe { X };
fn main() {}
@@ -1,8 +1,7 @@
//! Regression test for unwrapping the result of `join`, issue https://github.com/rust-lang/rust/issues/21291
//@ run-pass
//@ needs-threads
// Regression test for unwrapping the result of `join`, issue #21291
use std::thread;
fn main() {
@@ -1,4 +1,7 @@
struct X { x: i32 }
//! regression test for issue https://github.com/rust-lang/rust/issues/20162
struct X {
x: i32,
}
fn main() {
let mut b: Vec<X> = vec![];
@@ -1,5 +1,5 @@
error[E0277]: the trait bound `X: Ord` is not satisfied
--> $DIR/issue-20162.rs:5:7
--> $DIR/sort-missing-ord-bound.rs:8:7
|
LL | b.sort();
| ^^^^ the trait `Ord` is not implemented for `X`
@@ -9,7 +9,7 @@ note: required by a bound in `slice::<impl [T]>::sort`
help: consider annotating `X` with `#[derive(Ord)]`
|
LL + #[derive(Ord)]
LL | struct X { x: i32 }
LL | struct X {
|
error: aborting due to 1 previous error
@@ -1,9 +1,10 @@
//! regression test for https://github.com/rust-lang/rust/issues/21177
trait Trait {
type A;
type B;
}
fn foo<T: Trait<A = T::B>>() { }
fn foo<T: Trait<A = T::B>>() {}
//~^ ERROR cycle detected
fn main() { }
fn main() {}
@@ -1,14 +1,14 @@
error[E0391]: cycle detected when computing the bounds for type parameter `T`
--> $DIR/issue-21177.rs:6:21
--> $DIR/assoc-equality-cycle.rs:7:21
|
LL | fn foo<T: Trait<A = T::B>>() { }
LL | fn foo<T: Trait<A = T::B>>() {}
| ^^^^
|
= note: ...which immediately requires computing the bounds for type parameter `T` again
note: cycle used when computing explicit predicates of `foo`
--> $DIR/issue-21177.rs:6:21
--> $DIR/assoc-equality-cycle.rs:7:21
|
LL | fn foo<T: Trait<A = T::B>>() { }
LL | fn foo<T: Trait<A = T::B>>() {}
| ^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
@@ -1,5 +1,6 @@
trait T : Iterator<Item=Self::Item>
//~^ ERROR cycle detected
{}
//! regression test for https://github.com/rust-lang/rust/issues/20772
trait T: Iterator<Item = Self::Item> //~ ERROR cycle detected
{
}
fn main() {}
@@ -1,15 +1,15 @@
error[E0391]: cycle detected when computing the super traits of `T` with associated type name `Item`
--> $DIR/issue-20772.rs:1:1
--> $DIR/self-item-cycle.rs:2:1
|
LL | trait T : Iterator<Item=Self::Item>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | trait T: Iterator<Item = Self::Item>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: ...which immediately requires computing the super traits of `T` with associated type name `Item` again
note: cycle used when computing the super predicates of `T`
--> $DIR/issue-20772.rs:1:1
--> $DIR/self-item-cycle.rs:2:1
|
LL | trait T : Iterator<Item=Self::Item>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL | trait T: Iterator<Item = Self::Item>
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
error: aborting due to 1 previous error
@@ -1,3 +1,4 @@
//! Regression test for https://github.com/rust-lang/rust/issues/18159
fn main() {
let x; //~ ERROR type annotations needed
}
@@ -1,5 +1,5 @@
error[E0282]: type annotations needed
--> $DIR/issue-18159.rs:2:9
--> $DIR/missing-type-annotation.rs:3:9
|
LL | let x;
| ^
+1
View File
@@ -1,3 +1,4 @@
//! regression test for https://github.com/rust-lang/rust/issues/49854
//@ run-pass
use std::ffi::OsString;
@@ -1,7 +1,8 @@
// Test that overloaded call parameter checking does not ICE
// when a type error or unconstrained type variable propagates
// into it.
//! regression test for issue https://github.com/rust-lang/rust/issues/18532
//! Test that overloaded call parameter checking does not ICE
//! when a type error or unconstrained type variable propagates
//! into it.
fn main() {
(return)((),()); //~ ERROR expected function, found `!`
(return)((), ()); //~ ERROR expected function, found `!`
}
@@ -1,8 +1,8 @@
error[E0618]: expected function, found `!`
--> $DIR/issue-18532.rs:6:5
--> $DIR/return-expression-invalid-callee.rs:7:5
|
LL | (return)((),());
| ^^^^^^^^-------
LL | (return)((), ());
| ^^^^^^^^--------
| |
| call expression requires function