mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 23:12:02 +00:00
Add explanations to tests
This commit is contained in:
parent
bcff5a78b3
commit
29f3636282
@ -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: !) -> ! {
|
||||
|
@ -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)]
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)]
|
||||
|
@ -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
|
||||
|
@ -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!
|
||||
|
@ -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)]
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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() {
|
||||
|
@ -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 {
|
||||
|
@ -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, ()>;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user