Revert stabilization of feature(never_type).

This commit is just covering the feature gate itself and the tests
that made direct use of `!` and thus need to opt back into the
feature.

A follow on commit brings back the other change that motivates the
revert: Namely, going back to the old rules for falling back to `()`.
This commit is contained in:
Felix S. Klock II 2018-04-20 17:07:58 +02:00
parent 1a4443995c
commit fadabd6fbb
41 changed files with 127 additions and 17 deletions

View file

@ -10,6 +10,8 @@
// Test that we can't pass other types for !
#![feature(never_type)]
fn foo(x: !) -> ! {
x
}

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
fn foo(x: usize, y: !, z: usize) { }
fn cast_a() {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
fn foo(x: usize, y: !, z: usize) { }
fn call_foo_a() {

View file

@ -10,6 +10,7 @@
// error-pattern:reached recursion limit
#![feature(never_type)]
#![feature(exhaustive_patterns)]
struct Foo<'a, T: 'a> {

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
fn main() {
let val: ! = loop { break break; };
//~^ ERROR mismatched types

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![feature(exhaustive_patterns)]
mod private {

View file

@ -10,6 +10,7 @@
// Test that an assignment of type ! makes the rest of the block dead code.
#![feature(never_type)]
#![feature(rustc_attrs)]
#![warn(unused)]

View file

@ -10,6 +10,7 @@
// Test that we can't use another type in place of !
#![feature(never_type)]
#![deny(warnings)]
fn main() {

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![feature(exhaustive_patterns)]
mod foo {

View file

@ -10,6 +10,7 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(slice_patterns)]
#![deny(unreachable_patterns)]

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![deny(unreachable_patterns)]

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![feature(exhaustive_patterns, rustc_attrs)]
#![warn(unreachable_code)]
#![warn(unreachable_patterns)]

View file

@ -14,6 +14,8 @@
// These represent current behavior, but are pretty dubious. I would
// like to revisit these and potentially change them. --nmatsakis
#![feature(never_type)]
trait BadDefault {
fn default() -> Self;
}

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(slice_patterns)]
#![allow(unreachable_patterns)]

View file

@ -10,6 +10,8 @@
// Test that we can call static methods on ! both directly and when it appears in a generic
#![feature(never_type)]
trait StringifyType {
fn stringify_type() -> &'static str;
}

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![feature(exhaustive_patterns)]
// Regression test for inhabitedness check. The old

View file

@ -8,6 +8,8 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#[allow(unused)]
fn never_returns() {
loop {

View file

@ -11,6 +11,7 @@
// ignore-wasm32-bare compiled with panic=abort by default
#![feature(fn_traits)]
#![feature(never_type)]
use std::panic;

View file

@ -10,6 +10,8 @@
// Test that we can extract a ! through pattern matching then use it as several different types.
#![feature(never_type)]
fn main() {
let x: Result<u32, !> = Ok(123);
match x {

View file

@ -8,6 +8,7 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
use std::mem::size_of;

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
fn foo() -> Result<u32, !> {
Ok(123)
}

View file

@ -0,0 +1,27 @@
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// 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;
}
type Ma = (u32, !, i32); //~ ERROR type is experimental
type Meeshka = Vec<!>; //~ ERROR type is experimental
type Mow = &fn(!) -> !; //~ ERROR type is experimental
type Skwoz = &mut !; //~ ERROR type is experimental
impl Foo for Meeshka {
type Wub = !; //~ ERROR type is experimental
}
fn main() {
}

View file

@ -0,0 +1,43 @@
error[E0658]: The `!` type is experimental (see issue #35121)
--> $DIR/feature-gate-never_type.rs:17:17
|
LL | type Ma = (u32, !, i32); //~ ERROR type is experimental
| ^
|
= help: add #![feature(never_type)] to the crate attributes to enable
error[E0658]: The `!` type is experimental (see issue #35121)
--> $DIR/feature-gate-never_type.rs:18:20
|
LL | type Meeshka = Vec<!>; //~ ERROR type is experimental
| ^
|
= help: add #![feature(never_type)] to the crate attributes to enable
error[E0658]: The `!` type is experimental (see issue #35121)
--> $DIR/feature-gate-never_type.rs:19:16
|
LL | type Mow = &fn(!) -> !; //~ ERROR type is experimental
| ^
|
= help: add #![feature(never_type)] to the crate attributes to enable
error[E0658]: The `!` type is experimental (see issue #35121)
--> $DIR/feature-gate-never_type.rs:20:19
|
LL | type Skwoz = &mut !; //~ ERROR type is experimental
| ^
|
= help: add #![feature(never_type)] to the crate attributes to enable
error[E0658]: The `!` type is experimental (see issue #35121)
--> $DIR/feature-gate-never_type.rs:23:16
|
LL | type Wub = !; //~ ERROR type is experimental
| ^
|
= help: add #![feature(never_type)] to the crate attributes to enable
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0658`.

View file

@ -11,6 +11,7 @@
// compile-flags: -Z print-type-sizes
// compile-pass
#![feature(never_type)]
#![feature(start)]
#[start]

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![allow(unused_variables)]
#![deny(unreachable_code)]

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![allow(unused_variables)]
#![allow(unused_assignments)]
#![allow(dead_code)]

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![allow(unused_variables)]
#![allow(unused_assignments)]
#![allow(dead_code)]

View file

@ -12,7 +12,7 @@
#![allow(unused_assignments)]
#![allow(dead_code)]
#![deny(unreachable_code)]
#![feature(type_ascription)]
#![feature(never_type, type_ascription)]
fn a() {
// the cast is unreachable:

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![allow(unused_variables)]
#![allow(unused_assignments)]
#![allow(dead_code)]

View file

@ -12,7 +12,7 @@
#![allow(unused_assignments)]
#![allow(dead_code)]
#![deny(unreachable_code)]
#![feature(type_ascription)]
#![feature(never_type, type_ascription)]
fn a() {
// the cast is unreachable:

View file

@ -7,7 +7,7 @@
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(never_type)]
#![allow(unused_variables)]
#![allow(unused_assignments)]
#![allow(dead_code)]