Skip to content

Commit fadabd6

Browse files
committed
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 1a44439 commit fadabd6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+127
-17
lines changed

src/libcore/clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ mod impls {
179179
bool char
180180
}
181181

182-
#[stable(feature = "never_type", since = "1.26.0")]
182+
#[unstable(feature = "never_type", issue = "35121")]
183183
impl Clone for ! {
184184
#[inline]
185185
fn clone(&self) -> Self {

src/libcore/cmp.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -881,24 +881,24 @@ mod impls {
881881

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

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

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

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

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

src/libcore/fmt/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1780,14 +1780,14 @@ macro_rules! fmt_refs {
17801780

17811781
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
17821782

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

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

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
#![feature(iterator_repeat_with)]
8383
#![feature(lang_items)]
8484
#![feature(link_llvm_intrinsics)]
85+
#![feature(never_type)]
8586
#![feature(exhaustive_patterns)]
8687
#![feature(macro_at_most_once_rep)]
8788
#![feature(no_core)]

src/libcore/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ mod copy_impls {
630630
bool char
631631
}
632632

633-
#[stable(feature = "never_type", since = "1.26.0")]
633+
#[unstable(feature = "never_type", issue = "35121")]
634634
impl Copy for ! {}
635635

636636
#[stable(feature = "rust1", since = "1.0.0")]

src/librustc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
#![cfg_attr(windows, feature(libc))]
5353
#![feature(macro_lifetime_matcher)]
5454
#![feature(macro_vis_matcher)]
55+
#![feature(never_type)]
5556
#![feature(exhaustive_patterns)]
5657
#![feature(non_exhaustive)]
5758
#![feature(nonzero)]

src/librustc_mir/build/matches/simplify.rs

+1
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

+1-1
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

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
#![feature(macro_reexport)]
276276
#![feature(macro_vis_matcher)]
277277
#![feature(needs_panic_runtime)]
278+
#![feature(never_type)]
278279
#![feature(exhaustive_patterns)]
279280
#![feature(nonzero)]
280281
#![feature(num_bits_bytes)]

src/libsyntax/feature_gate.rs

+7
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ declare_features! (
272272
// Allows cfg(target_has_atomic = "...").
273273
(active, cfg_target_has_atomic, "1.9.0", Some(32976), None),
274274

275+
// The `!` type. Does not imply exhaustive_patterns (below) any more.
276+
(active, never_type, "1.13.0", Some(35121), None),
277+
275278
// Allows exhaustive pattern matching on types that contain uninhabited types.
276279
(active, exhaustive_patterns, "1.13.0", None, None),
277280

@@ -1635,6 +1638,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
16351638
ast::TyKind::BareFn(ref bare_fn_ty) => {
16361639
self.check_abi(bare_fn_ty.abi, ty.span);
16371640
}
1641+
ast::TyKind::Never => {
1642+
gate_feature_post!(&self, never_type, ty.span,
1643+
"The `!` type is experimental");
1644+
}
16381645
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
16391646
gate_feature_post!(&self, dyn_trait, ty.span,
16401647
"`dyn Trait` syntax is unstable");

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

+2
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

+2
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

+2
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

+1
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

+2
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

+1
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

+1
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

+1
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

+1
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

+1
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

+1
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

+1
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

+2
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

+1
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

+2
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

+1
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

+2
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

+1
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

+2
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

+1
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

+1-1
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
}
+27
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+
}
+43
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

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
// compile-flags: -Z print-type-sizes
1212
// compile-pass
1313

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

1617
#[start]

src/test/ui/reachable/expr_add.rs

+1-1
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

0 commit comments

Comments
 (0)