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

src/test/run-fail/never-associated-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 use ! as an associated type.
12+
1113
#![feature(never_type)]
1214

1315
// error-pattern:kapow!

src/test/run-fail/never-type-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 ! as an argument to a trait impl.
12+
1113
// error-pattern:oh no!
1214

1315
#![feature(never_type)]

src/test/run-fail/return-never-coerce.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 ! coerces to other types.
12+
1113
// error-pattern:aah!
1214

1315
fn call_another_fn<T, F: FnOnce() -> T>(f: F) -> T {

src/test/run-pass/impl-for-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 call static methods on ! both directly and when it appears in a generic
12+
1113
#![feature(never_type)]
1214

1315
trait StringifyType {

src/test/run-pass/never-result.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 extract a ! through pattern matching then use it as several different types.
12+
1113
#![feature(never_type)]
1214

1315
fn main() {

src/test/run-pass/never_coercions.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 having something of type ! doesn't screw up type-checking and that it coerces to the
12+
// LUB type of the other match arms.
13+
1114
fn main() {
1215
let v: Vec<u32> = Vec::new();
1316
match 0u32 {

src/test/run-pass/unit-fallback.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 diverging types default to () (with feature(never_type) disabled).
12+
1113
trait Balls: Sized {
1214
fn smeg() -> Result<Self, ()>;
1315
}

0 commit comments

Comments
 (0)