Skip to content

Commit 15c30dd

Browse files
committed
Stabilize the never_type, written !.
1 parent f1b882b commit 15c30dd

File tree

21 files changed

+26
-52
lines changed

21 files changed

+26
-52
lines changed

src/libcore/clone.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ mod impls {
185185
bool char
186186
}
187187

188-
#[unstable(feature = "never_type", issue = "35121")]
188+
#[stable(feature = "never_type", since = "1.41.0")]
189189
impl Clone for ! {
190190
#[inline]
191191
fn clone(&self) -> Self {

src/libcore/cmp.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1128,24 +1128,24 @@ mod impls {
11281128

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

1131-
#[unstable(feature = "never_type", issue = "35121")]
1131+
#[stable(feature = "never_type", since = "1.41.0")]
11321132
impl PartialEq for ! {
11331133
fn eq(&self, _: &!) -> bool {
11341134
*self
11351135
}
11361136
}
11371137

1138-
#[unstable(feature = "never_type", issue = "35121")]
1138+
#[stable(feature = "never_type", since = "1.41.0")]
11391139
impl Eq for ! {}
11401140

1141-
#[unstable(feature = "never_type", issue = "35121")]
1141+
#[stable(feature = "never_type", since = "1.41.0")]
11421142
impl PartialOrd for ! {
11431143
fn partial_cmp(&self, _: &!) -> Option<Ordering> {
11441144
*self
11451145
}
11461146
}
11471147

1148-
#[unstable(feature = "never_type", issue = "35121")]
1148+
#[stable(feature = "never_type", since = "1.41.0")]
11491149
impl Ord for ! {
11501150
fn cmp(&self, _: &!) -> Ordering {
11511151
*self

src/libcore/fmt/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1935,14 +1935,14 @@ macro_rules! fmt_refs {
19351935

19361936
fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
19371937

1938-
#[unstable(feature = "never_type", issue = "35121")]
1938+
#[stable(feature = "never_type", since = "1.41.0")]
19391939
impl Debug for ! {
19401940
fn fmt(&self, _: &mut Formatter<'_>) -> Result {
19411941
*self
19421942
}
19431943
}
19441944

1945-
#[unstable(feature = "never_type", issue = "35121")]
1945+
#[stable(feature = "never_type", since = "1.41.0")]
19461946
impl Display for ! {
19471947
fn fmt(&self, _: &mut Formatter<'_>) -> Result {
19481948
*self

src/libcore/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
#![feature(iter_once_with)]
8686
#![feature(lang_items)]
8787
#![feature(link_llvm_intrinsics)]
88-
#![feature(never_type)]
88+
#![cfg_attr(bootstrap, feature(never_type))]
8989
#![feature(nll)]
9090
#![feature(exhaustive_patterns)]
9191
#![feature(no_core)]

src/libcore/marker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,7 @@ mod copy_impls {
774774
bool char
775775
}
776776

777-
#[unstable(feature = "never_type", issue = "35121")]
777+
#[stable(feature = "never_type", since = "1.41.0")]
778778
impl Copy for ! {}
779779

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

src/libcore/num/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4728,7 +4728,7 @@ impl From<Infallible> for TryFromIntError {
47284728
}
47294729
}
47304730

4731-
#[unstable(feature = "never_type", issue = "35121")]
4731+
#[stable(feature = "never_type", since = "1.41.0")]
47324732
impl From<!> for TryFromIntError {
47334733
fn from(never: !) -> TryFromIntError {
47344734
// Match rather than coerce to make sure that code like

src/librustc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
#![feature(core_intrinsics)]
3737
#![feature(drain_filter)]
3838
#![cfg_attr(windows, feature(libc))]
39-
#![feature(never_type)]
39+
#![cfg_attr(bootstrap, feature(never_type))]
4040
#![feature(exhaustive_patterns)]
4141
#![feature(overlapping_marker_traits)]
4242
#![feature(extern_types)]

src/librustc/ty/context.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -2440,11 +2440,7 @@ impl<'tcx> TyCtxt<'tcx> {
24402440

24412441
#[inline]
24422442
pub fn mk_diverging_default(self) -> Ty<'tcx> {
2443-
if self.features().never_type {
2444-
self.types.never
2445-
} else {
2446-
self.intern_tup(&[])
2447-
}
2443+
self.types.never
24482444
}
24492445

24502446
#[inline]

src/librustc_codegen_utils/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#![feature(box_patterns)]
99
#![feature(box_syntax)]
1010
#![feature(core_intrinsics)]
11-
#![feature(never_type)]
11+
#![cfg_attr(bootstrap, feature(never_type))]
1212
#![feature(nll)]
1313
#![feature(in_band_lifetimes)]
1414

src/librustc_error_codes/error_codes/E0725.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ command line flags.
44
Erroneous code example:
55

66
```ignore (can't specify compiler flags from doctests)
7-
#![feature(never_type)] // error: the feature `never_type` is not in
8-
// the list of allowed features
7+
#![feature(specialization)] // error: the feature `specialization` is not in
8+
// the list of allowed features
99
```
1010

1111
Delete the offending feature attribute, or add it to the list of allowed

src/librustc_mir/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
1616
#![feature(decl_macro)]
1717
#![feature(drain_filter)]
1818
#![feature(exhaustive_patterns)]
19-
#![feature(never_type)]
19+
#![cfg_attr(bootstrap, feature(never_type))]
2020
#![feature(specialization)]
2121
#![feature(try_trait)]
2222
#![feature(unicode_internals)]

src/librustc_typeck/check/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -3129,9 +3129,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
31293129
}
31303130

31313131
// Tries to apply a fallback to `ty` if it is an unsolved variable.
3132-
// Non-numerics get replaced with ! or () (depending on whether
3133-
// feature(never_type) is enabled, unconstrained ints with i32,
3134-
// unconstrained floats with f64.
3132+
// Non-numerics get replaced with `!`, unconstrained ints with `i32`,
3133+
// unconstrained floats with `f64`.
31353134
// Fallback becomes very dubious if we have encountered type-checking errors.
31363135
// In that case, fallback to Error.
31373136
// The return value indicates whether fallback has occurred.

src/librustc_typeck/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ This API is completely unstable and subject to change.
6666
#![feature(in_band_lifetimes)]
6767
#![feature(nll)]
6868
#![feature(slice_patterns)]
69-
#![feature(never_type)]
69+
#![cfg_attr(bootstrap, feature(never_type))]
7070

7171
#![recursion_limit="256"]
7272

src/librustdoc/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#![feature(crate_visibility_modifier)]
1515
#![feature(const_fn)]
1616
#![feature(drain_filter)]
17-
#![feature(never_type)]
17+
#![cfg_attr(bootstrap, feature(never_type))]
1818
#![feature(unicode_internals)]
1919

2020
#![recursion_limit="256"]

src/libserialize/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Core encoding and decoding interfaces.
1111
#![feature(box_syntax)]
1212
#![feature(core_intrinsics)]
1313
#![feature(specialization)]
14-
#![feature(never_type)]
14+
#![cfg_attr(bootstrap, feature(never_type))]
1515
#![feature(nll)]
1616
#![feature(associated_type_bounds)]
1717
#![cfg_attr(test, feature(test))]

src/libstd/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
465465
}
466466
}
467467

468-
#[unstable(feature = "never_type", issue = "35121")]
468+
#[stable(feature = "never_type", since = "1.41.0")]
469469
impl Error for ! {
470470
fn description(&self) -> &str { *self }
471471
}

src/libstd/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@
280280
#![feature(maybe_uninit_ref)]
281281
#![feature(maybe_uninit_slice)]
282282
#![feature(needs_panic_runtime)]
283-
#![feature(never_type)]
283+
#![cfg_attr(bootstrap, feature(never_type))]
284284
#![feature(nll)]
285285
#![cfg_attr(bootstrap, feature(on_unimplemented))]
286286
#![feature(optin_builtin_traits)]

src/libstd/primitive_docs.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ mod prim_bool { }
7171
/// write:
7272
///
7373
/// ```
74-
/// #![feature(never_type)]
7574
/// # fn foo() -> u32 {
7675
/// let x: ! = {
7776
/// return 123
@@ -201,7 +200,6 @@ mod prim_bool { }
201200
/// for example:
202201
///
203202
/// ```
204-
/// #![feature(never_type)]
205203
/// # use std::fmt;
206204
/// # trait Debug {
207205
/// # fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result;
@@ -239,7 +237,7 @@ mod prim_bool { }
239237
/// [`Default`]: default/trait.Default.html
240238
/// [`default()`]: default/trait.Default.html#tymethod.default
241239
///
242-
#[unstable(feature = "never_type", issue = "35121")]
240+
#[stable(feature = "never_type", since = "1.41.0")]
243241
mod prim_never { }
244242

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

src/libsyntax/feature_gate/accepted.rs

+2
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ declare_features! (
253253
(accepted, const_constructor, "1.40.0", Some(61456), None),
254254
/// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests.
255255
(accepted, cfg_doctest, "1.40.0", Some(62210), None),
256+
/// Allows the `!` type. Does not imply 'exhaustive_patterns' any more.
257+
(accepted, never_type, "1.41.0", Some(35121), None),
256258
/// Allows relaxing the coherence rules such that
257259
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
258260
(accepted, re_rebalance_coherence, "1.41.0", Some(55437), None),

src/libsyntax/feature_gate/active.rs

-3
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,6 @@ declare_features! (
318318
/// Allows `X..Y` patterns.
319319
(active, exclusive_range_pattern, "1.11.0", Some(37854), None),
320320

321-
/// Allows the `!` type. Does not imply 'exhaustive_patterns' (below) any more.
322-
(active, never_type, "1.13.0", Some(35121), None),
323-
324321
/// Allows exhaustive pattern matching on types that contain uninhabited types.
325322
(active, exhaustive_patterns, "1.13.0", Some(51085), None),
326323

src/libsyntax/feature_gate/check.rs

-18
Original file line numberDiff line numberDiff line change
@@ -521,25 +521,11 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
521521
ast::TyKind::BareFn(ref bare_fn_ty) => {
522522
self.check_extern(bare_fn_ty.ext);
523523
}
524-
ast::TyKind::Never => {
525-
gate_feature_post!(&self, never_type, ty.span,
526-
"The `!` type is experimental");
527-
}
528524
_ => {}
529525
}
530526
visit::walk_ty(self, ty)
531527
}
532528

533-
fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FunctionRetTy) {
534-
if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty {
535-
if let ast::TyKind::Never = output_ty.kind {
536-
// Do nothing.
537-
} else {
538-
self.visit_ty(output_ty)
539-
}
540-
}
541-
}
542-
543529
fn visit_expr(&mut self, e: &'a ast::Expr) {
544530
match e.kind {
545531
ast::ExprKind::Box(_) => {
@@ -567,10 +553,6 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
567553
visit::walk_expr(self, e)
568554
}
569555

570-
fn visit_arm(&mut self, arm: &'a ast::Arm) {
571-
visit::walk_arm(self, arm)
572-
}
573-
574556
fn visit_pat(&mut self, pattern: &'a ast::Pat) {
575557
match &pattern.kind {
576558
PatKind::Slice(pats) => {

0 commit comments

Comments
 (0)