Skip to content

Commit 3848428

Browse files
committed
stabilise feature(never_type)
Replace feature(never_type) with feature(exhaustive_patterns). feature(exhaustive_patterns) only covers the pattern-exhaustives checks that used to be covered by feature(never_type)
1 parent 61f8e2c commit 3848428

File tree

77 files changed

+127
-198
lines changed

Some content is hidden

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

77 files changed

+127
-198
lines changed

src/libcore/cmp.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -880,24 +880,24 @@ mod impls {
880880

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

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

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

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

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

src/libcore/fmt/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1570,14 +1570,14 @@ macro_rules! fmt_refs {
15701570

15711571
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
15721572

1573-
#[unstable(feature = "never_type", issue = "35121")]
1573+
#[stable(feature = "never_type", since = "1.24.0")]
15741574
impl Debug for ! {
15751575
fn fmt(&self, _: &mut Formatter) -> Result {
15761576
*self
15771577
}
15781578
}
15791579

1580-
#[unstable(feature = "never_type", issue = "35121")]
1580+
#[stable(feature = "never_type", since = "1.24.0")]
15811581
impl Display for ! {
15821582
fn fmt(&self, _: &mut Formatter) -> Result {
15831583
*self

src/libcore/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
#![feature(inclusive_range_syntax)]
7979
#![feature(intrinsics)]
8080
#![feature(lang_items)]
81-
#![feature(never_type)]
81+
#![feature(exhaustive_patterns)]
8282
#![feature(no_core)]
8383
#![feature(on_unimplemented)]
8484
#![feature(optin_builtin_traits)]
@@ -91,6 +91,7 @@
9191
#![feature(untagged_unions)]
9292
#![feature(unwind_attributes)]
9393
#![feature(doc_spotlight)]
94+
#![cfg_attr(stage0, feature(never_type))]
9495

9596
#[prelude_import]
9697
#[allow(unused)]

src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
#![cfg_attr(windows, feature(libc))]
5757
#![feature(macro_vis_matcher)]
5858
#![feature(match_default_bindings)]
59-
#![feature(never_type)]
59+
#![feature(exhaustive_patterns)]
6060
#![feature(nonzero)]
6161
#![feature(quote)]
6262
#![feature(refcell_replace_swap)]

src/librustc_const_eval/_match.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> {
201201
}
202202

203203
fn is_uninhabited(&self, ty: Ty<'tcx>) -> bool {
204-
if self.tcx.sess.features.borrow().never_type {
204+
if self.tcx.sess.features.borrow().exhaustive_patterns {
205205
self.tcx.is_ty_uninhabited_from(self.module, ty)
206206
} else {
207207
false
@@ -227,7 +227,7 @@ impl<'a, 'tcx> MatchCheckCtxt<'a, 'tcx> {
227227
substs: &'tcx ty::subst::Substs<'tcx>)
228228
-> bool
229229
{
230-
if self.tcx.sess.features.borrow().never_type {
230+
if self.tcx.sess.features.borrow().exhaustive_patterns {
231231
self.tcx.is_enum_variant_uninhabited_from(self.module, variant, substs)
232232
} else {
233233
false
@@ -636,7 +636,7 @@ pub fn is_useful<'p, 'a: 'p, 'tcx: 'a>(cx: &mut MatchCheckCtxt<'a, 'tcx>,
636636
// test for details.
637637
//
638638
// FIXME: currently the only way I know of something can
639-
// be a privately-empty enum is when the never_type
639+
// be a privately-empty enum is when the exhaustive_patterns
640640
// feature flag is not present, so this is only
641641
// needed for that case.
642642

src/librustc_const_eval/check_match.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,9 @@ impl<'a, 'tcx> MatchVisitor<'a, 'tcx> {
205205
let pat_ty = self.tables.node_id_to_type(scrut.hir_id);
206206
let module = self.tcx.hir.get_module_parent(scrut.id);
207207
if inlined_arms.is_empty() {
208-
let scrutinee_is_uninhabited = if self.tcx.sess.features.borrow().never_type {
208+
let scrutinee_is_uninhabited = if self.tcx.sess.features
209+
.borrow()
210+
.exhaustive_patterns {
209211
self.tcx.is_ty_uninhabited_from(module, pat_ty)
210212
} else {
211213
self.conservative_is_uninhabited(pat_ty)

src/librustc_lint/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#![feature(quote)]
3333
#![feature(rustc_diagnostic_macros)]
3434
#![feature(slice_patterns)]
35+
#![cfg_attr(stage0, feature(never_type))]
3536

3637
#[macro_use]
3738
extern crate syntax;

src/librustc_mir/build/matches/simplify.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
100100
PatternKind::Variant { adt_def, substs, variant_index, ref subpatterns } => {
101101
let irrefutable = adt_def.variants.iter().enumerate().all(|(i, v)| {
102102
i == variant_index || {
103-
self.hir.tcx().sess.features.borrow().never_type &&
103+
self.hir.tcx().sess.features.borrow().exhaustive_patterns &&
104104
self.hir.tcx().is_variant_uninhabited_from_all_modules(v, substs)
105105
}
106106
});

src/librustc_mir/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,14 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
3030
#![feature(inclusive_range)]
3131
#![feature(macro_vis_matcher)]
3232
#![feature(match_default_bindings)]
33-
#![feature(never_type)]
33+
#![feature(exhaustive_patterns)]
3434
#![feature(range_contains)]
3535
#![feature(rustc_diagnostic_macros)]
3636
#![feature(placement_in_syntax)]
3737
#![feature(collection_placement)]
3838
#![feature(nonzero)]
3939
#![feature(underscore_lifetimes)]
40+
#![cfg_attr(stage0, feature(never_type))]
4041

4142
#[macro_use]
4243
extern crate bitflags;

src/librustc_typeck/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,12 @@ This API is completely unstable and subject to change.
7979
#![feature(conservative_impl_trait)]
8080
#![feature(from_ref)]
8181
#![feature(match_default_bindings)]
82-
#![feature(never_type)]
82+
#![feature(exhaustive_patterns)]
8383
#![feature(quote)]
8484
#![feature(refcell_replace_swap)]
8585
#![feature(rustc_diagnostic_macros)]
8686
#![feature(slice_patterns)]
87+
#![cfg_attr(stage0, feature(never_type))]
8788

8889
#[macro_use] extern crate log;
8990
#[macro_use] extern crate syntax;

src/libstd/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl<'a> From<Cow<'a, str>> for Box<Error> {
234234
}
235235
}
236236

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

src/libstd/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
#![feature(macro_reexport)]
283283
#![feature(macro_vis_matcher)]
284284
#![feature(needs_panic_runtime)]
285-
#![feature(never_type)]
285+
#![feature(exhaustive_patterns)]
286286
#![feature(num_bits_bytes)]
287287
#![feature(old_wrapping)]
288288
#![feature(on_unimplemented)]
@@ -323,6 +323,7 @@
323323
#![feature(doc_spotlight)]
324324
#![cfg_attr(test, feature(update_panic_count))]
325325
#![cfg_attr(windows, feature(used))]
326+
#![cfg_attr(stage0, feature(never_type))]
326327

327328
#![default_lib_allocator]
328329

src/libstd/primitive_docs.rs

+5-6
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ mod prim_bool { }
7979
/// write:
8080
///
8181
/// ```
82-
/// #![feature(never_type)]
8382
/// # fn foo() -> u32 {
8483
/// let x: ! = {
8584
/// return 123
@@ -131,13 +130,15 @@ mod prim_bool { }
131130
/// [`Result<String, !>`] which we can unpack like this:
132131
///
133132
/// ```ignore (string-from-str-error-type-is-not-never-yet)
133+
/// #[feature(exhaustive_patterns)]
134134
/// // NOTE: This does not work today!
135135
/// let Ok(s) = String::from_str("hello");
136136
/// ```
137137
///
138-
/// Since the [`Err`] variant contains a `!`, it can never occur. So we can exhaustively match on
139-
/// [`Result<T, !>`] by just taking the [`Ok`] variant. This illustrates another behaviour of `!` -
140-
/// it can be used to "delete" certain enum variants from generic types like `Result`.
138+
/// Since the [`Err`] variant contains a `!`, it can never occur. If the `exhaustive_patterns`
139+
/// feature is present this means we can exhaustively match on [`Result<T, !>`] by just taking the
140+
/// [`Ok`] variant. This illustrates another behaviour of `!` - it can be used to "delete" certain
141+
/// enum variants from generic types like `Result`.
141142
///
142143
/// [`String::from_str`]: str/trait.FromStr.html#tymethod.from_str
143144
/// [`Result<String, !>`]: result/enum.Result.html
@@ -154,7 +155,6 @@ mod prim_bool { }
154155
/// for example:
155156
///
156157
/// ```
157-
/// # #![feature(never_type)]
158158
/// # use std::fmt;
159159
/// # trait Debug {
160160
/// # fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result;
@@ -192,7 +192,6 @@ mod prim_bool { }
192192
/// [`Default`]: default/trait.Default.html
193193
/// [`default()`]: default/trait.Default.html#tymethod.default
194194
///
195-
#[unstable(feature = "never_type", issue = "35121")]
196195
mod prim_never { }
197196

198197
#[doc(primitive = "char")]

src/libsyntax/feature_gate.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ declare_features! (
280280
// Allows `impl Trait` in function arguments.
281281
(active, universal_impl_trait, "1.23.0", Some(34511)),
282282

283-
// The `!` type
284-
(active, never_type, "1.13.0", Some(35121)),
283+
// Allows exhaustive pattern matching on types that contain uninhabited types.
284+
(active, exhaustive_patterns, "1.13.0", None),
285285

286286
// Allows all literals in attribute lists and values of key-value pairs.
287287
(active, attr_literals, "1.13.0", Some(34981)),
@@ -1604,10 +1604,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
16041604
ast::TyKind::BareFn(ref bare_fn_ty) => {
16051605
self.check_abi(bare_fn_ty.abi, ty.span);
16061606
}
1607-
ast::TyKind::Never => {
1608-
gate_feature_post!(&self, never_type, ty.span,
1609-
"The `!` type is experimental");
1610-
},
16111607
ast::TyKind::TraitObject(_, ast::TraitObjectSyntax::Dyn) => {
16121608
gate_feature_post!(&self, dyn_trait, ty.span,
16131609
"`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,8 +10,6 @@
1010

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

13-
#![feature(never_type)]
14-
1513
fn foo(x: !) -> ! {
1614
x
1715
}

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

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

11-
#![feature(never_type)]
12-
1311
fn foo(x: usize, y: !, z: usize) { }
1412

1513
#[deny(coerce_never)]

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

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

11-
#![feature(never_type)]
1211
#![deny(coerce_never)]
1312

1413
fn foo(x: usize, y: !, z: usize) { }

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
// error-pattern:reached recursion limit
1212

13-
#![feature(never_type)]
13+
#![feature(exhaustive_patterns)]
1414

1515
struct Foo<'a, T: 'a> {
1616
ph: std::marker::PhantomData<T>,

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

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

11-
#![feature(never_type)]
12-
1311
fn main() {
1412
let val: ! = loop { break break; };
1513
//~^ ERROR mismatched types

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(never_type)]
11+
#![feature(exhaustive_patterns)]
1212

1313
mod private {
1414
pub struct Private {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

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

13-
#![feature(never_type, rustc_attrs)]
13+
#![feature(rustc_attrs)]
1414
#![warn(unused)]
1515

1616
#[rustc_error]

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

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

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

13-
#![feature(never_type)]
1413
#![deny(warnings)]
1514

1615
fn main() {

src/test/compile-fail/recursive-types-are-not-uninhabited.rs

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

11-
//#![feature(never_type)]
12-
1311
struct R<'a> {
1412
r: &'a R<'a>,
1513
}

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(never_type)]
11+
#![feature(exhaustive_patterns)]
1212

1313
mod foo {
1414
pub struct SecretlyEmpty {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#![feature(box_patterns)]
1212
#![feature(slice_patterns)]
1313
#![feature(box_syntax)]
14-
#![feature(never_type)]
14+
#![feature(exhaustive_patterns)]
1515
#![deny(unreachable_patterns)]
1616

1717
mod foo {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(never_type)]
11+
#![feature(exhaustive_patterns)]
1212
#![deny(unreachable_patterns)]
1313

1414
fn main() {

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
#![feature(never_type, rustc_attrs)]
11+
#![feature(exhaustive_patterns, rustc_attrs)]
1212
#![warn(unreachable_code)]
1313
#![warn(unreachable_patterns)]
1414

src/test/run-fail/adjust_never.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// Test that a variable of type ! can coerce to another type.
1212

13-
#![feature(never_type)]
14-
1513
// error-pattern:explicit
1614
fn main() {
1715
let x: ! = panic!();

src/test/run-fail/call-fn-never-arg.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212

1313
// error-pattern:wowzers!
1414

15-
#![feature(never_type)]
1615
#![allow(unreachable_code)]
1716

1817
fn foo(x: !) -> ! {

src/test/run-fail/cast-never.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// Test that we can explicitly cast ! to another type
1212

13-
#![feature(never_type)]
14-
1513
// error-pattern:explicit
1614
fn main() {
1715
let x: ! = panic!();

src/test/run-fail/never-associated-type.rs

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
// Test that we can use ! as an associated type.
1212

13-
#![feature(never_type)]
14-
1513
// error-pattern:kapow!
1614

1715
trait Foo {

0 commit comments

Comments
 (0)