Skip to content

Commit 29f3636

Browse files
committed
Add explanations to tests
1 parent bcff5a7 commit 29f3636

17 files changed

+37
-0
lines changed

src/test/compile-fail/call-fn-never-arg-wrong-type.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that we can't pass other types for !
12+
1113
#![feature(never_type)]
1214

1315
fn foo(x: !) -> ! {

src/test/compile-fail/never-assign-dead-code.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that an assignment of type ! makes the rest of the block dead code.
12+
1113
#![feature(never_type)]
1214
#![deny(unused, unreachable_code)]
1315

src/test/compile-fail/never-assign-wrong-type.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that we can't use another type in place of !
12+
1113
#![feature(never_type)]
1214

1315
fn main() {

src/test/compile-fail/never-disabled.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that ! errors when used in illegal positions with feature(never_type) disabled
12+
1113
trait Foo {
1214
type Wub;
1315
}

src/test/compile-fail/never-fallback.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that diverging types default to ! when feature(never_type) is enabled. This test is the
12+
// same as run-pass/unit-fallback.rs except that ! is enabled.
13+
1114
#![feature(never_type)]
1215

1316
trait Balls: Sized {

src/test/compile-fail/return-from-diverging.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that return another type in place of ! raises a type mismatch.
12+
1113
fn fail() -> ! {
1214
return "wow"; //~ ERROR mismatched types
1315
}

src/test/compile-fail/return-unit-from-diverging.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that we get the usual error that we'd get for any other return type and not something about
12+
// diverging functions not being able to return.
13+
1114
fn fail() -> ! {
1215
return; //~ ERROR in a function whose return type is not
1316
}

src/test/run-fail/adjust_never.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that a variable of type ! can coerce to another type.
12+
1113
#![feature(never_type)]
1214

1315
// error-pattern:explicit

src/test/run-fail/call-fn-never-arg.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that we can use a ! for an argument of type !
12+
1113
// error-pattern:wowzers!
1214

1315
#![feature(never_type)]

src/test/run-fail/cast-never.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
// Test that we can explicitly cast ! to another type
12+
1113
#![feature(never_type)]
1214

1315
// error-pattern:explicit

0 commit comments

Comments
 (0)