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

@ -179,7 +179,7 @@ mod impls {
bool char
}
#[stable(feature = "never_type", since = "1.26.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Clone for ! {
#[inline]
fn clone(&self) -> Self {

View File

@ -881,24 +881,24 @@ mod impls {
ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
#[stable(feature = "never_type", since = "1.26.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl PartialEq for ! {
fn eq(&self, _: &!) -> bool {
*self
}
}
#[stable(feature = "never_type", since = "1.26.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Eq for ! {}
#[stable(feature = "never_type", since = "1.26.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl PartialOrd for ! {
fn partial_cmp(&self, _: &!) -> Option<Ordering> {
*self
}
}
#[stable(feature = "never_type", since = "1.26.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Ord for ! {
fn cmp(&self, _: &!) -> Ordering {
*self

View File

@ -1780,14 +1780,14 @@ macro_rules! fmt_refs {
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
#[stable(feature = "never_type", since = "1.26.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Debug for ! {
fn fmt(&self, _: &mut Formatter) -> Result {
*self
}
}
#[stable(feature = "never_type", since = "1.26.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Display for ! {
fn fmt(&self, _: &mut Formatter) -> Result {
*self

View File

@ -82,6 +82,7 @@
#![feature(iterator_repeat_with)]
#![feature(lang_items)]
#![feature(link_llvm_intrinsics)]
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(macro_at_most_once_rep)]
#![feature(no_core)]

View File

@ -630,7 +630,7 @@ mod copy_impls {
bool char
}
#[stable(feature = "never_type", since = "1.26.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Copy for ! {}
#[stable(feature = "rust1", since = "1.0.0")]

View File

@ -52,6 +52,7 @@
#![cfg_attr(windows, feature(libc))]
#![feature(macro_lifetime_matcher)]
#![feature(macro_vis_matcher)]
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(non_exhaustive)]
#![feature(nonzero)]

View File

@ -113,6 +113,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
PatternKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
let irrefutable = adt_def.variants.iter().enumerate().all(|(i, v)| {
i == variant_index || {
self.hir.tcx().features().never_type &&
self.hir.tcx().features().exhaustive_patterns &&
self.hir.tcx().is_variant_uninhabited_from_all_modules(v, substs)
}

View File

@ -233,7 +233,7 @@ impl<'a> From<Cow<'a, str>> for Box<Error> {
}
}
#[stable(feature = "never_type", since = "1.26.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Error for ! {
fn description(&self) -> &str { *self }
}

View File

@ -275,6 +275,7 @@
#![feature(macro_reexport)]
#![feature(macro_vis_matcher)]
#![feature(needs_panic_runtime)]
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(nonzero)]
#![feature(num_bits_bytes)]

View File

@ -272,6 +272,9 @@ declare_features! (
// Allows cfg(target_has_atomic = "...").
(active, cfg_target_has_atomic, "1.9.0", Some(32976), None),
// The `!` type. Does not imply exhaustive_patterns (below) any more.
(active, never_type, "1.13.0", Some(35121), None),
// Allows exhaustive pattern matching on types that contain uninhabited types.
(active, exhaustive_patterns, "1.13.0", None, None),
@ -1635,6 +1638,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
ast::TyKind::BareFn(ref bare_fn_ty) => {
self.check_abi(bare_fn_ty.abi, ty.span);
}
ast::TyKind::Never => {
gate_feature_post!(&self, never_type, ty.span,
"The `!` type is experimental");
}
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
gate_feature_post!(&self, dyn_trait, ty.span,
"`dyn Trait` syntax is unstable");

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)]