Skip to content

Commit 1bc6989

Browse files
pnkfelixalexcrichton
authored andcommitted
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 `()`.
1 parent bbfc486 commit 1bc6989

39 files changed

+125
-15
lines changed

src/libcore/cmp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -882,24 +882,24 @@ mod impls {
882882

883883
ord_impl! { char usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
884884

885-
#[stable(feature = "never_type", since = "1.26.0")]
885+
#[unstable(feature = "never_type", issue = "35121")]
886886
impl PartialEq for ! {
887887
fn eq(&self, _: &!) -> bool {
888888
*self
889889
}
890890
}
891891

892-
#[stable(feature = "never_type", since = "1.26.0")]
892+
#[unstable(feature = "never_type", issue = "35121")]
893893
impl Eq for ! {}
894894

895-
#[stable(feature = "never_type", since = "1.26.0")]
895+
#[unstable(feature = "never_type", issue = "35121")]
896896
impl PartialOrd for ! {
897897
fn partial_cmp(&self, _: &!) -> Option<Ordering> {
898898
*self
899899
}
900900
}
901901

902-
#[stable(feature = "never_type", since = "1.26.0")]
902+
#[unstable(feature = "never_type", issue = "35121")]
903903
impl Ord for ! {
904904
fn cmp(&self, _: &!) -> Ordering {
905905
*self

src/libcore/fmt/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,14 +1777,14 @@ macro_rules! fmt_refs {
17771777

17781778
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
17791779

1780-
#[stable(feature = "never_type", since = "1.26.0")]
1780+
#[unstable(feature = "never_type", issue = "35121")]
17811781
impl Debug for ! {
17821782
fn fmt(&self, _: &mut Formatter) -> Result {
17831783
*self
17841784
}
17851785
}
17861786

1787-
#[stable(feature = "never_type", since = "1.26.0")]
1787+
#[unstable(feature = "never_type", issue = "35121")]
17881788
impl Display for ! {
17891789
fn fmt(&self, _: &mut Formatter) -> Result {
17901790
*self

src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
#![feature(iterator_repeat_with)]
8686
#![feature(lang_items)]
8787
#![feature(link_llvm_intrinsics)]
88+
#![feature(never_type)]
8889
#![feature(exhaustive_patterns)]
8990
#![feature(macro_at_most_once_rep)]
9091
#![feature(no_core)]

src/librustc/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
#![cfg_attr(stage0, feature(match_default_bindings))]
5959
#![feature(macro_lifetime_matcher)]
6060
#![feature(macro_vis_matcher)]
61+
#![feature(never_type)]
6162
#![feature(exhaustive_patterns)]
6263
#![feature(non_exhaustive)]
6364
#![feature(nonzero)]

src/librustc_mir/build/matches/simplify.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
113113
PatternKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
114114
let irrefutable = adt_def.variants.iter().enumerate().all(|(i, v)| {
115115
i == variant_index || {
116+
self.hir.tcx().features().never_type &&
116117
self.hir.tcx().features().exhaustive_patterns &&
117118
self.hir.tcx().is_variant_uninhabited_from_all_modules(v, substs)
118119
}

src/libstd/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl<'a> From<Cow<'a, str>> for Box<Error> {
233233
}
234234
}
235235

236-
#[stable(feature = "never_type", since = "1.26.0")]
236+
#[unstable(feature = "never_type", issue = "35121")]
237237
impl Error for ! {
238238
fn description(&self) -> &str { *self }
239239
}

src/libstd/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@
280280
#![feature(macro_reexport)]
281281
#![feature(macro_vis_matcher)]
282282
#![feature(needs_panic_runtime)]
283+
#![feature(never_type)]
283284
#![feature(exhaustive_patterns)]
284285
#![feature(nonzero)]
285286
#![feature(num_bits_bytes)]

src/libsyntax/feature_gate.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,9 @@ declare_features! (
276276
// Allows cfg(target_has_atomic = "...").
277277
(active, cfg_target_has_atomic, "1.9.0", Some(32976), None),
278278

279+
// The `!` type. Does not imply exhaustive_patterns (below) any more.
280+
(active, never_type, "1.13.0", Some(35121), None),
281+
279282
// Allows exhaustive pattern matching on types that contain uninhabited types.
280283
(active, exhaustive_patterns, "1.13.0", None, None),
281284

@@ -1604,6 +1607,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
16041607
ast::TyKind::BareFn(ref bare_fn_ty) => {
16051608
self.check_abi(bare_fn_ty.abi, ty.span);
16061609
}
1610+
ast::TyKind::Never => {
1611+
gate_feature_post!(&self, never_type, ty.span,
1612+
"The `!` type is experimental");
1613+
}
16071614
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
16081615
gate_feature_post!(&self, dyn_trait, ty.span,
16091616
"`dyn Trait` syntax is unstable");

src/test/compile-fail/call-fn-never-arg-wrong-type.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// Test that we can't pass other types for !
1212

13+
#![feature(never_type)]
14+
1315
fn foo(x: !) -> ! {
1416
x
1517
}

src/test/compile-fail/coerce-to-bang-cast.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
12+
1113
fn foo(x: usize, y: !, z: usize) { }
1214

1315
fn cast_a() {

src/test/compile-fail/coerce-to-bang.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
12+
1113
fn foo(x: usize, y: !, z: usize) { }
1214

1315
fn call_foo_a() {

src/test/compile-fail/inhabitedness-infinite-loop.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// error-pattern:reached recursion limit
1212

13+
#![feature(never_type)]
1314
#![feature(exhaustive_patterns)]
1415

1516
struct Foo<'a, T: 'a> {

src/test/compile-fail/loop-break-value.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
12+
1113
fn main() {
1214
let val: ! = loop { break break; };
1315
//~^ ERROR mismatched types

src/test/compile-fail/match-privately-empty.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
1112
#![feature(exhaustive_patterns)]
1213

1314
mod private {

src/test/compile-fail/never-assign-dead-code.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// Test that an assignment of type ! makes the rest of the block dead code.
1212

13+
#![feature(never_type)]
1314
#![feature(rustc_attrs)]
1415
#![warn(unused)]
1516

src/test/compile-fail/never-assign-wrong-type.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
// Test that we can't use another type in place of !
1212

13+
#![feature(never_type)]
1314
#![deny(warnings)]
1415

1516
fn main() {

src/test/compile-fail/uninhabited-irrefutable.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
1112
#![feature(exhaustive_patterns)]
1213

1314
mod foo {

src/test/compile-fail/uninhabited-patterns.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#![feature(box_patterns)]
1212
#![feature(box_syntax)]
13+
#![feature(never_type)]
1314
#![feature(exhaustive_patterns)]
1415
#![feature(slice_patterns)]
1516
#![deny(unreachable_patterns)]

src/test/compile-fail/unreachable-loop-patterns.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
1112
#![feature(exhaustive_patterns)]
1213
#![deny(unreachable_patterns)]
1314

src/test/compile-fail/unreachable-try-pattern.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
1112
#![feature(exhaustive_patterns, rustc_attrs)]
1213
#![warn(unreachable_code)]
1314
#![warn(unreachable_patterns)]

src/test/run-pass/diverging-fallback-control-flow.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
// These represent current behavior, but are pretty dubious. I would
1515
// like to revisit these and potentially change them. --nmatsakis
1616

17+
#![feature(never_type)]
18+
1719
trait BadDefault {
1820
fn default() -> Self;
1921
}

src/test/run-pass/empty-types-in-patterns.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
1112
#![feature(exhaustive_patterns)]
1213
#![feature(slice_patterns)]
1314
#![allow(unreachable_patterns)]

src/test/run-pass/impl-for-never.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// Test that we can call static methods on ! both directly and when it appears in a generic
1212

13+
#![feature(never_type)]
14+
1315
trait StringifyType {
1416
fn stringify_type() -> &'static str;
1517
}

src/test/run-pass/issue-44402.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
1112
#![feature(exhaustive_patterns)]
1213

1314
// Regression test for inhabitedness check. The old

src/test/run-pass/loop-break-value.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
12+
1113
#[allow(unused)]
1214
fn never_returns() {
1315
loop {

src/test/run-pass/mir_calls_to_shims.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// ignore-wasm32-bare compiled with panic=abort by default
1212

1313
#![feature(fn_traits)]
14+
#![feature(never_type)]
1415

1516
use std::panic;
1617

src/test/run-pass/never-result.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
// Test that we can extract a ! through pattern matching then use it as several different types.
1212

13+
#![feature(never_type)]
14+
1315
fn main() {
1416
let x: Result<u32, !> = Ok(123);
1517
match x {

src/test/run-pass/type-sizes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(never_type)]
1112

1213
use std::mem::size_of;
1314

src/test/ui/feature-gate-exhaustive-patterns.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(never_type)]
1111
fn foo() -> Result<u32, !> {
1212
Ok(123)
1313
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// Test that ! errors when used in illegal positions with feature(never_type) disabled
12+
13+
trait Foo {
14+
type Wub;
15+
}
16+
17+
type Ma = (u32, !, i32); //~ ERROR type is experimental
18+
type Meeshka = Vec<!>; //~ ERROR type is experimental
19+
type Mow = &fn(!) -> !; //~ ERROR type is experimental
20+
type Skwoz = &mut !; //~ ERROR type is experimental
21+
22+
impl Foo for Meeshka {
23+
type Wub = !; //~ ERROR type is experimental
24+
}
25+
26+
fn main() {
27+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0658]: The `!` type is experimental (see issue #35121)
2+
--> $DIR/feature-gate-never_type.rs:17:17
3+
|
4+
LL | type Ma = (u32, !, i32); //~ ERROR type is experimental
5+
| ^
6+
|
7+
= help: add #![feature(never_type)] to the crate attributes to enable
8+
9+
error[E0658]: The `!` type is experimental (see issue #35121)
10+
--> $DIR/feature-gate-never_type.rs:18:20
11+
|
12+
LL | type Meeshka = Vec<!>; //~ ERROR type is experimental
13+
| ^
14+
|
15+
= help: add #![feature(never_type)] to the crate attributes to enable
16+
17+
error[E0658]: The `!` type is experimental (see issue #35121)
18+
--> $DIR/feature-gate-never_type.rs:19:16
19+
|
20+
LL | type Mow = &fn(!) -> !; //~ ERROR type is experimental
21+
| ^
22+
|
23+
= help: add #![feature(never_type)] to the crate attributes to enable
24+
25+
error[E0658]: The `!` type is experimental (see issue #35121)
26+
--> $DIR/feature-gate-never_type.rs:20:19
27+
|
28+
LL | type Skwoz = &mut !; //~ ERROR type is experimental
29+
| ^
30+
|
31+
= help: add #![feature(never_type)] to the crate attributes to enable
32+
33+
error[E0658]: The `!` type is experimental (see issue #35121)
34+
--> $DIR/feature-gate-never_type.rs:23:16
35+
|
36+
LL | type Wub = !; //~ ERROR type is experimental
37+
| ^
38+
|
39+
= help: add #![feature(never_type)] to the crate attributes to enable
40+
41+
error: aborting due to 5 previous errors
42+
43+
For more information about this error, try `rustc --explain E0658`.

src/test/ui/print_type_sizes/uninhabited.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// compile-flags: -Z print-type-sizes
1212
// must-compile-successfully
1313

14+
#![feature(never_type)]
1415
#![feature(start)]
1516

1617
#[start]

src/test/ui/reachable/expr_add.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(never_type)]
1111
#![allow(unused_variables)]
1212
#![deny(unreachable_code)]
1313

src/test/ui/reachable/expr_assign.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(never_type)]
1111
#![allow(unused_variables)]
1212
#![allow(unused_assignments)]
1313
#![allow(dead_code)]

src/test/ui/reachable/expr_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
10-
10+
#![feature(never_type)]
1111
#![allow(unused_variables)]
1212
#![allow(unused_assignments)]
1313
#![allow(dead_code)]

0 commit comments

Comments
 (0)