Add explanations to tests

This commit is contained in:
Andrew Cann 2016-08-12 01:22:34 +08:00
parent bcff5a78b3
commit 29f3636282
17 changed files with 37 additions and 0 deletions

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we can't pass other types for !
#![feature(never_type)]
fn foo(x: !) -> ! {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that an assignment of type ! makes the rest of the block dead code.
#![feature(never_type)]
#![deny(unused, unreachable_code)]

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we can't use another type in place of !
#![feature(never_type)]
fn main() {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that ! errors when used in illegal positions with feature(never_type) disabled
trait Foo {
type Wub;
}

View File

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that diverging types default to ! when feature(never_type) is enabled. This test is the
// same as run-pass/unit-fallback.rs except that ! is enabled.
#![feature(never_type)]
trait Balls: Sized {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that return another type in place of ! raises a type mismatch.
fn fail() -> ! {
return "wow"; //~ ERROR mismatched types
}

View File

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we get the usual error that we'd get for any other return type and not something about
// diverging functions not being able to return.
fn fail() -> ! {
return; //~ ERROR in a function whose return type is not
}

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that a variable of type ! can coerce to another type.
#![feature(never_type)]
// error-pattern:explicit

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we can use a ! for an argument of type !
// error-pattern:wowzers!
#![feature(never_type)]

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we can explicitly cast ! to another type
#![feature(never_type)]
// error-pattern:explicit

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we can use ! as an associated type.
#![feature(never_type)]
// error-pattern:kapow!

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we can use ! as an argument to a trait impl.
// error-pattern:oh no!
#![feature(never_type)]

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that ! coerces to other types.
// error-pattern:aah!
fn call_another_fn<T, F: FnOnce() -> T>(f: F) -> T {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we can call static methods on ! both directly and when it appears in a generic
#![feature(never_type)]
trait StringifyType {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that we can extract a ! through pattern matching then use it as several different types.
#![feature(never_type)]
fn main() {

View File

@ -8,6 +8,9 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that having something of type ! doesn't screw up type-checking and that it coerces to the
// LUB type of the other match arms.
fn main() {
let v: Vec<u32> = Vec::new();
match 0u32 {

View File

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Test that diverging types default to () (with feature(never_type) disabled).
trait Balls: Sized {
fn smeg() -> Result<Self, ()>;
}