From fadabe08f52ce524a0cbb5af327e55db61198024 Mon Sep 17 00:00:00 2001 From: Andrew Cann Date: Tue, 2 Aug 2016 15:56:20 +0800 Subject: [PATCH] Rename empty/bang to never Split Ty::is_empty method into is_never and is_uninhabited --- src/libcore/cmp.rs | 8 ++--- src/libcore/fmt/mod.rs | 4 +-- src/libcore/lib.rs | 2 +- src/librustc/cfg/construct.rs | 3 +- src/librustc/hir/fold.rs | 2 +- src/librustc/hir/intravisit.rs | 2 +- src/librustc/hir/lowering.rs | 2 +- src/librustc/hir/mod.rs | 4 +-- src/librustc/hir/print.rs | 2 +- src/librustc/infer/freshen.rs | 2 +- src/librustc/middle/expr_use_visitor.rs | 2 +- src/librustc/middle/liveness.rs | 6 ++-- src/librustc/middle/mem_categorization.rs | 2 +- src/librustc/traits/coherence.rs | 2 +- src/librustc/traits/error_reporting.rs | 2 +- src/librustc/traits/select.rs | 6 ++-- src/librustc/ty/adjustment.rs | 11 +++--- src/librustc/ty/contents.rs | 2 +- src/librustc/ty/context.rs | 6 ++-- src/librustc/ty/error.rs | 2 +- src/librustc/ty/fast_reject.rs | 4 +-- src/librustc/ty/flags.rs | 2 +- src/librustc/ty/item_path.rs | 2 +- src/librustc/ty/layout.rs | 4 +-- src/librustc/ty/mod.rs | 2 +- src/librustc/ty/outlives.rs | 2 +- src/librustc/ty/relate.rs | 2 +- src/librustc/ty/structural_impls.rs | 4 +-- src/librustc/ty/sty.rs | 24 ++++++++----- src/librustc/ty/util.rs | 6 ++-- src/librustc/ty/walk.rs | 2 +- src/librustc/ty/wf.rs | 2 +- src/librustc/util/ppaux.rs | 8 ++--- src/librustc_const_eval/check_match.rs | 6 ++-- src/librustc_lint/types.rs | 2 +- src/librustc_lint/unused.rs | 2 +- src/librustc_metadata/astencode.rs | 8 ++--- src/librustc_metadata/tydecode.rs | 2 +- src/librustc_metadata/tyencode.rs | 2 +- src/librustc_mir/build/expr/as_lvalue.rs | 2 +- src/librustc_mir/build/expr/as_rvalue.rs | 2 +- src/librustc_mir/build/expr/category.rs | 2 +- src/librustc_mir/build/expr/into.rs | 5 +-- src/librustc_mir/hair/cx/expr.rs | 4 +-- src/librustc_mir/hair/mod.rs | 2 +- src/librustc_mir/transform/type_check.rs | 3 +- src/librustc_passes/consts.rs | 2 +- src/librustc_trans/_match.rs | 2 +- src/librustc_trans/callee.rs | 3 +- src/librustc_trans/collector.rs | 2 +- src/librustc_trans/common.rs | 2 +- src/librustc_trans/consts.rs | 4 +-- src/librustc_trans/debuginfo/metadata.rs | 6 ++-- src/librustc_trans/debuginfo/type_names.rs | 2 +- src/librustc_trans/declare.rs | 3 +- src/librustc_trans/expr.rs | 6 ++-- src/librustc_trans/trans_item.rs | 2 +- src/librustc_trans/type_of.rs | 4 +-- src/librustc_typeck/astconv.rs | 4 +-- src/librustc_typeck/check/coercion.rs | 8 ++--- src/librustc_typeck/check/dropck.rs | 2 +- src/librustc_typeck/check/intrinsic.rs | 2 +- src/librustc_typeck/check/mod.rs | 34 ++++++++++--------- src/librustc_typeck/check/wfcheck.rs | 2 +- src/librustc_typeck/check/writeback.rs | 4 +-- src/librustc_typeck/coherence/mod.rs | 4 +-- src/librustc_typeck/variance/constraints.rs | 2 +- src/librustdoc/clean/mod.rs | 7 ++-- src/librustdoc/html/format.rs | 2 +- src/libsyntax/ast.rs | 4 +-- src/libsyntax/feature_gate.rs | 8 ++--- src/libsyntax/fold.rs | 2 +- src/libsyntax/parse/parser.rs | 2 +- src/libsyntax/print/pprust.rs | 2 +- src/libsyntax/visit.rs | 2 +- .../{adjust_empty.rs => adjust_never.rs} | 4 +-- 76 files changed, 161 insertions(+), 150 deletions(-) rename src/test/run-fail/{adjust_empty.rs => adjust_never.rs} (95%) diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index 991f2df24789..bb7c97111185 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -703,24 +703,24 @@ mod impls { // that supports `!` macro_rules! not_stage0 { () => { - #[unstable(feature = "bang_type", issue = "35121")] + #[unstable(feature = "never_type", issue = "35121")] impl PartialEq for ! { fn eq(&self, _: &!) -> bool { *self } } - #[unstable(feature = "bang_type", issue = "35121")] + #[unstable(feature = "never_type", issue = "35121")] impl Eq for ! {} - #[unstable(feature = "bang_type", issue = "35121")] + #[unstable(feature = "never_type", issue = "35121")] impl PartialOrd for ! { fn partial_cmp(&self, _: &!) -> Option { *self } } - #[unstable(feature = "bang_type", issue = "35121")] + #[unstable(feature = "never_type", issue = "35121")] impl Ord for ! { fn cmp(&self, _: &!) -> Ordering { *self diff --git a/src/libcore/fmt/mod.rs b/src/libcore/fmt/mod.rs index 15fb950b143d..dbd715c722e1 100644 --- a/src/libcore/fmt/mod.rs +++ b/src/libcore/fmt/mod.rs @@ -1367,14 +1367,14 @@ fmt_refs! { Debug, Display, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperEx // that supports `!` macro_rules! not_stage0 { () => { - #[unstable(feature = "bang_type", issue = "35121")] + #[unstable(feature = "never_type", issue = "35121")] impl Debug for ! { fn fmt(&self, _: &mut Formatter) -> Result { *self } } - #[unstable(feature = "bang_type", issue = "35121")] + #[unstable(feature = "never_type", issue = "35121")] impl Display for ! { fn fmt(&self, _: &mut Formatter) -> Result { *self diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index d05036c97a67..7831464756b9 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -89,7 +89,7 @@ #![feature(question_mark)] // NOTE: remove the cfg_attr next snapshot -#![cfg_attr(not(stage0), feature(bang_type))] +#![cfg_attr(not(stage0), feature(never_type))] #[macro_use] mod macros; diff --git a/src/librustc/cfg/construct.rs b/src/librustc/cfg/construct.rs index b3f7af77691f..232db76a6d17 100644 --- a/src/librustc/cfg/construct.rs +++ b/src/librustc/cfg/construct.rs @@ -379,7 +379,8 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { let func_or_rcvr_exit = self.expr(func_or_rcvr, pred); let ret = self.straightline(call_expr, func_or_rcvr_exit, args); - if fn_ty.fn_ret().0.is_empty(self.tcx) { + // FIXME(canndrew): This is_never should probably be an is_uninhabited. + if fn_ty.fn_ret().0.is_never() { self.add_unreachable_node() } else { ret diff --git a/src/librustc/hir/fold.rs b/src/librustc/hir/fold.rs index d8b39f1f9587..0edfd16bdfd1 100644 --- a/src/librustc/hir/fold.rs +++ b/src/librustc/hir/fold.rs @@ -353,7 +353,7 @@ pub fn noop_fold_ty(t: P, fld: &mut T) -> P { } })) } - TyEmpty => node, + TyNever => node, TyTup(tys) => TyTup(tys.move_map(|ty| fld.fold_ty(ty))), TyPath(qself, path) => { let qself = qself.map(|QSelf { ty, position }| { diff --git a/src/librustc/hir/intravisit.rs b/src/librustc/hir/intravisit.rs index 0c24d1315f1a..92b956788860 100644 --- a/src/librustc/hir/intravisit.rs +++ b/src/librustc/hir/intravisit.rs @@ -403,7 +403,7 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { walk_list!(visitor, visit_lifetime, opt_lifetime); visitor.visit_ty(&mutable_type.ty) } - TyEmpty => {}, + TyNever => {}, TyTup(ref tuple_element_types) => { walk_list!(visitor, visit_ty, tuple_element_types); } diff --git a/src/librustc/hir/lowering.rs b/src/librustc/hir/lowering.rs index 45eaca4100b7..c2b211238b2f 100644 --- a/src/librustc/hir/lowering.rs +++ b/src/librustc/hir/lowering.rs @@ -270,7 +270,7 @@ impl<'a> LoweringContext<'a> { decl: self.lower_fn_decl(&f.decl), })) } - Empty => hir::TyEmpty, + Never => hir::TyNever, Tup(ref tys) => hir::TyTup(tys.iter().map(|ty| self.lower_ty(ty)).collect()), Paren(ref ty) => { return self.lower_ty(ty); diff --git a/src/librustc/hir/mod.rs b/src/librustc/hir/mod.rs index d726625f2fcc..d41cdfabdf4c 100644 --- a/src/librustc/hir/mod.rs +++ b/src/librustc/hir/mod.rs @@ -1122,8 +1122,8 @@ pub enum Ty_ { TyRptr(Option, MutTy), /// A bare function (e.g. `fn(usize) -> bool`) TyBareFn(P), - /// The empty type (`!`) - TyEmpty, + /// The never type (`!`) + TyNever, /// A tuple (`(A, B, C, D,...)`) TyTup(HirVec>), /// A path (`module::module::...::Type`), optionally diff --git a/src/librustc/hir/print.rs b/src/librustc/hir/print.rs index 20d069c126df..66c1bc7642c5 100644 --- a/src/librustc/hir/print.rs +++ b/src/librustc/hir/print.rs @@ -504,7 +504,7 @@ impl<'a> State<'a> { self.print_opt_lifetime(lifetime)?; self.print_mt(mt)?; } - hir::TyEmpty => { + hir::TyNever => { word(&mut self.s, "!")?; }, hir::TyTup(ref elts) => { diff --git a/src/librustc/infer/freshen.rs b/src/librustc/infer/freshen.rs index 7e7953aa258f..ecd9759c721b 100644 --- a/src/librustc/infer/freshen.rs +++ b/src/librustc/infer/freshen.rs @@ -168,7 +168,7 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for TypeFreshener<'a, 'gcx, 'tcx> { ty::TyTrait(..) | ty::TyStruct(..) | ty::TyClosure(..) | - ty::TyEmpty | + ty::TyNever | ty::TyTuple(..) | ty::TyProjection(..) | ty::TyParam(..) | diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 4980b3abc63f..87463055a276 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -717,7 +717,7 @@ impl<'a, 'gcx, 'tcx> ExprUseVisitor<'a, 'gcx, 'tcx> { let adj = infcx.adjustments().get(&expr.id).map(|x| x.clone()); if let Some(adjustment) = adj { match adjustment { - adjustment::AdjustEmptyToAny(..) | + adjustment::AdjustNeverToAny(..) | adjustment::AdjustReifyFnPointer | adjustment::AdjustUnsafeFnPointer | adjustment::AdjustMutToConstPointer => { diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index e9c28f3782b0..74d29b273ff2 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -1111,8 +1111,9 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { } hir::ExprCall(ref f, ref args) => { + // FIXME(canndrew): This is_never should really be an is_uninhabited let diverges = !self.ir.tcx.is_method_call(expr.id) && - self.ir.tcx.expr_ty_adjusted(&f).fn_ret().0.is_empty(self.ir.tcx); + self.ir.tcx.expr_ty_adjusted(&f).fn_ret().0.is_never(); let succ = if diverges { self.s.exit_ln } else { @@ -1125,7 +1126,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { hir::ExprMethodCall(_, _, ref args) => { let method_call = ty::MethodCall::expr(expr.id); let method_ty = self.ir.tcx.tables.borrow().method_map[&method_call].ty; - let succ = if method_ty.fn_ret().0.is_empty(self.ir.tcx) { + // FIXME(canndrew): This is_never should really be an is_uninhabited + let succ = if method_ty.fn_ret().0.is_never() { self.s.exit_ln } else { succ diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index bee17c31248d..676e456dcea9 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -451,7 +451,7 @@ impl<'a, 'gcx, 'tcx> MemCategorizationContext<'a, 'gcx, 'tcx> { self.cat_expr_autoderefd(expr, autoderefs) } - adjustment::AdjustEmptyToAny(..) | + adjustment::AdjustNeverToAny(..) | adjustment::AdjustReifyFnPointer | adjustment::AdjustUnsafeFnPointer | adjustment::AdjustMutToConstPointer | diff --git a/src/librustc/traits/coherence.rs b/src/librustc/traits/coherence.rs index 291c7c6426a4..b38f5f96de44 100644 --- a/src/librustc/traits/coherence.rs +++ b/src/librustc/traits/coherence.rs @@ -253,7 +253,7 @@ fn ty_is_local_constructor(tcx: TyCtxt, ty: Ty, infer_is_local: InferIsLocal)-> ty::TySlice(..) | ty::TyRawPtr(..) | ty::TyRef(..) | - ty::TyEmpty | + ty::TyNever | ty::TyTuple(..) | ty::TyParam(..) | ty::TyProjection(..) => { diff --git a/src/librustc/traits/error_reporting.rs b/src/librustc/traits/error_reporting.rs index 4ee173fbb1c5..cf004767b2aa 100644 --- a/src/librustc/traits/error_reporting.rs +++ b/src/librustc/traits/error_reporting.rs @@ -212,7 +212,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ty::TyProjection(..) => Some(13), ty::TyParam(..) => Some(14), ty::TyAnon(..) => Some(15), - ty::TyEmpty => Some(16), + ty::TyNever => Some(16), ty::TyInfer(..) | ty::TyError => None } } diff --git a/src/librustc/traits/select.rs b/src/librustc/traits/select.rs index d535606d1b63..b61cb0d3eee7 100644 --- a/src/librustc/traits/select.rs +++ b/src/librustc/traits/select.rs @@ -1772,7 +1772,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) | ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyRawPtr(..) | ty::TyChar | ty::TyBox(_) | ty::TyRef(..) | - ty::TyArray(..) | ty::TyClosure(..) | ty::TyEmpty | + ty::TyArray(..) | ty::TyClosure(..) | ty::TyNever | ty::TyError => { // safe for everything Where(ty::Binder(Vec::new())) @@ -1820,7 +1820,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { ty::TyInfer(ty::IntVar(_)) | ty::TyInfer(ty::FloatVar(_)) | ty::TyUint(_) | ty::TyInt(_) | ty::TyBool | ty::TyFloat(_) | ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyChar | - ty::TyRawPtr(..) | ty::TyError | ty::TyEmpty | + ty::TyRawPtr(..) | ty::TyError | ty::TyNever | ty::TyRef(_, ty::TypeAndMut { ty: _, mutbl: hir::MutImmutable }) => { Where(ty::Binder(Vec::new())) } @@ -1886,7 +1886,7 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> { ty::TyError | ty::TyInfer(ty::IntVar(_)) | ty::TyInfer(ty::FloatVar(_)) | - ty::TyEmpty | + ty::TyNever | ty::TyChar => { Vec::new() } diff --git a/src/librustc/ty/adjustment.rs b/src/librustc/ty/adjustment.rs index dc4bdda0cf09..ae9fd5ab5bc8 100644 --- a/src/librustc/ty/adjustment.rs +++ b/src/librustc/ty/adjustment.rs @@ -11,7 +11,7 @@ pub use self::AutoAdjustment::*; pub use self::AutoRef::*; -use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFoldable, TypeVariants}; +use ty::{self, Ty, TyCtxt, TypeAndMut, TypeFoldable}; use ty::LvaluePreference::{NoPreference}; use syntax::ast; @@ -21,7 +21,7 @@ use hir; #[derive(Copy, Clone)] pub enum AutoAdjustment<'tcx> { - AdjustEmptyToAny(Ty<'tcx>), // go from ! to any type + AdjustNeverToAny(Ty<'tcx>), // go from ! to any type AdjustReifyFnPointer, // go from a fn-item type to a fn-pointer type AdjustUnsafeFnPointer, // go from a safe fn pointer to an unsafe fn pointer AdjustMutToConstPointer, // go from a mut raw pointer to a const raw pointer @@ -107,10 +107,7 @@ pub struct AutoDerefRef<'tcx> { impl<'tcx> AutoAdjustment<'tcx> { pub fn is_identity(&self) -> bool { match *self { - AdjustEmptyToAny(ty) => match ty.sty { - TypeVariants::TyEmpty => true, - _ => false, - }, + AdjustNeverToAny(ty) => ty.is_never(), AdjustReifyFnPointer | AdjustUnsafeFnPointer | AdjustMutToConstPointer => false, @@ -159,7 +156,7 @@ impl<'a, 'gcx, 'tcx> ty::TyS<'tcx> { return match adjustment { Some(adjustment) => { match *adjustment { - AdjustEmptyToAny(ref ty) => ty, + AdjustNeverToAny(ref ty) => ty, AdjustReifyFnPointer => { match self.sty { diff --git a/src/librustc/ty/contents.rs b/src/librustc/ty/contents.rs index 67a2624eaad6..53bf046d6b59 100644 --- a/src/librustc/ty/contents.rs +++ b/src/librustc/ty/contents.rs @@ -185,7 +185,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> { // Scalar and unique types are sendable, and durable ty::TyInfer(ty::FreshIntTy(_)) | ty::TyInfer(ty::FreshFloatTy(_)) | - ty::TyBool | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::TyEmpty | + ty::TyBool | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::TyNever | ty::TyFnDef(..) | ty::TyFnPtr(_) | ty::TyChar => { TC::None } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index 206de733606d..8ca02eaabe6a 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -190,7 +190,7 @@ pub struct CommonTypes<'tcx> { pub u64: Ty<'tcx>, pub f32: Ty<'tcx>, pub f64: Ty<'tcx>, - pub empty: Ty<'tcx>, + pub never: Ty<'tcx>, pub err: Ty<'tcx>, } @@ -257,7 +257,7 @@ impl<'tcx> CommonTypes<'tcx> { CommonTypes { bool: mk(TyBool), char: mk(TyChar), - empty: mk(TyEmpty), + never: mk(TyNever), err: mk(TyError), isize: mk(TyInt(ast::IntTy::Is)), i8: mk(TyInt(ast::IntTy::I8)), @@ -977,7 +977,7 @@ macro_rules! sty_debug_print { for &Interned(t) in tcx.interners.type_.borrow().iter() { let variant = match t.sty { ty::TyBool | ty::TyChar | ty::TyInt(..) | ty::TyUint(..) | - ty::TyFloat(..) | ty::TyStr | ty::TyEmpty => continue, + ty::TyFloat(..) | ty::TyStr | ty::TyNever => continue, ty::TyError => /* unimportant */ continue, $(ty::$variant(..) => &mut $variant,)* }; diff --git a/src/librustc/ty/error.rs b/src/librustc/ty/error.rs index e43b23ef3c45..dab9c246d5f1 100644 --- a/src/librustc/ty/error.rs +++ b/src/librustc/ty/error.rs @@ -214,7 +214,7 @@ impl<'a, 'gcx, 'lcx, 'tcx> ty::TyS<'tcx> { fn sort_string(&self, tcx: TyCtxt<'a, 'gcx, 'lcx>) -> String { match self.sty { ty::TyBool | ty::TyChar | ty::TyInt(_) | - ty::TyUint(_) | ty::TyFloat(_) | ty::TyStr | ty::TyEmpty => self.to_string(), + ty::TyUint(_) | ty::TyFloat(_) | ty::TyStr | ty::TyNever => self.to_string(), ty::TyTuple(ref tys) if tys.is_empty() => self.to_string(), ty::TyEnum(def, _) => format!("enum `{}`", tcx.item_path_str(def.did)), diff --git a/src/librustc/ty/fast_reject.rs b/src/librustc/ty/fast_reject.rs index a90c90e99ed5..9bf2daeb5f49 100644 --- a/src/librustc/ty/fast_reject.rs +++ b/src/librustc/ty/fast_reject.rs @@ -26,7 +26,7 @@ pub enum SimplifiedType { StrSimplifiedType, VecSimplifiedType, PtrSimplifiedType, - EmptySimplifiedType, + NeverSimplifiedType, TupleSimplifiedType(usize), TraitSimplifiedType(DefId), StructSimplifiedType(DefId), @@ -82,7 +82,7 @@ pub fn simplify_type<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, ty::TyClosure(def_id, _) => { Some(ClosureSimplifiedType(def_id)) } - ty::TyEmpty => Some(EmptySimplifiedType), + ty::TyNever => Some(NeverSimplifiedType), ty::TyTuple(ref tys) => { Some(TupleSimplifiedType(tys.len())) } diff --git a/src/librustc/ty/flags.rs b/src/librustc/ty/flags.rs index fa38bacba2ed..0997d6c1a756 100644 --- a/src/librustc/ty/flags.rs +++ b/src/librustc/ty/flags.rs @@ -60,7 +60,7 @@ impl FlagComputation { &ty::TyInt(_) | &ty::TyFloat(_) | &ty::TyUint(_) | - &ty::TyEmpty | + &ty::TyNever | &ty::TyStr => { } diff --git a/src/librustc/ty/item_path.rs b/src/librustc/ty/item_path.rs index a31893707075..8ddd8bef36a6 100644 --- a/src/librustc/ty/item_path.rs +++ b/src/librustc/ty/item_path.rs @@ -349,7 +349,7 @@ pub fn characteristic_def_id_of_type(ty: Ty) -> Option { ty::TyAnon(..) | ty::TyInfer(_) | ty::TyError | - ty::TyEmpty | + ty::TyNever | ty::TyFloat(_) => None, } } diff --git a/src/librustc/ty/layout.rs b/src/librustc/ty/layout.rs index 79631bff9647..195cece6bc4e 100644 --- a/src/librustc/ty/layout.rs +++ b/src/librustc/ty/layout.rs @@ -795,8 +795,8 @@ impl<'a, 'gcx, 'tcx> Layout { ty::TyFloat(FloatTy::F64) => Scalar { value: F64, non_zero: false }, ty::TyFnPtr(_) => Scalar { value: Pointer, non_zero: true }, - // The empty type. - ty::TyEmpty => Univariant { variant: Struct::new(dl, false), non_zero: false }, + // The never type. + ty::TyNever => Univariant { variant: Struct::new(dl, false), non_zero: false }, // Potentially-fat pointers. ty::TyBox(pointee) | diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 60d819bdad93..cfc2e89f9d5a 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -1853,7 +1853,7 @@ impl<'a, 'tcx> AdtDefData<'tcx, 'tcx> { let result = match ty.sty { TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) | TyBox(..) | TyRawPtr(..) | TyRef(..) | TyFnDef(..) | TyFnPtr(_) | - TyArray(..) | TyClosure(..) | TyEmpty => { + TyArray(..) | TyClosure(..) | TyNever => { vec![] } diff --git a/src/librustc/ty/outlives.rs b/src/librustc/ty/outlives.rs index bc90c18856fc..ee431681ad10 100644 --- a/src/librustc/ty/outlives.rs +++ b/src/librustc/ty/outlives.rs @@ -171,7 +171,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> { ty::TyInt(..) | // OutlivesScalar ty::TyUint(..) | // OutlivesScalar ty::TyFloat(..) | // OutlivesScalar - ty::TyEmpty | // ... + ty::TyNever | // ... ty::TyEnum(..) | // OutlivesNominalType ty::TyStruct(..) | // OutlivesNominalType ty::TyBox(..) | // OutlivesNominalType (ish) diff --git a/src/librustc/ty/relate.rs b/src/librustc/ty/relate.rs index 1997eac9728f..05a9b8111570 100644 --- a/src/librustc/ty/relate.rs +++ b/src/librustc/ty/relate.rs @@ -453,7 +453,7 @@ pub fn super_relate_tys<'a, 'gcx, 'tcx, R>(relation: &mut R, Ok(tcx.types.err) } - (&ty::TyEmpty, _) | + (&ty::TyNever, _) | (&ty::TyChar, _) | (&ty::TyBool, _) | (&ty::TyInt(_), _) | diff --git a/src/librustc/ty/structural_impls.rs b/src/librustc/ty/structural_impls.rs index 840703afd6f6..83413d16ffb3 100644 --- a/src/librustc/ty/structural_impls.rs +++ b/src/librustc/ty/structural_impls.rs @@ -486,7 +486,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { ty::TyAnon(did, substs) => ty::TyAnon(did, substs.fold_with(folder)), ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) | - ty::TyParam(..) | ty::TyEmpty => self.sty.clone(), + ty::TyParam(..) | ty::TyNever => self.sty.clone(), }; folder.tcx().mk_ty(sty) } @@ -515,7 +515,7 @@ impl<'tcx> TypeFoldable<'tcx> for Ty<'tcx> { ty::TyAnon(_, ref substs) => substs.visit_with(visitor), ty::TyBool | ty::TyChar | ty::TyStr | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | ty::TyError | ty::TyInfer(_) | - ty::TyParam(..) | ty::TyEmpty => false, + ty::TyParam(..) | ty::TyNever => false, } } diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index fec2c3b5ae56..8d9bd7a58af0 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -158,8 +158,8 @@ pub enum TypeVariants<'tcx> { /// `|a| a`. TyClosure(DefId, ClosureSubsts<'tcx>), - /// The empty type `!` - TyEmpty, + /// The never type `!` + TyNever, /// A tuple type. For example, `(i32, bool)`. TyTuple(&'tcx [Ty<'tcx>]), @@ -894,14 +894,22 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { } } - pub fn is_empty(&self, cx: TyCtxt) -> bool { - // FIXME(#24885): be smarter here + pub fn is_never(&self) -> bool { + match self.sty { + TyNever => true, + _ => false, + } + } + + pub fn is_uninhabited(&self, cx: TyCtxt) -> bool { + // FIXME(#24885): be smarter here, the AdtDefData::is_empty method could easily be made + // more complete. match self.sty { TyEnum(def, _) | TyStruct(def, _) => def.is_empty(), - TyEmpty => true, - TyTuple(ref tys) => tys.iter().any(|ty| ty.is_empty(cx)), + TyNever => true, + TyTuple(ref tys) => tys.iter().any(|ty| ty.is_uninhabited(cx)), // FIXME (canndrew): this line breaks core::fmt - //TyRef(_, ref tm) => tm.ty.is_empty(cx), + //TyRef(_, ref tm) => tm.ty.is_uninhabited(cx), _ => false, } } @@ -1225,7 +1233,7 @@ impl<'a, 'gcx, 'tcx> TyS<'tcx> { TyArray(_, _) | TySlice(_) | TyRawPtr(_) | - TyEmpty | + TyNever | TyTuple(_) | TyParam(_) | TyInfer(_) | diff --git a/src/librustc/ty/util.rs b/src/librustc/ty/util.rs index eae97a9c49ec..d7bb8ff2995a 100644 --- a/src/librustc/ty/util.rs +++ b/src/librustc/ty/util.rs @@ -485,7 +485,7 @@ impl<'a, 'gcx, 'tcx> TypeVisitor<'tcx> for TypeIdHasher<'a, 'gcx, 'tcx> { self.def_id(data.trait_ref.def_id); self.hash(data.item_name.as_str()); } - TyEmpty | + TyNever | TyBool | TyChar | TyStr | @@ -551,7 +551,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> { // Fast-path for primitive types let result = match self.sty { - TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) | TyEmpty | + TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) | TyNever | TyRawPtr(..) | TyFnDef(..) | TyFnPtr(_) | TyRef(_, TypeAndMut { mutbl: hir::MutImmutable, .. }) => Some(false), @@ -597,7 +597,7 @@ impl<'a, 'tcx> ty::TyS<'tcx> { let result = match self.sty { TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) | TyBox(..) | TyRawPtr(..) | TyRef(..) | TyFnDef(..) | TyFnPtr(_) | - TyArray(..) | TyTuple(..) | TyClosure(..) | TyEmpty => Some(true), + TyArray(..) | TyTuple(..) | TyClosure(..) | TyNever => Some(true), TyStr | TyTrait(..) | TySlice(_) => Some(false), diff --git a/src/librustc/ty/walk.rs b/src/librustc/ty/walk.rs index fef1e7a164ca..9c1f9d9537a4 100644 --- a/src/librustc/ty/walk.rs +++ b/src/librustc/ty/walk.rs @@ -70,7 +70,7 @@ pub fn walk_shallow<'tcx>(ty: Ty<'tcx>) -> IntoIter> { fn push_subtypes<'tcx>(stack: &mut Vec>, parent_ty: Ty<'tcx>) { match parent_ty.sty { ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | ty::TyFloat(_) | - ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyEmpty | ty::TyError => { + ty::TyStr | ty::TyInfer(_) | ty::TyParam(_) | ty::TyNever | ty::TyError => { } ty::TyBox(ty) | ty::TyArray(ty, _) | ty::TySlice(ty) => { stack.push(ty); diff --git a/src/librustc/ty/wf.rs b/src/librustc/ty/wf.rs index 6e138db74c97..bfc2e11d9fbc 100644 --- a/src/librustc/ty/wf.rs +++ b/src/librustc/ty/wf.rs @@ -321,7 +321,7 @@ impl<'a, 'gcx, 'tcx> WfPredicates<'a, 'gcx, 'tcx> { ty::TyFloat(..) | ty::TyError | ty::TyStr | - ty::TyEmpty | + ty::TyNever | ty::TyParam(_) => { // WfScalar, WfParameter, etc } diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 90ebf58f8615..896ef49de6f0 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -14,7 +14,7 @@ use ty::subst::{self, Subst}; use ty::{BrAnon, BrEnv, BrFresh, BrNamed}; use ty::{TyBool, TyChar, TyStruct, TyEnum}; use ty::{TyError, TyStr, TyArray, TySlice, TyFloat, TyFnDef, TyFnPtr}; -use ty::{TyParam, TyRawPtr, TyRef, TyEmpty, TyTuple}; +use ty::{TyParam, TyRawPtr, TyRef, TyNever, TyTuple}; use ty::TyClosure; use ty::{TyBox, TyTrait, TyInt, TyUint, TyInfer}; use ty::{self, Ty, TyCtxt, TypeFoldable}; @@ -422,8 +422,8 @@ impl<'tcx, 'container> fmt::Debug for ty::AdtDefData<'tcx, 'container> { impl<'tcx> fmt::Debug for ty::adjustment::AutoAdjustment<'tcx> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { - ty::adjustment::AdjustEmptyToAny(ref target) => { - write!(f, "AdjustEmptyToAny({:?})", target) + ty::adjustment::AdjustNeverToAny(ref target) => { + write!(f, "AdjustNeverToAny({:?})", target) } ty::adjustment::AdjustReifyFnPointer => { write!(f, "AdjustReifyFnPointer") @@ -843,7 +843,7 @@ impl<'tcx> fmt::Display for ty::TypeVariants<'tcx> { } write!(f, "{}", tm) } - TyEmpty => write!(f, "!"), + TyNever => write!(f, "!"), TyTuple(ref tys) => { write!(f, "(")?; let mut tys = tys.iter(); diff --git a/src/librustc_const_eval/check_match.rs b/src/librustc_const_eval/check_match.rs index 3e88dec8cb27..d80e152248fc 100644 --- a/src/librustc_const_eval/check_match.rs +++ b/src/librustc_const_eval/check_match.rs @@ -215,17 +215,17 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &hir::Expr) { // Check for empty enum, because is_useful only works on inhabited types. let pat_ty = cx.tcx.node_id_to_type(scrut.id); if inlined_arms.is_empty() { - if !pat_ty.is_empty(cx.tcx) { + if !pat_ty.is_uninhabited(cx.tcx) { // We know the type is inhabited, so this must be wrong let mut err = struct_span_err!(cx.tcx.sess, ex.span, E0002, - "non-exhaustive patterns: type {} is non-empty", + "non-exhaustive patterns: type {} is inhabited", pat_ty); span_help!(&mut err, ex.span, "Please ensure that all possible cases are being handled; \ possibly adding wildcards or more match arms."); err.emit(); } - // If the type *is* empty, it's vacuously exhaustive + // If the type *is* uninhabited, it's vacuously exhaustive return; } diff --git a/src/librustc_lint/types.rs b/src/librustc_lint/types.rs index 0ac12d77b1d9..99df5c6e5f95 100644 --- a/src/librustc_lint/types.rs +++ b/src/librustc_lint/types.rs @@ -523,7 +523,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> { // Primitive types with a stable representation. ty::TyBool | ty::TyInt(..) | ty::TyUint(..) | - ty::TyFloat(..) | ty::TyEmpty => FfiSafe, + ty::TyFloat(..) | ty::TyNever => FfiSafe, ty::TyBox(..) => { FfiUnsafe("found Rust type Box<_> in foreign module, \ diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index cd24de6a0a74..57705301aab4 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -133,7 +133,7 @@ impl LateLintPass for UnusedResults { let t = cx.tcx.expr_ty(&expr); let warned = match t.sty { ty::TyTuple(ref tys) if tys.is_empty() => return, - ty::TyEmpty => return, + ty::TyNever => return, ty::TyBool => return, ty::TyStruct(def, _) | ty::TyEnum(def, _) => { diff --git a/src/librustc_metadata/astencode.rs b/src/librustc_metadata/astencode.rs index 99d5758076fd..b8e66530ea15 100644 --- a/src/librustc_metadata/astencode.rs +++ b/src/librustc_metadata/astencode.rs @@ -645,8 +645,8 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> { }) } - adjustment::AdjustEmptyToAny(ref ty) => { - this.emit_enum_variant("AdjustEmptyToAny", 5, 1, |this| { + adjustment::AdjustNeverToAny(ref ty) => { + this.emit_enum_variant("AdjustNeverToAny", 5, 1, |this| { this.emit_enum_variant_arg(0, |this| Ok(this.emit_ty(ecx, ty))) }) } @@ -1024,7 +1024,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { self.read_enum("AutoAdjustment", |this| { let variants = ["AdjustReifyFnPointer", "AdjustUnsafeFnPointer", "AdjustMutToConstPointer", "AdjustDerefRef", - "AdjustEmptyToAny"]; + "AdjustNeverToAny"]; this.read_enum_variant(&variants, |this, i| { Ok(match i { 1 => adjustment::AdjustReifyFnPointer, @@ -1042,7 +1042,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> { Ok(this.read_ty(dcx)) }).unwrap(); - adjustment::AdjustEmptyToAny(ty) + adjustment::AdjustNeverToAny(ty) } _ => bug!("bad enum variant for adjustment::AutoAdjustment") }) diff --git a/src/librustc_metadata/tydecode.rs b/src/librustc_metadata/tydecode.rs index 29dd9ba8b1b9..7b4919bb4773 100644 --- a/src/librustc_metadata/tydecode.rs +++ b/src/librustc_metadata/tydecode.rs @@ -311,7 +311,7 @@ impl<'a,'tcx> TyDecoder<'a,'tcx> { let tcx = self.tcx; match self.next() { 'b' => return tcx.types.bool, - '!' => return tcx.types.empty, + '!' => return tcx.types.never, 'i' => { /* eat the s of is */ self.next(); return tcx.types.isize }, 'u' => { /* eat the s of us */ self.next(); return tcx.types.usize }, 'M' => { diff --git a/src/librustc_metadata/tyencode.rs b/src/librustc_metadata/tyencode.rs index 762a163da93b..15bafcdd3c99 100644 --- a/src/librustc_metadata/tyencode.rs +++ b/src/librustc_metadata/tyencode.rs @@ -74,7 +74,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut Cursor>, cx: &ctxt<'a, 'tcx>, t: Ty<'tcx match t.sty { ty::TyBool => { write!(w, "b"); } ty::TyChar => { write!(w, "c"); } - ty::TyEmpty => { write!(w, "!"); } + ty::TyNever => { write!(w, "!"); } ty::TyInt(t) => { match t { ast::IntTy::Is => write!(w, "is"), diff --git a/src/librustc_mir/build/expr/as_lvalue.rs b/src/librustc_mir/build/expr/as_lvalue.rs index 420147d037c5..ae5ccbfd8209 100644 --- a/src/librustc_mir/build/expr/as_lvalue.rs +++ b/src/librustc_mir/build/expr/as_lvalue.rs @@ -96,7 +96,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ExprKind::LogicalOp { .. } | ExprKind::Box { .. } | ExprKind::Cast { .. } | - ExprKind::EmptyToAny { .. } | + ExprKind::NeverToAny { .. } | ExprKind::ReifyFnPointer { .. } | ExprKind::UnsafeFnPointer { .. } | ExprKind::Unsize { .. } | diff --git a/src/librustc_mir/build/expr/as_rvalue.rs b/src/librustc_mir/build/expr/as_rvalue.rs index 5cf00a195dc2..dafc53d3c154 100644 --- a/src/librustc_mir/build/expr/as_rvalue.rs +++ b/src/librustc_mir/build/expr/as_rvalue.rs @@ -219,7 +219,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ExprKind::Block { .. } | ExprKind::Match { .. } | ExprKind::If { .. } | - ExprKind::EmptyToAny { .. } | + ExprKind::NeverToAny { .. } | ExprKind::Loop { .. } | ExprKind::LogicalOp { .. } | ExprKind::Call { .. } | diff --git a/src/librustc_mir/build/expr/category.rs b/src/librustc_mir/build/expr/category.rs index fb5be8e7d1cb..c19ea0f445ac 100644 --- a/src/librustc_mir/build/expr/category.rs +++ b/src/librustc_mir/build/expr/category.rs @@ -56,7 +56,7 @@ impl Category { ExprKind::LogicalOp { .. } | ExprKind::If { .. } | ExprKind::Match { .. } | - ExprKind::EmptyToAny { .. } | + ExprKind::NeverToAny { .. } | ExprKind::Call { .. } => Some(Category::Rvalue(RvalueFunc::Into)), diff --git a/src/librustc_mir/build/expr/into.rs b/src/librustc_mir/build/expr/into.rs index b8044a24cbfc..e5930f5a62df 100644 --- a/src/librustc_mir/build/expr/into.rs +++ b/src/librustc_mir/build/expr/into.rs @@ -45,7 +45,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ExprKind::Match { discriminant, arms } => { this.match_expr(destination, expr_span, block, discriminant, arms) } - ExprKind::EmptyToAny { source } => { + ExprKind::NeverToAny { source } => { let source = this.hir.mirror(source); let is_call = match source.kind { ExprKind::Call { .. } => true, @@ -209,7 +209,8 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> { ExprKind::Call { ty, fun, args } => { let diverges = match ty.sty { ty::TyFnDef(_, _, ref f) | ty::TyFnPtr(ref f) => { - f.sig.0.output.is_empty(this.hir.tcx()) + // FIXME(canndrew): This is_never should probably be an is_uninhabited + f.sig.0.output.is_never() } _ => false }; diff --git a/src/librustc_mir/hair/cx/expr.rs b/src/librustc_mir/hair/cx/expr.rs index bb6e9ba823ca..8a6a33decd64 100644 --- a/src/librustc_mir/hair/cx/expr.rs +++ b/src/librustc_mir/hair/cx/expr.rs @@ -60,13 +60,13 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr { kind: ExprKind::UnsafeFnPointer { source: expr.to_ref() }, }; } - Some(&ty::adjustment::AdjustEmptyToAny(..)) => { + Some(&ty::adjustment::AdjustNeverToAny(..)) => { let adjusted_ty = cx.tcx.expr_ty_adjusted(self); expr = Expr { temp_lifetime: temp_lifetime, ty: adjusted_ty, span: self.span, - kind: ExprKind::EmptyToAny { source: expr.to_ref() }, + kind: ExprKind::NeverToAny { source: expr.to_ref() }, }; } Some(&ty::adjustment::AdjustMutToConstPointer) => { diff --git a/src/librustc_mir/hair/mod.rs b/src/librustc_mir/hair/mod.rs index 14c3f0e580d0..2a5b7d0fb290 100644 --- a/src/librustc_mir/hair/mod.rs +++ b/src/librustc_mir/hair/mod.rs @@ -139,7 +139,7 @@ pub enum ExprKind<'tcx> { Cast { source: ExprRef<'tcx>, }, - EmptyToAny { + NeverToAny { source: ExprRef<'tcx>, }, ReifyFnPointer { diff --git a/src/librustc_mir/transform/type_check.rs b/src/librustc_mir/transform/type_check.rs index 501b69bb12a2..a030ba17655f 100644 --- a/src/librustc_mir/transform/type_check.rs +++ b/src/librustc_mir/transform/type_check.rs @@ -492,7 +492,8 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> { } }, None => { - if !sig.output.is_empty(tcx) { + // FIXME(canndrew): This is_never should probably be an is_uninhabited + if !sig.output.is_never() { span_mirbug!(self, term, "call to converging function {:?} w/o dest", sig); } }, diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index 9cd955b1cafd..0c54f20fe766 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -632,7 +632,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node fn check_adjustments<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr) { match v.tcx.tables.borrow().adjustments.get(&e.id) { None | - Some(&ty::adjustment::AdjustEmptyToAny(..)) | + Some(&ty::adjustment::AdjustNeverToAny(..)) | Some(&ty::adjustment::AdjustReifyFnPointer) | Some(&ty::adjustment::AdjustUnsafeFnPointer) | Some(&ty::adjustment::AdjustMutToConstPointer) => {} diff --git a/src/librustc_trans/_match.rs b/src/librustc_trans/_match.rs index 29b3f6ce52fb..27a8c1f1df47 100644 --- a/src/librustc_trans/_match.rs +++ b/src/librustc_trans/_match.rs @@ -1593,7 +1593,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>, } let t = node_id_type(bcx, discr_expr.id); - let chk = if t.is_empty(tcx) { + let chk = if t.is_uninhabited(tcx) { Unreachable } else { Infallible diff --git a/src/librustc_trans/callee.rs b/src/librustc_trans/callee.rs index 56b378519b4a..aaec2a47025a 100644 --- a/src/librustc_trans/callee.rs +++ b/src/librustc_trans/callee.rs @@ -712,7 +712,8 @@ fn trans_call_inner<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, _ => {} } - if output.is_empty(bcx.tcx()) { + // FIXME(canndrew): This is_never should really be an is_uninhabited + if output.is_never() { Unreachable(bcx); } diff --git a/src/librustc_trans/collector.rs b/src/librustc_trans/collector.rs index 4df96a3b685d..6decc48c36a3 100644 --- a/src/librustc_trans/collector.rs +++ b/src/librustc_trans/collector.rs @@ -753,7 +753,7 @@ fn find_drop_glue_neighbors<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>, ty::TyRef(..) | ty::TyFnDef(..) | ty::TyFnPtr(_) | - ty::TyEmpty | + ty::TyNever | ty::TyTrait(_) => { /* nothing to do */ } diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index 5da4304abb3b..79cf77cd9d35 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -558,7 +558,7 @@ impl<'a, 'tcx> FunctionContext<'a, 'tcx> { abi: Abi::C, sig: ty::Binder(ty::FnSig { inputs: vec![tcx.mk_mut_ptr(tcx.types.u8)], - output: tcx.types.empty, + output: tcx.types.never, variadic: false }), })); diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index 95af6db0260d..3ecba3691d27 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -34,7 +34,7 @@ use type_of; use value::Value; use Disr; use rustc::ty::subst::Substs; -use rustc::ty::adjustment::{AdjustEmptyToAny, AdjustDerefRef, AdjustReifyFnPointer}; +use rustc::ty::adjustment::{AdjustNeverToAny, AdjustDerefRef, AdjustReifyFnPointer}; use rustc::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::cast::{CastTy,IntTy}; @@ -348,7 +348,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, &cx.tcx().expr_ty_adjusted(e)); let opt_adj = cx.tcx().tables.borrow().adjustments.get(&e.id).cloned(); match opt_adj { - Some(AdjustEmptyToAny(..)) => span_bug!(e.span, "const expression of type ! encountered"), + Some(AdjustNeverToAny(..)) => span_bug!(e.span, "const expression of type ! encountered"), Some(AdjustReifyFnPointer) => { match ety.sty { ty::TyFnDef(def_id, substs, _) => { diff --git a/src/librustc_trans/debuginfo/metadata.rs b/src/librustc_trans/debuginfo/metadata.rs index 08dfc97d67a7..3fe8b2b66791 100644 --- a/src/librustc_trans/debuginfo/metadata.rs +++ b/src/librustc_trans/debuginfo/metadata.rs @@ -171,7 +171,7 @@ impl<'tcx> TypeMap<'tcx> { unique_type_id.push('{'); match type_.sty { - ty::TyEmpty | + ty::TyNever | ty::TyBool | ty::TyChar | ty::TyStr | @@ -695,7 +695,7 @@ pub fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, let sty = &t.sty; let MetadataCreationResult { metadata, already_stored_in_typemap } = match *sty { - ty::TyEmpty | + ty::TyNever | ty::TyBool | ty::TyChar | ty::TyInt(_) | @@ -912,7 +912,7 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, debug!("basic_type_metadata: {:?}", t); let (name, encoding) = match t.sty { - ty::TyEmpty => ("!", DW_ATE_unsigned), + ty::TyNever => ("!", DW_ATE_unsigned), ty::TyTuple(ref elements) if elements.is_empty() => ("()", DW_ATE_unsigned), ty::TyBool => ("bool", DW_ATE_boolean), diff --git a/src/librustc_trans/debuginfo/type_names.rs b/src/librustc_trans/debuginfo/type_names.rs index 190b40d41c98..73b1c828663e 100644 --- a/src/librustc_trans/debuginfo/type_names.rs +++ b/src/librustc_trans/debuginfo/type_names.rs @@ -40,7 +40,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ty::TyBool => output.push_str("bool"), ty::TyChar => output.push_str("char"), ty::TyStr => output.push_str("str"), - ty::TyEmpty => output.push_str("!"), + ty::TyNever => output.push_str("!"), ty::TyInt(int_ty) => output.push_str(int_ty.ty_to_string()), ty::TyUint(uint_ty) => output.push_str(uint_ty.ty_to_string()), ty::TyFloat(float_ty) => output.push_str(float_ty.ty_to_string()), diff --git a/src/librustc_trans/declare.rs b/src/librustc_trans/declare.rs index 01eedb11ceb4..4d9ee187ac50 100644 --- a/src/librustc_trans/declare.rs +++ b/src/librustc_trans/declare.rs @@ -111,7 +111,8 @@ pub fn declare_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, name: &str, let fty = FnType::new(ccx, abi, &sig, &[]); let llfn = declare_raw_fn(ccx, name, fty.cconv, fty.llvm_type(ccx)); - if sig.output.is_empty(ccx.tcx()) { + // FIXME(canndrew): This is_never should really be an is_uninhabited + if sig.output.is_never() { llvm::Attribute::NoReturn.apply_llfn(Function, llfn); } diff --git a/src/librustc_trans/expr.rs b/src/librustc_trans/expr.rs index fa2521205a8e..0ea571513f75 100644 --- a/src/librustc_trans/expr.rs +++ b/src/librustc_trans/expr.rs @@ -69,7 +69,7 @@ use tvec; use type_of; use value::Value; use Disr; -use rustc::ty::adjustment::{AdjustEmptyToAny, AdjustDerefRef, AdjustReifyFnPointer}; +use rustc::ty::adjustment::{AdjustNeverToAny, AdjustDerefRef, AdjustReifyFnPointer}; use rustc::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; use rustc::ty::adjustment::CustomCoerceUnsized; use rustc::ty::{self, Ty, TyCtxt}; @@ -348,7 +348,7 @@ fn adjustment_required<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } match adjustment { - AdjustEmptyToAny(..) => true, + AdjustNeverToAny(..) => true, AdjustReifyFnPointer => true, AdjustUnsafeFnPointer | AdjustMutToConstPointer => { // purely a type-level thing @@ -381,7 +381,7 @@ fn apply_adjustments<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, debug!("unadjusted datum for expr {:?}: {:?} adjustment={:?}", expr, datum, adjustment); match adjustment { - AdjustEmptyToAny(ref target) => { + AdjustNeverToAny(ref target) => { let mono_target = bcx.monomorphize(target); let llty = type_of::type_of(bcx.ccx(), mono_target); let dummy = C_undef(llty.ptr_to()); diff --git a/src/librustc_trans/trans_item.rs b/src/librustc_trans/trans_item.rs index 9f4f8fc990aa..90058f0b8329 100644 --- a/src/librustc_trans/trans_item.rs +++ b/src/librustc_trans/trans_item.rs @@ -412,7 +412,7 @@ pub fn push_unique_type_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty::TyBool => output.push_str("bool"), ty::TyChar => output.push_str("char"), ty::TyStr => output.push_str("str"), - ty::TyEmpty => output.push_str("!"), + ty::TyNever => output.push_str("!"), ty::TyInt(ast::IntTy::Is) => output.push_str("isize"), ty::TyInt(ast::IntTy::I8) => output.push_str("i8"), ty::TyInt(ast::IntTy::I16) => output.push_str("i16"), diff --git a/src/librustc_trans/type_of.rs b/src/librustc_trans/type_of.rs index 6224bb761667..e6794149fcb3 100644 --- a/src/librustc_trans/type_of.rs +++ b/src/librustc_trans/type_of.rs @@ -64,7 +64,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ ty::TyInt(t) => Type::int_from_ty(cx, t), ty::TyUint(t) => Type::uint_from_ty(cx, t), ty::TyFloat(t) => Type::float_from_ty(cx, t), - ty::TyEmpty => Type::nil(cx), + ty::TyNever => Type::nil(cx), ty::TyBox(ty) | ty::TyRef(_, ty::TypeAndMut{ty, ..}) | @@ -250,7 +250,7 @@ pub fn in_memory_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> ty::TyInt(t) => Type::int_from_ty(cx, t), ty::TyUint(t) => Type::uint_from_ty(cx, t), ty::TyFloat(t) => Type::float_from_ty(cx, t), - ty::TyEmpty => Type::nil(cx), + ty::TyNever => Type::nil(cx), ty::TyEnum(def, ref substs) => { // Only create the named struct, but don't fill it in. We // fill it in *after* placing it into the type cache. This diff --git a/src/librustc_typeck/astconv.rs b/src/librustc_typeck/astconv.rs index e342bfb635c2..ed67c9fbe30b 100644 --- a/src/librustc_typeck/astconv.rs +++ b/src/librustc_typeck/astconv.rs @@ -1700,8 +1700,8 @@ impl<'o, 'gcx: 'tcx, 'tcx> AstConv<'gcx, 'tcx>+'o { let t = self.ast_ty_to_ty(rscope1, &mt.ty); tcx.mk_ref(tcx.mk_region(r), ty::TypeAndMut {ty: t, mutbl: mt.mutbl}) } - hir::TyEmpty => { - tcx.types.empty + hir::TyNever => { + tcx.types.never }, hir::TyTup(ref fields) => { let flds = fields.iter() diff --git a/src/librustc_typeck/check/coercion.rs b/src/librustc_typeck/check/coercion.rs index cf5cfff6037d..f5345bbea2d5 100644 --- a/src/librustc_typeck/check/coercion.rs +++ b/src/librustc_typeck/check/coercion.rs @@ -68,8 +68,8 @@ use rustc::traits::{self, ObligationCause}; use rustc::ty::adjustment::{AutoAdjustment, AutoDerefRef, AdjustDerefRef}; use rustc::ty::adjustment::{AutoPtr, AutoUnsafe, AdjustReifyFnPointer}; use rustc::ty::adjustment::{AdjustUnsafeFnPointer, AdjustMutToConstPointer}; -use rustc::ty::adjustment::AdjustEmptyToAny; -use rustc::ty::{self, TypeVariants, LvaluePreference, TypeAndMut, Ty}; +use rustc::ty::adjustment::AdjustNeverToAny; +use rustc::ty::{self, LvaluePreference, TypeAndMut, Ty}; use rustc::ty::fold::TypeFoldable; use rustc::ty::error::TypeError; use rustc::ty::relate::RelateResult; @@ -168,8 +168,8 @@ impl<'f, 'gcx, 'tcx> Coerce<'f, 'gcx, 'tcx> { return self.identity(b); } - if let TypeVariants::TyEmpty = a.sty { - return Ok((b, AdjustEmptyToAny(b))); + if a.is_never() { + return Ok((b, AdjustNeverToAny(b))); } // Consider coercing the subtype to a DST diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index b526d2dcbede..f3a01ef7409f 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -433,7 +433,7 @@ fn iterate_over_potentially_unsafe_regions_in_type<'a, 'b, 'gcx, 'tcx>( // We still need to ensure all referenced data is safe. match ty.sty { ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | - ty::TyFloat(_) | ty::TyStr | ty::TyEmpty => { + ty::TyFloat(_) | ty::TyStr | ty::TyNever => { // primitive - definitely safe Ok(()) } diff --git a/src/librustc_typeck/check/intrinsic.rs b/src/librustc_typeck/check/intrinsic.rs index d0085a1cc84a..ddc8c82c1225 100644 --- a/src/librustc_typeck/check/intrinsic.rs +++ b/src/librustc_typeck/check/intrinsic.rs @@ -106,7 +106,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &hir::ForeignItem) { }; (n_tps, inputs, output) } else if &name[..] == "abort" || &name[..] == "unreachable" { - (0, Vec::new(), tcx.types.empty) + (0, Vec::new(), tcx.types.never) } else { let (n_tps, inputs, output) = match &name[..] { "breakpoint" => (0, Vec::new(), tcx.mk_nil()), diff --git a/src/librustc_typeck/check/mod.rs b/src/librustc_typeck/check/mod.rs index cea591a84d6f..6ad7c5a84772 100644 --- a/src/librustc_typeck/check/mod.rs +++ b/src/librustc_typeck/check/mod.rs @@ -93,7 +93,7 @@ use rustc::traits::{self, Reveal}; use rustc::ty::{GenericPredicates, TypeScheme}; use rustc::ty::{ParamTy, ParameterEnvironment}; use rustc::ty::{LvaluePreference, NoPreference, PreferMutLvalue}; -use rustc::ty::{self, ToPolyTraitRef, Ty, TypeVariants, TyCtxt, Visibility}; +use rustc::ty::{self, ToPolyTraitRef, Ty, TyCtxt, Visibility}; use rustc::ty::{MethodCall, MethodCallee}; use rustc::ty::adjustment; use rustc::ty::fold::{BottomUpFolder, TypeFoldable}; @@ -1556,8 +1556,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { #[inline] pub fn write_ty_expr(&self, node_id: ast::NodeId, ty: Ty<'tcx>) { self.write_ty(node_id, ty); - if let TypeVariants::TyEmpty = ty.sty { - self.write_adjustment(node_id, adjustment::AdjustEmptyToAny(self.next_diverging_ty_var())); + if ty.is_never() { + self.write_adjustment(node_id, adjustment::AdjustNeverToAny(self.next_diverging_ty_var())); } } @@ -1732,8 +1732,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { self.write_ty(node_id, self.tcx.mk_nil()); } - pub fn write_empty(&self, node_id: ast::NodeId) { - self.write_ty_expr(node_id, self.tcx.types.empty); + pub fn write_never(&self, node_id: ast::NodeId) { + self.write_ty_expr(node_id, self.tcx.types.never); } pub fn write_error(&self, node_id: ast::NodeId) { @@ -1793,7 +1793,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } pub fn expr_ty(&self, ex: &hir::Expr) -> Ty<'tcx> { - if let Some(&adjustment::AdjustEmptyToAny(ref t)) + if let Some(&adjustment::AdjustNeverToAny(ref t)) = self.tables.borrow().adjustments.get(&ex.id) { return t; } @@ -1977,7 +1977,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { if self.type_var_diverges(resolved) { debug!("default_type_parameters: defaulting `{:?}` to `!` because it diverges", resolved); - self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.empty); + self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.never); } else { match self.type_is_unconstrained_numeric(resolved) { UnconstrainedInt => { @@ -2051,7 +2051,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { for ty in &unsolved_variables { let resolved = self.resolve_type_vars_if_possible(ty); if self.type_var_diverges(resolved) { - self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.empty); + self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.never); } else { match self.type_is_unconstrained_numeric(resolved) { UnconstrainedInt | UnconstrainedFloat => { @@ -2109,7 +2109,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { let _ = self.commit_if_ok(|_: &infer::CombinedSnapshot| { for ty in &unbound_tyvars { if self.type_var_diverges(ty) { - self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.empty); + self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.never); } else { match self.type_is_unconstrained_numeric(ty) { UnconstrainedInt => { @@ -2205,7 +2205,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { // reporting for more then one conflict. for ty in &unbound_tyvars { if self.type_var_diverges(ty) { - self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.empty); + self.demand_eqtype(syntax_pos::DUMMY_SP, *ty, self.tcx.types.never); } else { match self.type_is_unconstrained_numeric(ty) { UnconstrainedInt => { @@ -2610,9 +2610,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } if let Some(&arg_ty) = self.tables.borrow().node_types.get(&arg.id) { + // FIXME(canndrew): This is_never should probably be an is_uninhabited any_diverges = any_diverges || self.type_var_diverges(arg_ty) || - arg_ty.is_empty(self.tcx); + arg_ty.is_never(); } } if any_diverges && !warned { @@ -3485,8 +3486,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { } self.write_nil(id); } - hir::ExprBreak(_) => { self.write_empty(id); } - hir::ExprAgain(_) => { self.write_empty(id); } + hir::ExprBreak(_) => { self.write_never(id); } + hir::ExprAgain(_) => { self.write_never(id); } hir::ExprRet(ref expr_opt) => { if let Some(ref e) = *expr_opt { self.check_expr_coercable_to_type(&e, self.ret_ty); @@ -3504,7 +3505,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { .emit(); } } - self.write_empty(id); + self.write_never(id); } hir::ExprAssign(ref lhs, ref rhs) => { self.check_expr_with_lvalue_pref(&lhs, PreferMutLvalue); @@ -3546,7 +3547,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { hir::ExprLoop(ref body, _) => { self.check_block_no_value(&body); if !may_break(tcx, expr.id, &body) { - self.write_empty(id); + self.write_never(id); } else { self.write_nil(id); } @@ -4002,9 +4003,10 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> { "unreachable statement".to_string()); warned = true; } + // FIXME(canndrew): This is_never should probably be an is_uninhabited any_diverges = any_diverges || self.type_var_diverges(s_ty) || - s_ty.is_empty(self.tcx); + s_ty.is_never(); any_err = any_err || s_ty.references_error(); } match blk.expr { diff --git a/src/librustc_typeck/check/wfcheck.rs b/src/librustc_typeck/check/wfcheck.rs index 5eca6e21681a..4bb9f4fd332f 100644 --- a/src/librustc_typeck/check/wfcheck.rs +++ b/src/librustc_typeck/check/wfcheck.rs @@ -51,7 +51,7 @@ impl<'a, 'gcx, 'tcx> CheckWfFcxBuilder<'a, 'gcx, 'tcx> { let id = self.id; let span = self.span; self.inherited.enter(|inh| { - let fcx = FnCtxt::new(&inh, inh.ccx.tcx.types.empty, id); + let fcx = FnCtxt::new(&inh, inh.ccx.tcx.types.never, id); let wf_tys = f(&fcx, &mut CheckTypeWellFormedVisitor { ccx: fcx.ccx, code: code diff --git a/src/librustc_typeck/check/writeback.rs b/src/librustc_typeck/check/writeback.rs index 5fe9b8742d7e..5f8861f30994 100644 --- a/src/librustc_typeck/check/writeback.rs +++ b/src/librustc_typeck/check/writeback.rs @@ -378,8 +378,8 @@ impl<'cx, 'gcx, 'tcx> WritebackCx<'cx, 'gcx, 'tcx> { Some(adjustment) => { let resolved_adjustment = match adjustment { - adjustment::AdjustEmptyToAny(ty) => { - adjustment::AdjustEmptyToAny(self.resolve(&ty, reason)) + adjustment::AdjustNeverToAny(ty) => { + adjustment::AdjustNeverToAny(self.resolve(&ty, reason)) } adjustment::AdjustReifyFnPointer => { diff --git a/src/librustc_typeck/coherence/mod.rs b/src/librustc_typeck/coherence/mod.rs index 2ac74e2e7f88..9b26e95f7fa5 100644 --- a/src/librustc_typeck/coherence/mod.rs +++ b/src/librustc_typeck/coherence/mod.rs @@ -24,7 +24,7 @@ use rustc::ty::{ImplOrTraitItemId, ConstTraitItemId}; use rustc::ty::{MethodTraitItemId, TypeTraitItemId, ParameterEnvironment}; use rustc::ty::{Ty, TyBool, TyChar, TyEnum, TyError}; use rustc::ty::{TyParam, TyRawPtr}; -use rustc::ty::{TyRef, TyStruct, TyTrait, TyEmpty, TyTuple}; +use rustc::ty::{TyRef, TyStruct, TyTrait, TyNever, TyTuple}; use rustc::ty::{TyStr, TyArray, TySlice, TyFloat, TyInfer, TyInt}; use rustc::ty::{TyUint, TyClosure, TyBox, TyFnDef, TyFnPtr}; use rustc::ty::{TyProjection, TyAnon}; @@ -84,7 +84,7 @@ impl<'a, 'gcx, 'tcx> CoherenceChecker<'a, 'gcx, 'tcx> { TyBool | TyChar | TyInt(..) | TyUint(..) | TyFloat(..) | TyStr | TyArray(..) | TySlice(..) | TyFnDef(..) | TyFnPtr(_) | - TyTuple(..) | TyParam(..) | TyError | TyEmpty | + TyTuple(..) | TyParam(..) | TyError | TyNever | TyRawPtr(_) | TyRef(_, _) | TyProjection(..) => { None } diff --git a/src/librustc_typeck/variance/constraints.rs b/src/librustc_typeck/variance/constraints.rs index 3d4e71bed46f..a4faee8f633e 100644 --- a/src/librustc_typeck/variance/constraints.rs +++ b/src/librustc_typeck/variance/constraints.rs @@ -322,7 +322,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { match ty.sty { ty::TyBool | ty::TyChar | ty::TyInt(_) | ty::TyUint(_) | - ty::TyFloat(_) | ty::TyStr | ty::TyEmpty => { + ty::TyFloat(_) | ty::TyStr | ty::TyNever => { /* leaf type -- noop */ } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index bfb50bcbc25a..99d2732c4bb0 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1459,8 +1459,7 @@ pub enum Type { Tuple(Vec), Vector(Box), FixedVector(Box, String), - /// aka TyBot - Bottom, + Never, Unique(Box), RawPointer(Mutability, Box), BorrowedRef { @@ -1671,7 +1670,7 @@ impl Clean for hir::Ty { fn clean(&self, cx: &DocContext) -> Type { use rustc::hir::*; match self.node { - TyEmpty => Bottom, + TyNever => Never, TyPtr(ref m) => RawPointer(m.mutbl.clean(cx), box m.ty.clean(cx)), TyRptr(ref l, ref m) => BorrowedRef {lifetime: l.clean(cx), mutability: m.mutbl.clean(cx), @@ -1780,7 +1779,7 @@ impl Clean for hir::Ty { impl<'tcx> Clean for ty::Ty<'tcx> { fn clean(&self, cx: &DocContext) -> Type { match self.sty { - ty::TyEmpty => Bottom, + ty::TyNever => Never, ty::TyBool => Primitive(Bool), ty::TyChar => Primitive(Char), ty::TyInt(ast::IntTy::Is) => Primitive(Isize), diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index ce0cfa564393..2f03b235e9f6 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -492,7 +492,7 @@ impl fmt::Display for clean::Type { primitive_link(f, clean::PrimitiveType::Array, &format!("; {}]", Escape(s))) } - clean::Bottom => f.write_str("!"), + clean::Never => f.write_str("!"), clean::RawPointer(m, ref t) => { match **t { clean::Generic(_) | clean::ResolvedPath {is_generic: true, ..} => { diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index 9046a44fdc6d..f8a5cb0b04a8 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -1358,8 +1358,8 @@ pub enum TyKind { Rptr(Option, MutTy), /// A bare function (e.g. `fn(usize) -> bool`) BareFn(P), - /// The empty type (`!`) - Empty, + /// The never type (`!`) + Never, /// A tuple (`(A, B, C, D,...)`) Tup(Vec> ), /// A path (`module::module::...::Type`), optionally diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index efedc7229e64..734d8d442562 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -287,7 +287,7 @@ declare_features! ( (active, relaxed_adts, "1.12.0", Some(35626)), // The `!` type - (active, bang_type, "1.13.0", Some(35121)) + (active, never_type, "1.13.0", Some(35121)) ); declare_features! ( @@ -966,8 +966,8 @@ impl<'a> Visitor for PostExpansionVisitor<'a> { gate_feature_post!(&self, conservative_impl_trait, ty.span, "`impl Trait` is experimental"); } - ast::TyKind::Empty => { - gate_feature_post!(&self, bang_type, ty.span, + ast::TyKind::Never => { + gate_feature_post!(&self, never_type, ty.span, "The `!` type is experimental"); }, _ => {} @@ -978,7 +978,7 @@ impl<'a> Visitor for PostExpansionVisitor<'a> { fn visit_fn_ret_ty(&mut self, ret_ty: &ast::FunctionRetTy) { if let ast::FunctionRetTy::Ty(ref output_ty) = *ret_ty { match output_ty.node { - ast::TyKind::Empty => return, + ast::TyKind::Never => return, _ => (), }; visit::walk_ty(self, output_ty) diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 6c5cbdc645a7..b257ab98987d 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -373,7 +373,7 @@ pub fn noop_fold_ty(t: P, fld: &mut T) -> P { decl: fld.fold_fn_decl(decl) })) } - TyKind::Empty => node, + TyKind::Never => node, TyKind::Tup(tys) => TyKind::Tup(tys.move_map(|ty| fld.fold_ty(ty))), TyKind::Paren(ty) => TyKind::Paren(fld.fold_ty(ty)), TyKind::Path(qself, path) => { diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 4f54f5293226..118096d9d486 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1396,7 +1396,7 @@ impl<'a> Parser<'a> { TyKind::Tup(ts) } } else if self.eat(&token::Not) { - TyKind::Empty + TyKind::Never } else if self.check(&token::BinOp(token::Star)) { // STAR POINTER (bare pointer?) self.bump(); diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index a5d512f14ec6..24d8198191e3 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -976,7 +976,7 @@ impl<'a> State<'a> { try!(self.print_opt_lifetime(lifetime)); try!(self.print_mt(mt)); } - ast::TyKind::Empty => { + ast::TyKind::Never => { word(&mut self.s, "!")?; }, ast::TyKind::Tup(ref elts) => { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index 228409b82074..8b03afdeb368 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -323,7 +323,7 @@ pub fn walk_ty(visitor: &mut V, typ: &Ty) { walk_list!(visitor, visit_lifetime, opt_lifetime); visitor.visit_ty(&mutable_type.ty) } - TyKind::Empty => {}, + TyKind::Never => {}, TyKind::Tup(ref tuple_element_types) => { walk_list!(visitor, visit_ty, tuple_element_types); } diff --git a/src/test/run-fail/adjust_empty.rs b/src/test/run-fail/adjust_never.rs similarity index 95% rename from src/test/run-fail/adjust_empty.rs rename to src/test/run-fail/adjust_never.rs index 6d81099cedaa..b390aae61434 100644 --- a/src/test/run-fail/adjust_empty.rs +++ b/src/test/run-fail/adjust_never.rs @@ -8,9 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(bang_type)] - - +#![feature(never_type)] // error-pattern:explicit fn main() {