tidy never type issue-* tests

This commit is contained in:
Waffle Lapkin
2025-11-14 00:24:27 +01:00
parent eef3c4db7b
commit 05174fbcc5
14 changed files with 36 additions and 98 deletions
-8
View File
@@ -1726,14 +1726,6 @@ ui/moves/issue-46099-move-in-macro.rs
ui/moves/issue-72649-uninit-in-loop.rs
ui/moves/issue-75904-move-closure-loop.rs
ui/moves/issue-99470-move-out-of-some.rs
ui/never_type/issue-10176.rs
ui/never_type/issue-13352.rs
ui/never_type/issue-2149.rs
ui/never_type/issue-44402.rs
ui/never_type/issue-51506.rs
ui/never_type/issue-52443.rs
ui/never_type/issue-5500-1.rs
ui/never_type/issue-96335.rs
ui/nll/closure-requirements/issue-58127-mutliple-requirements.rs
ui/nll/issue-112604-closure-output-normalize.rs
ui/nll/issue-16223.rs
@@ -1,8 +1,7 @@
// Regression test for <https://github.com/rust-lang/rust/issues/5500>,
// check that you can take a reference to the never type.
//
//@ edition:2015..2021
// MIR doesn't generate an error because the assignment isn't reachable. This
// is OK because the test is here to check that the compiler doesn't ICE (cf.
// #5500).
//@ check-pass
struct TrieMapIterator<'a> {
@@ -1,5 +1,5 @@
error[E0308]: mismatched types
--> $DIR/diverging-tuple-parts-39485.rs:9:5
--> $DIR/divergent-block-with-tail.rs:12:5
|
LL | &panic!()
| ^^^^^^^^^ expected `()`, found `&_`
@@ -17,7 +17,7 @@ LL + panic!()
|
error[E0308]: mismatched types
--> $DIR/diverging-tuple-parts-39485.rs:13:5
--> $DIR/divergent-block-with-tail.rs:17:5
|
LL | fn f() -> isize {
| ----- expected `isize` because of return type
@@ -1,9 +0,0 @@
fn foo(_: Box<dyn FnMut()>) {}
fn main() {
foo(loop {
std::process::exit(0);
});
2_usize + (loop {});
//~^ ERROR E0277
}
@@ -1,28 +0,0 @@
error[E0277]: cannot add `()` to `usize`
--> $DIR/issue-13352.rs:7:13
|
LL | 2_usize + (loop {});
| ^ no implementation for `usize + ()`
|
= help: the trait `Add<()>` is not implemented for `usize`
help: the following other types implement trait `Add<Rhs>`
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
|
= note: `usize` implements `Add`
::: $SRC_DIR/core/src/ops/arith.rs:LL:COL
|
= note: in this macro invocation
--> $SRC_DIR/core/src/internal_macros.rs:LL:COL
|
= note: `&usize` implements `Add<usize>`
::: $SRC_DIR/core/src/internal_macros.rs:LL:COL
|
= note: `usize` implements `Add<&usize>`
::: $SRC_DIR/core/src/internal_macros.rs:LL:COL
|
= note: `&usize` implements `Add`
= note: this error originates in the macro `add_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0277`.
@@ -1,34 +0,0 @@
// Regression test for <https://github.com/rust-lang/rust/issues/44402>
//
// Previously inhabitedness check was handling cycles incorrectly causing this
// to not compile.
//
//@ check-pass
#![allow(dead_code)]
#![feature(never_type)]
#![feature(exhaustive_patterns)]
struct Foo {
field1: !,
field2: Option<&'static Bar>,
}
struct Bar {
field1: &'static Foo
}
fn test_a() {
let x: Option<Foo> = None;
match x { None => () }
}
fn test_b() {
let x: Option<Bar> = None;
match x {
Some(_) => (),
None => ()
}
}
fn main() {}
@@ -1,3 +1,5 @@
// Regression test for <https://github.com/rust-lang/rust/issues/52443>
fn main() {
[(); & { loop { continue } } ]; //~ ERROR mismatched types
@@ -1,5 +1,5 @@
warning: denote infinite loops with `loop { ... }`
--> $DIR/issue-52443.rs:6:11
--> $DIR/loop-in-array-length.rs:8:11
|
LL | [(); {while true {break}; 0}];
| ^^^^^^^^^^ help: use `loop`
@@ -7,7 +7,7 @@ LL | [(); {while true {break}; 0}];
= note: `#[warn(while_true)]` on by default
error[E0308]: mismatched types
--> $DIR/issue-52443.rs:2:10
--> $DIR/loop-in-array-length.rs:4:10
|
LL | [(); & { loop { continue } } ];
| ^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `&_`
@@ -21,7 +21,7 @@ LL + [(); { loop { continue } } ];
|
error[E0308]: mismatched types
--> $DIR/issue-52443.rs:4:17
--> $DIR/loop-in-array-length.rs:6:17
|
LL | [(); loop { break }];
| ^^^^^ expected `usize`, found `()`
@@ -32,7 +32,7 @@ LL | [(); loop { break 42 }];
| ++
error[E0277]: the trait bound `std::ops::RangeFrom<usize>: const Iterator` is not satisfied
--> $DIR/issue-52443.rs:9:21
--> $DIR/loop-in-array-length.rs:11:21
|
LL | [(); { for _ in 0usize.. {}; 0}];
| ^^^^^^^^ required by a bound introduced by this call
@@ -42,7 +42,7 @@ note: trait `Iterator` is implemented but not `const`
= note: required for `std::ops::RangeFrom<usize>` to implement `const IntoIterator`
error[E0277]: the trait bound `std::ops::RangeFrom<usize>: const Iterator` is not satisfied
--> $DIR/issue-52443.rs:9:21
--> $DIR/loop-in-array-length.rs:11:21
|
LL | [(); { for _ in 0usize.. {}; 0}];
| ^^^^^^^^
@@ -1,3 +1,5 @@
// Regression test for <https://github.com/rust-lang/rust/issues/96335>
fn main() {
0.....{loop{}1};
//~^ ERROR unexpected token
@@ -1,5 +1,5 @@
error: unexpected token: `...`
--> $DIR/issue-96335.rs:2:6
--> $DIR/malformed-range-to-never.rs:4:6
|
LL | 0.....{loop{}1};
| ^^^
@@ -16,7 +16,7 @@ LL + 0..=..{loop{}1};
|
error[E0308]: mismatched types
--> $DIR/issue-96335.rs:2:9
--> $DIR/malformed-range-to-never.rs:4:9
|
LL | 0.....{loop{}1};
| ----^^^^^^^^^^^
@@ -0,0 +1,13 @@
// Regression test for <https://github.com/rust-lang/rust/issues/13352>,
// check that the never type can be used as a function argument.
//
//@run-pass
fn foo(_: Box<dyn FnMut()>) {}
fn main() {
#[expect(unreachable_code)]
foo(loop {
std::process::exit(0);
});
}
@@ -1,12 +1,12 @@
error[E0277]: `!` is not an iterator
--> $DIR/issue-51506.rs:15:24
--> $DIR/never-as-spec-default-associated-type.rs:15:24
|
LL | default type Out = !;
| ^ `!` is not an iterator
|
= help: the trait `Iterator` is not implemented for `!`
note: required by a bound in `Trait::Out`
--> $DIR/issue-51506.rs:9:15
--> $DIR/never-as-spec-default-associated-type.rs:9:15
|
LL | type Out: Iterator<Item = u32>;
| ^^^^^^^^^^^^^^^^^^^^ required by this bound in `Trait::Out`
@@ -1,12 +1,13 @@
// Tests that `return` without a semicolon parses correctly in a match arm.
// See <https://github.com/rust-lang/rust/issues/521>
//
//@ run-pass
//@ check-pass
fn f() {
fn _f() {
#[rustfmt::skip]
let _x = match true {
true => { 10 }
false => { return }
true => { 10 },
false => { return },
};
}