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() {

0 commit comments

Comments
 (0)