Skip to content

Commit

Permalink
Revert "Stabilize the never_type, written !."
Browse files Browse the repository at this point in the history
This reverts commit 15c30dd.
  • Loading branch information
nikomatsakis committed Dec 14, 2019
1 parent 1719337 commit d286113
Show file tree
Hide file tree
Showing 19 changed files with 44 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/libcore/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ mod impls {
bool char
}

#[stable(feature = "never_type", since = "1.41.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Clone for ! {
#[inline]
fn clone(&self) -> Self {
Expand Down
8 changes: 4 additions & 4 deletions src/libcore/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,24 +1141,24 @@ mod impls {

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

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

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

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

#[stable(feature = "never_type", since = "1.41.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Ord for ! {
fn cmp(&self, _: &!) -> Ordering {
*self
Expand Down
4 changes: 2 additions & 2 deletions src/libcore/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1940,14 +1940,14 @@ macro_rules! fmt_refs {

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

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

#[stable(feature = "never_type", since = "1.41.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Display for ! {
fn fmt(&self, _: &mut Formatter<'_>) -> Result {
*self
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
#![feature(iter_once_with)]
#![feature(lang_items)]
#![feature(link_llvm_intrinsics)]
#![cfg_attr(bootstrap, feature(never_type))]
#![feature(never_type)]
#![feature(nll)]
#![feature(exhaustive_patterns)]
#![feature(no_core)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -776,7 +776,7 @@ mod copy_impls {
bool char
}

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

#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
2 changes: 1 addition & 1 deletion src/libcore/num/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4731,7 +4731,7 @@ impl From<Infallible> for TryFromIntError {
}
}

#[stable(feature = "never_type", since = "1.41.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl From<!> for TryFromIntError {
fn from(never: !) -> TryFromIntError {
// Match rather than coerce to make sure that code like
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
#![feature(core_intrinsics)]
#![feature(drain_filter)]
#![cfg_attr(windows, feature(libc))]
#![cfg_attr(bootstrap, feature(never_type))]
#![feature(never_type)]
#![feature(exhaustive_patterns)]
#![feature(overlapping_marker_traits)]
#![feature(extern_types)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_utils/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#![feature(box_patterns)]
#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![cfg_attr(bootstrap, feature(never_type))]
#![feature(never_type)]
#![feature(nll)]
#![feature(in_band_lifetimes)]

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_error_codes/error_codes/E0725.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ command line flags.
Erroneous code example:

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

Delete the offending feature attribute, or add it to the list of allowed
Expand Down
2 changes: 0 additions & 2 deletions src/librustc_feature/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,6 @@ declare_features! (
(accepted, const_constructor, "1.40.0", Some(61456), None),
/// Allows the use of `#[cfg(doctest)]`, set when rustdoc is collecting doctests.
(accepted, cfg_doctest, "1.40.0", Some(62210), None),
/// Allows the `!` type. Does not imply 'exhaustive_patterns' any more.
(accepted, never_type, "1.41.0", Some(35121), None),
/// Allows relaxing the coherence rules such that
/// `impl<T> ForeignTrait<LocalType> for ForeignType<T>` is permitted.
(accepted, re_rebalance_coherence, "1.41.0", Some(55437), None),
Expand Down
3 changes: 3 additions & 0 deletions src/librustc_feature/active.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,9 @@ declare_features! (
/// Allows `X..Y` patterns.
(active, exclusive_range_pattern, "1.11.0", Some(37854), None),

/// Allows the `!` type. Does not imply 'exhaustive_patterns' (below) any more.
(active, never_type, "1.13.0", Some(35121), None),

/// Allows exhaustive pattern matching on types that contain uninhabited types.
(active, exhaustive_patterns, "1.13.0", Some(51085), None),

Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Rust MIR: a lowered representation of Rust. Also: an experiment!
#![feature(drain_filter)]
#![feature(exhaustive_patterns)]
#![feature(iter_order_by)]
#![cfg_attr(bootstrap, feature(never_type))]
#![feature(never_type)]
#![feature(specialization)]
#![feature(try_trait)]
#![feature(unicode_internals)]
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ This API is completely unstable and subject to change.
#![feature(in_band_lifetimes)]
#![feature(nll)]
#![feature(slice_patterns)]
#![cfg_attr(bootstrap, feature(never_type))]
#![feature(never_type)]

#![recursion_limit="256"]

Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#![feature(crate_visibility_modifier)]
#![feature(const_fn)]
#![feature(drain_filter)]
#![cfg_attr(bootstrap, feature(never_type))]
#![feature(never_type)]
#![feature(unicode_internals)]

#![recursion_limit="256"]
Expand Down
2 changes: 1 addition & 1 deletion src/libserialize/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Core encoding and decoding interfaces.
#![feature(box_syntax)]
#![feature(core_intrinsics)]
#![feature(specialization)]
#![cfg_attr(bootstrap, feature(never_type))]
#![feature(never_type)]
#![feature(nll)]
#![feature(associated_type_bounds)]
#![cfg_attr(test, feature(test))]
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ impl<'a> From<Cow<'a, str>> for Box<dyn Error> {
}
}

#[stable(feature = "never_type", since = "1.41.0")]
#[unstable(feature = "never_type", issue = "35121")]
impl Error for ! {
fn description(&self) -> &str { *self }
}
Expand Down
2 changes: 1 addition & 1 deletion src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@
#![feature(maybe_uninit_ref)]
#![feature(maybe_uninit_slice)]
#![feature(needs_panic_runtime)]
#![cfg_attr(bootstrap, feature(never_type))]
#![feature(never_type)]
#![feature(nll)]
#![cfg_attr(bootstrap, feature(on_unimplemented))]
#![feature(optin_builtin_traits)]
Expand Down
4 changes: 3 additions & 1 deletion src/libstd/primitive_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ mod prim_bool { }
/// write:
///
/// ```
/// #![feature(never_type)]
/// # fn foo() -> u32 {
/// let x: ! = {
/// return 123
Expand Down Expand Up @@ -200,6 +201,7 @@ mod prim_bool { }
/// for example:
///
/// ```
/// #![feature(never_type)]
/// # use std::fmt;
/// # trait Debug {
/// # fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result;
Expand Down Expand Up @@ -237,7 +239,7 @@ mod prim_bool { }
/// [`Default`]: default/trait.Default.html
/// [`default()`]: default/trait.Default.html#tymethod.default
///
#[stable(feature = "never_type", since = "1.41.0")]
#[unstable(feature = "never_type", issue = "35121")]
mod prim_never { }

#[doc(primitive = "char")]
Expand Down
18 changes: 18 additions & 0 deletions src/libsyntax/feature_gate/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,11 +464,25 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
ast::TyKind::BareFn(ref bare_fn_ty) => {
self.check_extern(bare_fn_ty.ext);
}
ast::TyKind::Never => {
gate_feature_post!(&self, never_type, ty.span,
"The `!` type is experimental");
}
_ => {}
}
visit::walk_ty(self, ty)
}

fn visit_fn_ret_ty(&mut self, ret_ty: &'a ast::FunctionRetTy) {
if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty {
if let ast::TyKind::Never = output_ty.kind {
// Do nothing.
} else {
self.visit_ty(output_ty)
}
}
}

fn visit_expr(&mut self, e: &'a ast::Expr) {
match e.kind {
ast::ExprKind::Box(_) => {
Expand Down Expand Up @@ -499,6 +513,10 @@ impl<'a> Visitor<'a> for PostExpansionVisitor<'a> {
visit::walk_expr(self, e)
}

fn visit_arm(&mut self, arm: &'a ast::Arm) {
visit::walk_arm(self, arm)
}

fn visit_pat(&mut self, pattern: &'a ast::Pat) {
match &pattern.kind {
PatKind::Slice(pats) => {
Expand Down

0 comments on commit d286113

Please sign in to comment.