move never type tests to subdirectories and add some comments

This commit is contained in:
Waffle Lapkin
2025-11-14 00:24:27 +01:00
parent 1b7d722f42
commit eef3c4db7b
88 changed files with 35 additions and 95 deletions
@@ -1,16 +0,0 @@
//@ edition:2015..2021
// After #39485, this test used to pass, but that change was reverted
// due to numerous inference failures like #39808, so it now fails
// again. #39485 made it so that diverging types never propagate
// upward; but we now do propagate such types upward in many more
// cases.
fn g() {
&panic!() //~ ERROR mismatched types
}
fn f() -> isize {
(return 1, return 2) //~ ERROR mismatched types
}
fn main() {}
-14
View File
@@ -1,14 +0,0 @@
//@ run-pass
#![allow(dead_code)]
// Issue #521
fn f() {
let _x = match true {
true => { 10 }
false => { return }
};
}
pub fn main() { }
@@ -2,7 +2,7 @@
//
// This is a *minimization* of the issue.
// Note that the original version with the `?` does not fail anymore even with fallback to unit,
// see `tests/ui/never_type/question_mark_from_never.rs`.
// see `tests/ui/never_type/fallback_change/question_mark_from_never.rs`.
//
//@ revisions: unit never
//@[never] check-pass
@@ -1,6 +1,6 @@
// Regression test for <https://github.com/rust-lang/rust/issues/66757>.
//
// See also: `tests/ui/never_type/from_infer_breaking_with_unit_fallback.rs`.
// See also: `tests/ui/never_type/fallback_change/from_infer_breaking_with_unit_fallback.rs`.
//
//@ revisions: unit never
//@ check-pass
-9
View File
@@ -1,9 +0,0 @@
fn f() -> isize { //~ NOTE expected `isize` because of return type
(return 1, return 2)
//~^ ERROR mismatched types
//~| NOTE expected type `isize`
//~| NOTE found tuple `(!, !)`
//~| NOTE expected `isize`, found `(!, !)`
}
fn main() {}
-14
View File
@@ -1,14 +0,0 @@
error[E0308]: mismatched types
--> $DIR/issue-10176.rs:2:5
|
LL | fn f() -> isize {
| ----- expected `isize` because of return type
LL | (return 1, return 2)
| ^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `(!, !)`
|
= note: expected type `isize`
found tuple `(!, !)`
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0308`.
-15
View File
@@ -1,15 +0,0 @@
trait VecMonad<A> {
fn bind<B, F>(&self, f: F) where F: FnMut(A) -> Vec<B>;
}
impl<A> VecMonad<A> for Vec<A> {
fn bind<B, F>(&self, mut f: F) where F: FnMut(A) -> Vec<B> {
let mut r = panic!();
for elt in self { r = r + f(*elt); }
//~^ ERROR E0277
}
}
fn main() {
["hi"].bind(|x| [x] );
//~^ ERROR no method named `bind` found
}
-25
View File
@@ -1,25 +0,0 @@
error[E0277]: cannot add `Vec<B>` to `()`
--> $DIR/issue-2149.rs:8:33
|
LL | for elt in self { r = r + f(*elt); }
| ^ no implementation for `() + Vec<B>`
|
= help: the trait `Add<Vec<B>>` is not implemented for `()`
error[E0599]: no method named `bind` found for array `[&str; 1]` in the current scope
--> $DIR/issue-2149.rs:13:12
|
LL | ["hi"].bind(|x| [x] );
| ^^^^ method not found in `[&str; 1]`
|
= help: items from traits can only be used if the trait is implemented and in scope
note: `VecMonad` defines an item `bind`, perhaps you need to implement it
--> $DIR/issue-2149.rs:1:1
|
LL | trait VecMonad<A> {
| ^^^^^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Some errors have detailed explanations: E0277, E0599.
For more information about an error, try `rustc --explain E0277`.
@@ -0,0 +1,20 @@
// Rust briefly used to allow blocks with divergent statements to type check as `!`, even if they
// had a tail expression. This led to a number of regressions (because type information no longer
// flowed from the tail expression) and was quickly reverted.i
//
// See <https://github.com/rust-lang/rust/pull/39485>,
// <https://github.com/rust-lang/rust/pull/40636>,
// <https://github.com/rust-lang/rust/pull/39808>.
//
//@ edition:2015..2021
fn g() {
&panic!() //~ ERROR mismatched types
}
// This used to ICE, see <https://github.com/rust-lang/rust/issues/10176>
fn f() -> isize {
(return 1, return 2) //~ ERROR mismatched types
}
fn main() {}
@@ -0,0 +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
fn f() {
let _x = match true {
true => { 10 }
false => { return }
};
}
fn main() {}