// 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: !) -> ! {
// 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)]
// 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() {
// 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;
}
// 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 {
// 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
}
// 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
}
// 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
// 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)]
// 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
// 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!
// 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)]
// 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 {
// 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 {
// 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() {
// 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 {
// 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, ()>;
}