about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2014-11-04 07:57:21 -0500
committerJakub Bukaj <jakub@jakub.cc>2014-11-16 14:23:14 +0100
commit08d6774f39743b69c199d79a5c64dbcef58c03d3 (patch)
tree1296ffa9f310773d4bbd5cdbf8ba5d1758a3bf1f
parent0c7a3d6c167c4656e8d35a1d428d142993e0aaab (diff)
downloadrust-08d6774f39743b69c199d79a5c64dbcef58c03d3.tar.gz
rust-08d6774f39743b69c199d79a5c64dbcef58c03d3.zip
Try to remove ty_nil, some kind of error in exhaustiveness checking
-rw-r--r--src/librustc/lint/builtin.rs2
-rw-r--r--src/librustc/metadata/tydecode.rs1
-rw-r--r--src/librustc/metadata/tyencode.rs1
-rw-r--r--src/librustc/middle/check_match.rs6
-rw-r--r--src/librustc/middle/traits/coherence.rs1
-rw-r--r--src/librustc/middle/traits/select.rs1
-rw-r--r--src/librustc/middle/trans/_match.rs2
-rw-r--r--src/librustc/middle/trans/base.rs22
-rw-r--r--src/librustc/middle/trans/callee.rs4
-rw-r--r--src/librustc/middle/trans/context.rs6
-rw-r--r--src/librustc/middle/trans/debuginfo.rs9
-rw-r--r--src/librustc/middle/trans/foreign.rs2
-rw-r--r--src/librustc/middle/trans/glue.rs13
-rw-r--r--src/librustc/middle/trans/meth.rs1
-rw-r--r--src/librustc/middle/trans/type_of.rs8
-rw-r--r--src/librustc/middle/ty.rs40
-rw-r--r--src/librustc/middle/ty_fold.rs2
-rw-r--r--src/librustc/middle/typeck/astconv.rs4
-rw-r--r--src/librustc/middle/typeck/check/method.rs2
-rw-r--r--src/librustc/middle/typeck/check/mod.rs49
-rw-r--r--src/librustc/middle/typeck/check/regionmanip.rs1
-rw-r--r--src/librustc/middle/typeck/coherence/mod.rs4
-rw-r--r--src/librustc/middle/typeck/infer/combine.rs1
-rw-r--r--src/librustc/middle/typeck/infer/skolemize.rs1
-rw-r--r--src/librustc/middle/typeck/mod.rs2
-rw-r--r--src/librustc/middle/typeck/variance.rs2
-rw-r--r--src/librustc/util/ppaux.rs3
27 files changed, 76 insertions, 114 deletions
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs
index 86dd967026b..a5187283de1 100644
--- a/src/librustc/lint/builtin.rs
+++ b/src/librustc/lint/builtin.rs
@@ -735,7 +735,7 @@ impl LintPass for UnusedResults {
         let t = ty::expr_ty(cx.tcx, expr);
         let mut warned = false;
         match ty::get(t).sty {
-            ty::ty_nil | ty::ty_bool => return,
+            ty::ty_bool => return,
             ty::ty_struct(did, _) |
             ty::ty_enum(did, _) => {
                 if ast_util::is_local(did) {
diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs
index 26b2afd2f3c..50c9a4a2a52 100644
--- a/src/librustc/metadata/tydecode.rs
+++ b/src/librustc/metadata/tydecode.rs
@@ -360,7 +360,6 @@ fn parse_trait_ref(st: &mut PState, conv: conv_did) -> ty::TraitRef {
 
 fn parse_ty(st: &mut PState, conv: conv_did) -> ty::t {
     match next(st) {
-      'n' => return ty::mk_nil(),
       'b' => return ty::mk_bool(),
       'i' => return ty::mk_int(),
       'u' => return ty::mk_uint(),
diff --git a/src/librustc/metadata/tyencode.rs b/src/librustc/metadata/tyencode.rs
index 56e44b69a5f..3242d396146 100644
--- a/src/librustc/metadata/tyencode.rs
+++ b/src/librustc/metadata/tyencode.rs
@@ -199,7 +199,6 @@ pub fn enc_trait_store(w: &mut SeekableMemWriter, cx: &ctxt, s: ty::TraitStore)
 
 fn enc_sty(w: &mut SeekableMemWriter, cx: &ctxt, st: &ty::sty) {
     match *st {
-        ty::ty_nil => mywrite!(w, "n"),
         ty::ty_bool => mywrite!(w, "b"),
         ty::ty_char => mywrite!(w, "c"),
         ty::ty_int(t) => {
diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs
index a893f8e8959..a23889d9cab 100644
--- a/src/librustc/middle/check_match.rs
+++ b/src/librustc/middle/check_match.rs
@@ -402,7 +402,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor,
     let pats_len = pats.len();
     let mut pats = pats.into_iter().map(|p| P((*p).clone()));
     let pat = match ty::get(left_ty).sty {
-        ty::ty_tup(_) => PatTup(pats.collect()),
+        ty::ty_tup(ref tys) if !tys.is_empty() => PatTup(pats.collect()),
 
         ty::ty_enum(cid, _) | ty::ty_struct(cid, _)  => {
             let (vid, is_structure) = match ctor {
@@ -497,7 +497,7 @@ fn all_constructors(cx: &MatchCheckCtxt, left_ty: ty::t,
         ty::ty_bool =>
             [true, false].iter().map(|b| ConstantValue(const_bool(*b))).collect(),
 
-        ty::ty_nil =>
+        ty::ty_tup(ref tys) if tys.is_empty() =>
             vec!(ConstantValue(const_nil)),
 
         ty::ty_rptr(_, ty::mt { ty, .. }) => match ty::get(ty).sty {
@@ -552,7 +552,7 @@ fn is_useful(cx: &MatchCheckCtxt,
         None => v[0]
     };
     let left_ty = if real_pat.id == DUMMY_NODE_ID {
-        ty::mk_nil()
+        ty::mk_nil(cx.tcx)
     } else {
         ty::pat_ty(cx.tcx, &*real_pat)
     };
diff --git a/src/librustc/middle/traits/coherence.rs b/src/librustc/middle/traits/coherence.rs
index 9900620b229..be5a007c1eb 100644
--- a/src/librustc/middle/traits/coherence.rs
+++ b/src/librustc/middle/traits/coherence.rs
@@ -79,7 +79,6 @@ pub fn ty_is_local(tcx: &ty::ctxt,
     debug!("ty_is_local({})", ty.repr(tcx));
 
     match ty::get(ty).sty {
-        ty::ty_nil |
         ty::ty_bool |
         ty::ty_char |
         ty::ty_int(..) |
diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs
index ce8ba7c14d3..b50956ec9db 100644
--- a/src/librustc/middle/traits/select.rs
+++ b/src/librustc/middle/traits/select.rs
@@ -1227,7 +1227,6 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
             ty::ty_infer(ty::FloatVar(_)) |
             ty::ty_uint(_) |
             ty::ty_int(_) |
-            ty::ty_nil |
             ty::ty_bool |
             ty::ty_float(_) |
             ty::ty_bare_fn(_) |
diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs
index 7b0ebe631e0..e4409777686 100644
--- a/src/librustc/middle/trans/_match.rs
+++ b/src/librustc/middle/trans/_match.rs
@@ -1012,7 +1012,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                          .unwrap_or(DUMMY_NODE_ID);
 
     let left_ty = if pat_id == DUMMY_NODE_ID {
-        ty::mk_nil()
+        ty::mk_nil(tcx)
     } else {
         node_id_type(bcx, pat_id)
     };
diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs
index d02c5dfa9e9..d4d532c1c44 100644
--- a/src/librustc/middle/trans/base.rs
+++ b/src/librustc/middle/trans/base.rs
@@ -47,7 +47,7 @@ use middle::trans::builder::{Builder, noname};
 use middle::trans::callee;
 use middle::trans::cleanup::{CleanupMethods, ScopeId};
 use middle::trans::cleanup;
-use middle::trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_integral, C_nil};
+use middle::trans::common::{Block, C_bool, C_bytes_in_context, C_i32, C_integral};
 use middle::trans::common::{C_null, C_struct_in_context, C_u64, C_u8, C_uint, C_undef};
 use middle::trans::common::{CrateContext, ExternMap, FunctionContext};
 use middle::trans::common::{NodeInfo, Result, SubstP};
@@ -517,7 +517,7 @@ pub fn get_res_dtor(ccx: &CrateContext,
         let class_ty = ty::lookup_item_type(tcx, parent_id).ty.subst(tcx, substs);
         let llty = type_of_dtor(ccx, class_ty);
         let dtor_ty = ty::mk_ctor_fn(ccx.tcx(), ast::DUMMY_NODE_ID,
-                                     [glue::get_drop_glue_type(ccx, t)], ty::mk_nil());
+                                     [glue::get_drop_glue_type(ccx, t)], ty::mk_nil(ccx.tcx()));
         get_extern_fn(ccx,
                       &mut *ccx.externs().borrow_mut(),
                       name.as_slice(),
@@ -551,7 +551,7 @@ pub fn compare_scalar_types<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
     let f = |a| Result::new(cx, compare_scalar_values(cx, lhs, rhs, a, op));
 
     match ty::get(t).sty {
-        ty::ty_nil => f(nil_type),
+        ty::ty_tup(ref tys) if tys.is_empty() => f(nil_type),
         ty::ty_bool | ty::ty_uint(_) | ty::ty_char => f(unsigned_int),
         ty::ty_ptr(mt) if ty::type_is_sized(cx.tcx(), mt.ty) => f(unsigned_int),
         ty::ty_int(_) => f(signed_int),
@@ -1578,12 +1578,6 @@ fn create_datums_for_fn_args_under_call_abi(
                                                                 "argtuple"));
                 result.push(tuple);
             }
-            ty::ty_nil => {
-                let mode = datum::Rvalue::new(datum::ByValue);
-                result.push(datum::Datum::new(C_nil(bcx.ccx()),
-                                              ty::mk_nil(),
-                                              mode))
-            }
             _ => {
                 bcx.tcx().sess.bug("last argument of a function with \
                                     `rust-call` ABI isn't a tuple?!")
@@ -1647,10 +1641,8 @@ fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>(
                       arg_datum.to_lvalue_datum_in_scope(bcx,
                                                          "argtuple",
                                                          arg_scope_id));
-    let empty = Vec::new();
     let untupled_arg_types = match ty::get(monomorphized_arg_types[0]).sty {
         ty::ty_tup(ref types) => types.as_slice(),
-        ty::ty_nil => empty.as_slice(),
         _ => {
             bcx.tcx().sess.span_bug(args[0].pat.span,
                                     "first arg to `rust-call` ABI function \
@@ -1824,7 +1816,7 @@ pub fn trans_closure(ccx: &CrateContext,
         NotUnboxedClosure => monomorphized_arg_types,
 
         // Tuple up closure argument types for the "rust-call" ABI.
-        IsUnboxedClosure => vec![ty::mk_tup_or_nil(ccx.tcx(), monomorphized_arg_types)]
+        IsUnboxedClosure => vec![ty::mk_tup(ccx.tcx(), monomorphized_arg_types)]
     };
     for monomorphized_arg_type in monomorphized_arg_types.iter() {
         debug!("trans_closure: monomorphized_arg_type: {}",
@@ -2380,7 +2372,6 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
             assert!(abi == RustCall);
 
             match ty::get(fn_sig.inputs[0]).sty {
-                ty::ty_nil => Vec::new(),
                 ty::ty_tup(ref inputs) => inputs.clone(),
                 _ => ccx.sess().bug("expected tuple'd inputs")
             }
@@ -2389,7 +2380,6 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t)
             let mut inputs = vec![fn_sig.inputs[0]];
 
             match ty::get(fn_sig.inputs[1]).sty {
-                ty::ty_nil => inputs,
                 ty::ty_tup(ref t_in) => {
                     inputs.push_all(t_in.as_slice());
                     inputs
@@ -2532,7 +2522,7 @@ pub fn register_fn_llvmty(ccx: &CrateContext,
                           llfty: Type) -> ValueRef {
     debug!("register_fn_llvmty id={} sym={}", node_id, sym);
 
-    let llfn = decl_fn(ccx, sym.as_slice(), cc, llfty, ty::FnConverging(ty::mk_nil()));
+    let llfn = decl_fn(ccx, sym.as_slice(), cc, llfty, ty::FnConverging(ty::mk_nil(ccx.tcx())));
     finish_register_fn(ccx, sp, sym, node_id, llfn);
     llfn
 }
@@ -2564,7 +2554,7 @@ pub fn create_entry_wrapper(ccx: &CrateContext,
         let llfty = Type::func([ccx.int_type(), Type::i8p(ccx).ptr_to()],
                                &ccx.int_type());
 
-        let llfn = decl_cdecl_fn(ccx, "main", llfty, ty::mk_nil());
+        let llfn = decl_cdecl_fn(ccx, "main", llfty, ty::mk_nil(ccx.tcx()));
 
         // FIXME: #16581: Marking a symbol in the executable with `dllexport`
         // linkage forces MinGW's linker to output a `.reloc` section for ASLR
diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs
index 7a040196ea8..f62159cd490 100644
--- a/src/librustc/middle/trans/callee.rs
+++ b/src/librustc/middle/trans/callee.rs
@@ -764,7 +764,7 @@ pub fn trans_call_inner<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         expr::Ignore => {
             let ret_ty = match ret_ty {
                 ty::FnConverging(ret_ty) => ret_ty,
-                ty::FnDiverging => ty::mk_nil()
+                ty::FnDiverging => ty::mk_nil(ccx.tcx())
             };
             if !is_rust_fn ||
               type_of::return_uses_outptr(ccx, ret_ty) ||
@@ -957,7 +957,6 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
                 llargs.push(arg_datum.add_clean(bcx.fcx, arg_cleanup_scope));
             }
         }
-        ty::ty_nil => {}
         _ => {
             bcx.sess().span_bug(tuple_expr.span,
                                 "argument to `.call()` wasn't a tuple?!")
@@ -1004,7 +1003,6 @@ fn trans_overloaded_call_args<'blk, 'tcx>(
                 }))
             }
         }
-        ty::ty_nil => {}
         _ => {
             bcx.sess().span_bug(arg_exprs[0].span,
                                 "argument to `.call()` wasn't a tuple?!")
diff --git a/src/librustc/middle/trans/context.rs b/src/librustc/middle/trans/context.rs
index 2ba01aa922a..be712087e0b 100644
--- a/src/librustc/middle/trans/context.rs
+++ b/src/librustc/middle/trans/context.rs
@@ -718,7 +718,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
     macro_rules! ifn (
         ($name:expr fn() -> $ret:expr) => (
             if *key == $name {
-                let f = base::decl_cdecl_fn(ccx, $name, Type::func([], &$ret), ty::mk_nil());
+                let f = base::decl_cdecl_fn(ccx, $name, Type::func([], &$ret), ty::mk_nil(ccx.tcx()));
                 ccx.intrinsics().borrow_mut().insert($name, f.clone());
                 return Some(f);
             }
@@ -726,7 +726,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
         ($name:expr fn($($arg:expr),*) -> $ret:expr) => (
             if *key == $name {
                 let f = base::decl_cdecl_fn(ccx, $name,
-                                  Type::func([$($arg),*], &$ret), ty::mk_nil());
+                                  Type::func([$($arg),*], &$ret), ty::mk_nil(ccx.tcx()));
                 ccx.intrinsics().borrow_mut().insert($name, f.clone());
                 return Some(f);
             }
@@ -863,7 +863,7 @@ fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef
             } else if *key == $name {
                 let f = base::decl_cdecl_fn(ccx, stringify!($cname),
                                       Type::func([$($arg),*], &$ret),
-                                      ty::mk_nil());
+                                      ty::mk_nil(ccx.tcx()));
                 ccx.intrinsics().borrow_mut().insert($name, f.clone());
                 return Some(f);
             }
diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs
index fb6347af698..be342c8afe9 100644
--- a/src/librustc/middle/trans/debuginfo.rs
+++ b/src/librustc/middle/trans/debuginfo.rs
@@ -350,7 +350,6 @@ impl TypeMap {
         unique_type_id.push('{');
 
         match ty::get(type_).sty {
-            ty::ty_nil      |
             ty::ty_bool     |
             ty::ty_char     |
             ty::ty_str      |
@@ -367,6 +366,9 @@ impl TypeMap {
                 unique_type_id.push_str("struct ");
                 from_def_id_and_substs(self, cx, def_id, substs, &mut unique_type_id);
             },
+            ty::ty_tup(ref component_types) if component_types.is_empty() => {
+                push_debuginfo_type_name(cx, type_, false, &mut unique_type_id);
+            },
             ty::ty_tup(ref component_types) => {
                 unique_type_id.push_str("tuple ");
                 for &component_type in component_types.iter() {
@@ -1736,7 +1738,6 @@ fn basic_type_metadata(cx: &CrateContext, t: ty::t) -> DIType {
     debug!("basic_type_metadata: {}", ty::get(t));
 
     let (name, encoding) = match ty::get(t).sty {
-        ty::ty_nil => ("()".to_string(), DW_ATE_unsigned),
         ty::ty_bool => ("bool".to_string(), DW_ATE_boolean),
         ty::ty_char => ("char".to_string(), DW_ATE_unsigned_char),
         ty::ty_int(int_ty) => match int_ty {
@@ -2773,7 +2774,7 @@ fn subroutine_type_metadata(cx: &CrateContext,
     // return type
     signature_metadata.push(match signature.output {
         ty::FnConverging(ret_ty) => match ty::get(ret_ty).sty {
-            ty::ty_nil => ptr::null_mut(),
+            ty::ty_tup(ref tys) if tys.is_empty() => ptr::null_mut(),
             _ => type_metadata(cx, ret_ty, span)
         },
         ty::FnDiverging => diverging_type_metadata(cx)
@@ -2880,7 +2881,6 @@ fn type_metadata(cx: &CrateContext,
 
     let sty = &ty::get(t).sty;
     let MetadataCreationResult { metadata, already_stored_in_typemap } = match *sty {
-        ty::ty_nil      |
         ty::ty_bool     |
         ty::ty_char     |
         ty::ty_int(_)   |
@@ -3671,7 +3671,6 @@ fn push_debuginfo_type_name(cx: &CrateContext,
                             qualified: bool,
                             output:&mut String) {
     match ty::get(t).sty {
-        ty::ty_nil               => output.push_str("()"),
         ty::ty_bool              => output.push_str("bool"),
         ty::ty_char              => output.push_str("char"),
         ty::ty_str               => output.push_str("str"),
diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs
index bed45a28691..0b03163a02b 100644
--- a/src/librustc/middle/trans/foreign.rs
+++ b/src/librustc/middle/trans/foreign.rs
@@ -520,7 +520,7 @@ pub fn decl_rust_fn_with_foreign_abi(ccx: &CrateContext,
         }
         _ => panic!("expected bare fn in decl_rust_fn_with_foreign_abi")
     };
-    let llfn = base::decl_fn(ccx, name, cconv, llfn_ty, ty::FnConverging(ty::mk_nil()));
+    let llfn = base::decl_fn(ccx, name, cconv, llfn_ty, ty::FnConverging(ty::mk_nil(ccx.tcx())));
     add_argument_attributes(&tys, llfn);
     debug!("decl_rust_fn_with_foreign_abi(llfn_ty={}, llfn={})",
            ccx.tn().type_to_string(llfn_ty), ccx.tn().val_to_string(llfn));
diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs
index 0a44abb6780..f5db3d41812 100644
--- a/src/librustc/middle/trans/glue.rs
+++ b/src/librustc/middle/trans/glue.rs
@@ -159,7 +159,7 @@ pub fn get_drop_glue(ccx: &CrateContext, t: ty::t) -> ValueRef {
 
     let (glue, new_sym) = match ccx.available_drop_glues().borrow().get(&t) {
         Some(old_sym) => {
-            let glue = decl_cdecl_fn(ccx, old_sym.as_slice(), llfnty, ty::mk_nil());
+            let glue = decl_cdecl_fn(ccx, old_sym.as_slice(), llfnty, ty::mk_nil(ccx.tcx()));
             (glue, None)
         },
         None => {
@@ -288,7 +288,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         }
 
         let dtor_ty = ty::mk_ctor_fn(variant_cx.tcx(), ast::DUMMY_NODE_ID,
-                                     [get_drop_glue_type(bcx.ccx(), t)], ty::mk_nil());
+                                     [get_drop_glue_type(bcx.ccx(), t)], ty::mk_nil(bcx.tcx()));
         let (_, variant_cx) = invoke(variant_cx, dtor_addr, args, dtor_ty, None, false);
 
         variant_cx.fcx.pop_and_trans_custom_cleanup_scope(variant_cx, field_scope);
@@ -520,7 +520,7 @@ fn declare_generic_glue(ccx: &CrateContext, t: ty::t, llfnty: Type,
         ccx,
         t,
         format!("glue_{}", name).as_slice());
-    let llfn = decl_cdecl_fn(ccx, fn_nm.as_slice(), llfnty, ty::mk_nil());
+    let llfn = decl_cdecl_fn(ccx, fn_nm.as_slice(), llfnty, ty::mk_nil(ccx.tcx()));
     note_unique_llvm_symbol(ccx, fn_nm.clone());
     return (fn_nm, llfn);
 }
@@ -538,10 +538,11 @@ fn make_generic_glue(ccx: &CrateContext,
 
     let arena = TypedArena::new();
     let empty_param_substs = param_substs::empty();
-    let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, false, ty::FnConverging(ty::mk_nil()),
+    let fcx = new_fn_ctxt(ccx, llfn, ast::DUMMY_NODE_ID, false,
+                          ty::FnConverging(ty::mk_nil(ccx.tcx())),
                           &empty_param_substs, None, &arena);
 
-    let bcx = init_function(&fcx, false, ty::FnConverging(ty::mk_nil()));
+    let bcx = init_function(&fcx, false, ty::FnConverging(ty::mk_nil(ccx.tcx())));
 
     update_linkage(ccx, llfn, None, OriginalTranslation);
 
@@ -556,7 +557,7 @@ fn make_generic_glue(ccx: &CrateContext,
 
     let llrawptr0 = get_param(llfn, fcx.arg_pos(0) as c_uint);
     let bcx = helper(bcx, llrawptr0, t);
-    finish_fn(&fcx, bcx, ty::FnConverging(ty::mk_nil()));
+    finish_fn(&fcx, bcx, ty::FnConverging(ty::mk_nil(ccx.tcx())));
 
     llfn
 }
diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs
index 098b82fe38c..f0af123221f 100644
--- a/src/librustc/middle/trans/meth.rs
+++ b/src/librustc/middle/trans/meth.rs
@@ -594,7 +594,6 @@ pub fn get_vtable(bcx: Block,
                                             new_inputs.push(element.subst(bcx.tcx(), substs));
                                         }
                                     }
-                                    ty::ty_nil => {}
                                     _ => {
                                         bcx.tcx().sess.bug("get_vtable(): closure \
                                                             type wasn't a tuple")
diff --git a/src/librustc/middle/trans/type_of.rs b/src/librustc/middle/trans/type_of.rs
index 9530c86a94c..379d1e85b8b 100644
--- a/src/librustc/middle/trans/type_of.rs
+++ b/src/librustc/middle/trans/type_of.rs
@@ -83,7 +83,6 @@ pub fn untuple_arguments_if_necessary(ccx: &CrateContext,
                 result.push(tupled_argument);
             }
         }
-        ty::ty_nil => {}
         _ => {
             ccx.tcx().sess.bug("argument to function with \"rust-call\" ABI \
                                 is neither a tuple nor unit")
@@ -186,7 +185,6 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
                                   ppaux::ty_to_string(cx.tcx(), t)).as_slice())
         }
 
-        ty::ty_nil => Type::nil(cx),
         ty::ty_bool => Type::bool(cx),
         ty::ty_char => Type::char(cx),
         ty::ty_int(t) => Type::int_from_ty(cx, t),
@@ -211,6 +209,10 @@ pub fn sizing_type_of(cx: &CrateContext, t: ty::t) -> Type {
             Type::array(&llty, size)
         }
 
+        ty::ty_tup(ref tys) if tys.is_empty() => {
+            Type::nil(cx)
+        }
+
         ty::ty_tup(..) | ty::ty_enum(..) | ty::ty_unboxed_closure(..) => {
             let repr = adt::represent_type(cx, t);
             adt::sizing_type_of(cx, &*repr, false)
@@ -298,7 +300,6 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
     }
 
     let mut llty = match ty::get(t).sty {
-      ty::ty_nil => Type::nil(cx),
       ty::ty_bool => Type::bool(cx),
       ty::ty_char => Type::char(cx),
       ty::ty_int(t) => Type::int_from_ty(cx, t),
@@ -365,6 +366,7 @@ pub fn type_of(cx: &CrateContext, t: ty::t) -> Type {
           let fn_ty = type_of_fn_from_ty(cx, t).ptr_to();
           Type::struct_(cx, [fn_ty, Type::i8p(cx)], false)
       }
+      ty::ty_tup(ref tys) if tys.is_empty() => Type::nil(cx),
       ty::ty_tup(..) => {
           let repr = adt::represent_type(cx, t);
           adt::type_of(cx, &*repr)
diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs
index 0a3c4e76fa0..1e5b3c9ea7a 100644
--- a/src/librustc/middle/ty.rs
+++ b/src/librustc/middle/ty.rs
@@ -906,7 +906,6 @@ mod primitives {
         )
     )
 
-    def_prim_ty!(TY_NIL,    super::ty_nil)
     def_prim_ty!(TY_BOOL,   super::ty_bool)
     def_prim_ty!(TY_CHAR,   super::ty_char)
     def_prim_ty!(TY_INT,    super::ty_int(ast::TyI))
@@ -932,7 +931,6 @@ mod primitives {
 // AST structure in libsyntax/ast.rs as well.
 #[deriving(Clone, PartialEq, Eq, Hash, Show)]
 pub enum sty {
-    ty_nil,
     ty_bool,
     ty_char,
     ty_int(ast::IntTy),
@@ -1557,7 +1555,6 @@ pub fn mk_ctxt<'tcx>(s: Session,
 pub fn mk_t(cx: &ctxt, st: sty) -> t {
     // Check for primitive types.
     match st {
-        ty_nil => return mk_nil(),
         ty_err => return mk_err(),
         ty_bool => return mk_bool(),
         ty_int(i) => return mk_mach_int(i),
@@ -1603,7 +1600,7 @@ pub fn mk_t(cx: &ctxt, st: sty) -> t {
         rflags(bounds.region_bound)
     }
     match &st {
-      &ty_nil | &ty_bool | &ty_char | &ty_int(_) | &ty_float(_) | &ty_uint(_) |
+      &ty_bool | &ty_char | &ty_int(_) | &ty_float(_) | &ty_uint(_) |
       &ty_str => {}
       // You might think that we could just return ty_err for
       // any type containing ty_err as a component, and get
@@ -1690,9 +1687,6 @@ pub fn mk_prim_t(primitive: &'static t_box_) -> t {
 }
 
 #[inline]
-pub fn mk_nil() -> t { mk_prim_t(&primitives::TY_NIL) }
-
-#[inline]
 pub fn mk_err() -> t { mk_prim_t(&primitives::TY_ERR) }
 
 #[inline]
@@ -1803,7 +1797,7 @@ pub fn mk_imm_ptr(cx: &ctxt, ty: t) -> t {
 }
 
 pub fn mk_nil_ptr(cx: &ctxt) -> t {
-    mk_ptr(cx, mt {ty: mk_nil(), mutbl: ast::MutImmutable})
+    mk_ptr(cx, mt {ty: mk_nil(cx), mutbl: ast::MutImmutable})
 }
 
 pub fn mk_vec(cx: &ctxt, t: t, sz: Option<uint>) -> t {
@@ -1818,14 +1812,12 @@ pub fn mk_slice(cx: &ctxt, r: Region, tm: mt) -> t {
             })
 }
 
-pub fn mk_tup(cx: &ctxt, ts: Vec<t>) -> t { mk_t(cx, ty_tup(ts)) }
+pub fn mk_tup(cx: &ctxt, ts: Vec<t>) -> t {
+    mk_t(cx, ty_tup(ts))
+}
 
-pub fn mk_tup_or_nil(cx: &ctxt, ts: Vec<t>) -> t {
-    if ts.len() == 0 {
-        ty::mk_nil()
-    } else {
-        mk_t(cx, ty_tup(ts))
-    }
+pub fn mk_nil(cx: &ctxt) -> t {
+    mk_tup(cx, Vec::new())
 }
 
 pub fn mk_closure(cx: &ctxt, fty: ClosureTy) -> t {
@@ -1908,7 +1900,7 @@ pub fn maybe_walk_ty(ty: t, f: |t| -> bool) {
         return;
     }
     match get(ty).sty {
-        ty_nil | ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) |
+        ty_bool | ty_char | ty_int(_) | ty_uint(_) | ty_float(_) |
         ty_str | ty_infer(_) | ty_param(_) | ty_err => {}
         ty_uniq(ty) | ty_vec(ty, _) | ty_open(ty) => maybe_walk_ty(ty, f),
         ty_ptr(ref tm) | ty_rptr(_, ref tm) => {
@@ -1996,7 +1988,10 @@ impl ParamBounds {
 // Type utilities
 
 pub fn type_is_nil(ty: t) -> bool {
-    get(ty).sty == ty_nil
+    match get(ty).sty {
+        ty_tup(ref tys) => tys.is_empty(),
+        _ => false
+    }
 }
 
 pub fn type_is_error(ty: t) -> bool {
@@ -2133,7 +2128,7 @@ pub fn type_is_fat_ptr(cx: &ctxt, ty: t) -> bool {
 */
 pub fn type_is_scalar(ty: t) -> bool {
     match get(ty).sty {
-      ty_nil | ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) |
+      ty_bool | ty_char | ty_int(_) | ty_float(_) | ty_uint(_) |
       ty_infer(IntVar(_)) | ty_infer(FloatVar(_)) |
       ty_bare_fn(..) | ty_ptr(_) => true,
       _ => false
@@ -2170,7 +2165,7 @@ pub fn type_needs_unwind_cleanup(cx: &ctxt, ty: t) -> bool {
         let mut needs_unwind_cleanup = false;
         maybe_walk_ty(ty, |ty| {
             needs_unwind_cleanup |= match get(ty).sty {
-                ty_nil | ty_bool | ty_int(_) | ty_uint(_) |
+                ty_bool | ty_int(_) | ty_uint(_) |
                 ty_float(_) | ty_tup(_) | ty_ptr(_) => false,
 
                 ty_enum(did, ref substs) =>
@@ -2429,7 +2424,7 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents {
 
             // Scalar and unique types are sendable, and durable
             ty_infer(ty::SkolemizedIntTy(_)) |
-            ty_nil | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
+            ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
             ty_bare_fn(_) | ty::ty_char => {
                 TC::None
             }
@@ -2740,7 +2735,6 @@ pub fn is_instantiable(cx: &ctxt, r_ty: t) -> bool {
             ty_vec(_, Some(0)) => false, // don't need no contents
             ty_vec(ty, Some(_)) => type_requires(cx, seen, r_ty, ty),
 
-            ty_nil |
             ty_bool |
             ty_char |
             ty_int(_) |
@@ -3779,7 +3773,7 @@ pub fn impl_or_trait_item_idx(id: ast::Name, trait_items: &[ImplOrTraitItem])
 
 pub fn ty_sort_string(cx: &ctxt, t: t) -> String {
     match get(t).sty {
-        ty_nil | ty_bool | ty_char | ty_int(_) |
+        ty_bool | ty_char | ty_int(_) |
         ty_uint(_) | ty_float(_) | ty_str => {
             ::util::ppaux::ty_to_string(cx, t)
         }
@@ -5141,7 +5135,6 @@ pub fn hash_crate_independent(tcx: &ctxt, t: t, svh: &Svh) -> u64 {
     };
     ty::walk_ty(t, |t| {
         match ty::get(t).sty {
-            ty_nil => byte!(0),
             ty_bool => byte!(2),
             ty_char => byte!(3),
             ty_int(i) => {
@@ -5512,7 +5505,6 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
                 accumulator.push(*region);
                 accum_substs(accumulator, substs);
             }
-            ty_nil |
             ty_bool |
             ty_char |
             ty_int(_) |
diff --git a/src/librustc/middle/ty_fold.rs b/src/librustc/middle/ty_fold.rs
index 031c7b2aed6..6d8d03aa0ab 100644
--- a/src/librustc/middle/ty_fold.rs
+++ b/src/librustc/middle/ty_fold.rs
@@ -554,7 +554,7 @@ pub fn super_fold_sty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
         ty::ty_unboxed_closure(did, ref region, ref substs) => {
             ty::ty_unboxed_closure(did, region.fold_with(this), substs.fold_with(this))
         }
-        ty::ty_nil | ty::ty_bool | ty::ty_char | ty::ty_str |
+        ty::ty_bool | ty::ty_char | ty::ty_str |
         ty::ty_int(_) | ty::ty_uint(_) | ty::ty_float(_) |
         ty::ty_err | ty::ty_infer(_) |
         ty::ty_param(..) => {
diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs
index ec289a2d806..9358904a78c 100644
--- a/src/librustc/middle/typeck/astconv.rs
+++ b/src/librustc/middle/typeck/astconv.rs
@@ -389,7 +389,7 @@ fn ast_path_substs<'tcx,AC,RS>(
 
         let output = match data.output {
             Some(ref output_ty) => ast_ty_to_ty(this, &binding_rscope, &**output_ty),
-            None => ty::mk_nil()
+            None => ty::mk_nil(this.tcx())
         };
 
         (Vec::new(), vec![input_ty, output])
@@ -824,7 +824,7 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>(
 
     let typ = ast_ty_to_builtin_ty(this, rscope, ast_ty).unwrap_or_else(|| {
         match ast_ty.node {
-            ast::TyNil => ty::mk_nil(),
+            ast::TyNil => ty::mk_nil(this.tcx()),
             ast::TyBot => unreachable!(),
             ast::TyUniq(ref ty) => {
                 mk_pointer(this, rscope, ast::MutImmutable, &**ty, Uniq,
diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs
index 6280fce035a..a35bc502813 100644
--- a/src/librustc/middle/typeck/check/method.rs
+++ b/src/librustc/middle/typeck/check/method.rs
@@ -1214,7 +1214,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> {
             ty_bare_fn(..) | ty_uniq(..) | ty_rptr(..) |
             ty_infer(IntVar(_)) |
             ty_infer(FloatVar(_)) |
-            ty_param(..) | ty_nil | ty_bool |
+            ty_param(..) | ty_bool |
             ty_char | ty_int(..) | ty_uint(..) |
             ty_float(..) | ty_enum(..) | ty_ptr(..) | ty_struct(..) |
             ty_unboxed_closure(..) | ty_tup(..) | ty_open(..) |
diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs
index cac702d6ac0..bb20475c0cf 100644
--- a/src/librustc/middle/typeck/check/mod.rs
+++ b/src/librustc/middle/typeck/check/mod.rs
@@ -1569,7 +1569,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     pub fn default_diverging_type_variables_to_nil(&self) {
         for (_, &ref ty) in self.inh.node_types.borrow_mut().iter_mut() {
             if self.infcx().type_var_diverges(self.infcx().resolve_type_vars_if_possible(*ty)) {
-                demand::eqtype(self, codemap::DUMMY_SP, *ty, ty::mk_nil());
+                demand::eqtype(self, codemap::DUMMY_SP, *ty, ty::mk_nil(self.tcx()));
             }
         }
     }
@@ -1741,7 +1741,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
     }
 
     pub fn write_nil(&self, node_id: ast::NodeId) {
-        self.write_ty(node_id, ty::mk_nil());
+        self.write_ty(node_id, ty::mk_nil(self.tcx()));
     }
     pub fn write_error(&self, node_id: ast::NodeId) {
         self.write_ty(node_id, ty::mk_err());
@@ -2664,17 +2664,6 @@ fn check_argument_types<'a>(fcx: &FnCtxt,
                     (*arg_types).clone()
                 }
             }
-            ty::ty_nil => {
-                if args.len() != 0 {
-                    span_err!(tcx.sess, sp, E0058,
-                        "this function takes 0 parameters but {} parameter{} supplied",
-                        args.len(),
-                        if args.len() == 1 {" was"} else {"s were"});
-                    err_args(args.len())
-                } else {
-                    vec![]
-                }
-            }
             _ => {
                 span_err!(tcx.sess, sp, E0059,
                     "cannot use call notation; the first type parameter \
@@ -2865,7 +2854,7 @@ fn check_lit(fcx: &FnCtxt,
             opt_ty.unwrap_or_else(
                 || ty::mk_float_var(tcx, fcx.infcx().next_float_var_id()))
         }
-        ast::LitNil => ty::mk_nil(),
+        ast::LitNil => ty::mk_nil(tcx),
         ast::LitBool(_) => ty::mk_bool()
     }
 }
@@ -3179,7 +3168,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
                                         infer::IfExpressionWithNoElse(sp),
                                         false,
                                         then_ty,
-                                        ty::mk_nil())
+                                        ty::mk_nil(fcx.tcx()))
             }
         };
 
@@ -3480,7 +3469,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
 
         // Tuple up the arguments and insert the resulting function type into
         // the `unboxed_closures` table.
-        fn_ty.sig.inputs = vec![ty::mk_tup_or_nil(fcx.tcx(), fn_ty.sig.inputs)];
+        fn_ty.sig.inputs = vec![ty::mk_tup(fcx.tcx(), fn_ty.sig.inputs)];
 
         let kind = match kind {
             ast::FnUnboxedClosureKind => ty::FnUnboxedClosureKind,
@@ -4148,7 +4137,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt,
                 match *expr_opt {
                     None =>
                         if let Err(_) = fcx.mk_eqty(false, infer::Misc(expr.span),
-                                                    result_type, ty::mk_nil()) {
+                                                    result_type, ty::mk_nil(fcx.tcx())) {
                             span_err!(tcx.sess, expr.span, E0069,
                                 "`return;` in function returning non-nil");
                         },
@@ -4743,7 +4732,7 @@ pub fn check_stmt(fcx: &FnCtxt, stmt: &ast::Stmt)  {
       ast::StmtExpr(ref expr, id) => {
         node_id = id;
         // Check with expected type of ()
-        check_expr_has_type(fcx, &**expr, ty::mk_nil());
+        check_expr_has_type(fcx, &**expr, ty::mk_nil(fcx.tcx()));
         let expr_ty = fcx.expr_ty(&**expr);
         saw_bot = saw_bot || fcx.infcx().type_var_diverges(expr_ty);
         saw_err = saw_err || ty::type_is_error(expr_ty);
@@ -4769,12 +4758,12 @@ pub fn check_stmt(fcx: &FnCtxt, stmt: &ast::Stmt)  {
 }
 
 pub fn check_block_no_value(fcx: &FnCtxt, blk: &ast::Block)  {
-    check_block_with_expected(fcx, blk, ExpectHasType(ty::mk_nil()));
+    check_block_with_expected(fcx, blk, ExpectHasType(ty::mk_nil(fcx.tcx())));
     let blkty = fcx.node_ty(blk.id);
     if ty::type_is_error(blkty) {
         fcx.write_error(blk.id);
     } else {
-        let nilty = ty::mk_nil();
+        let nilty = ty::mk_nil(fcx.tcx());
         demand::suptype(fcx, blk.span, nilty, blkty);
     }
 }
@@ -5507,7 +5496,7 @@ pub fn instantiate_path(fcx: &FnCtxt,
             data.output.as_ref().map(|ty| fcx.to_ty(&**ty));
 
         let output_ty =
-            output_ty.unwrap_or(ty::mk_nil());
+            output_ty.unwrap_or(ty::mk_nil(fcx.tcx()));
 
         if type_count >= 2 {
             substs.types.push(space, output_ty);
@@ -5727,7 +5716,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
             "load" => (1, vec!(ty::mk_imm_ptr(tcx, param(ccx, 0))),
                        param(ccx, 0)),
             "store" => (1, vec!(ty::mk_mut_ptr(tcx, param(ccx, 0)), param(ccx, 0)),
-                        ty::mk_nil()),
+                        ty::mk_nil(tcx)),
 
             "xchg" | "xadd" | "xsub" | "and"  | "nand" | "or" | "xor" | "max" |
             "min"  | "umax" | "umin" => {
@@ -5735,7 +5724,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
                  param(ccx, 0))
             }
             "fence" => {
-                (0, Vec::new(), ty::mk_nil())
+                (0, Vec::new(), ty::mk_nil(tcx))
             }
             op => {
                 span_err!(tcx.sess, it.span, E0092,
@@ -5748,12 +5737,12 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
         (0, Vec::new(), ty::FnDiverging)
     } else {
         let (n_tps, inputs, output) = match name.get() {
-            "breakpoint" => (0, Vec::new(), ty::mk_nil()),
+            "breakpoint" => (0, Vec::new(), ty::mk_nil(tcx)),
             "size_of" |
             "pref_align_of" | "min_align_of" => (1u, Vec::new(), ty::mk_uint()),
             "init" => (1u, Vec::new(), param(ccx, 0u)),
             "uninit" => (1u, Vec::new(), param(ccx, 0u)),
-            "forget" => (1u, vec!( param(ccx, 0) ), ty::mk_nil()),
+            "forget" => (1u, vec!( param(ccx, 0) ), ty::mk_nil(tcx)),
             "transmute" => (2, vec!( param(ccx, 0) ), param(ccx, 1)),
             "move_val_init" => {
                 (1u,
@@ -5761,7 +5750,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
                     ty::mk_mut_rptr(tcx, ty::ReLateBound(it.id, ty::BrAnon(0)), param(ccx, 0)),
                     param(ccx, 0u)
                   ),
-               ty::mk_nil())
+               ty::mk_nil(tcx))
             }
             "needs_drop" => (1u, Vec::new(), ty::mk_bool()),
             "owns_managed" => (1u, Vec::new(), ty::mk_bool()),
@@ -5817,7 +5806,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
                   }),
                   ty::mk_uint()
                ),
-               ty::mk_nil())
+               ty::mk_nil(tcx))
             }
             "set_memory" | "volatile_set_memory" => {
               (1,
@@ -5829,7 +5818,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
                   ty::mk_u8(),
                   ty::mk_uint()
                ),
-               ty::mk_nil())
+               ty::mk_nil(tcx))
             }
             "sqrtf32" => (0, vec!( ty::mk_f32() ), ty::mk_f32()),
             "sqrtf64" => (0, vec!( ty::mk_f64() ), ty::mk_f64()),
@@ -5912,7 +5901,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
             "volatile_load" =>
                 (1, vec!( ty::mk_imm_ptr(tcx, param(ccx, 0)) ), param(ccx, 0)),
             "volatile_store" =>
-                (1, vec!( ty::mk_mut_ptr(tcx, param(ccx, 0)), param(ccx, 0) ), ty::mk_nil()),
+                (1, vec!( ty::mk_mut_ptr(tcx, param(ccx, 0)), param(ccx, 0) ), ty::mk_nil(tcx)),
 
             "i8_add_with_overflow" | "i8_sub_with_overflow" | "i8_mul_with_overflow" =>
                 (0, vec!(ty::mk_i8(), ty::mk_i8()),
@@ -5948,7 +5937,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) {
 
             "return_address" => (0, vec![], ty::mk_imm_ptr(tcx, ty::mk_u8())),
 
-            "assume" => (0, vec![ty::mk_bool()], ty::mk_nil()),
+            "assume" => (0, vec![ty::mk_bool()], ty::mk_nil(tcx)),
 
             ref other => {
                 span_err!(tcx.sess, it.span, E0093,
diff --git a/src/librustc/middle/typeck/check/regionmanip.rs b/src/librustc/middle/typeck/check/regionmanip.rs
index 0856c86946b..032b31b1f38 100644
--- a/src/librustc/middle/typeck/check/regionmanip.rs
+++ b/src/librustc/middle/typeck/check/regionmanip.rs
@@ -91,7 +91,6 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
                ty.repr(self.tcx));
 
         match ty::get(ty).sty {
-            ty::ty_nil |
             ty::ty_bool |
             ty::ty_char |
             ty::ty_int(..) |
diff --git a/src/librustc/middle/typeck/coherence/mod.rs b/src/librustc/middle/typeck/coherence/mod.rs
index 898d987ace7..ca03e9d96e8 100644
--- a/src/librustc/middle/typeck/coherence/mod.rs
+++ b/src/librustc/middle/typeck/coherence/mod.rs
@@ -24,7 +24,7 @@ use middle::ty::get;
 use middle::ty::{ImplContainer, ImplOrTraitItemId, MethodTraitItemId};
 use middle::ty::{TypeTraitItemId, lookup_item_type};
 use middle::ty::{t, ty_bool, ty_char, ty_enum, ty_err};
-use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_nil, ty_open};
+use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_open};
 use middle::ty::{ty_param, Polytype, ty_ptr};
 use middle::ty::{ty_rptr, ty_struct, ty_trait, ty_tup};
 use middle::ty::{ty_uint, ty_unboxed_closure, ty_uniq, ty_bare_fn};
@@ -82,7 +82,7 @@ fn get_base_type(inference_context: &InferCtxt,
             Some(resolved_type)
         }
 
-        ty_nil | ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) |
+        ty_bool | ty_char | ty_int(..) | ty_uint(..) | ty_float(..) |
         ty_str(..) | ty_vec(..) | ty_bare_fn(..) | ty_closure(..) | ty_tup(..) |
         ty_infer(..) | ty_param(..) | ty_err | ty_open(..) | ty_uniq(_) |
         ty_ptr(_) | ty_rptr(_, _) => {
diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs
index 83d90274fd3..df25e5009c3 100644
--- a/src/librustc/middle/typeck/infer/combine.rs
+++ b/src/librustc/middle/typeck/infer/combine.rs
@@ -433,7 +433,6 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres<t
         }
 
       (&ty::ty_char, _) |
-      (&ty::ty_nil, _) |
       (&ty::ty_bool, _) |
       (&ty::ty_int(_), _) |
       (&ty::ty_uint(_), _) |
diff --git a/src/librustc/middle/typeck/infer/skolemize.rs b/src/librustc/middle/typeck/infer/skolemize.rs
index 6e5e8d72839..9458960156e 100644
--- a/src/librustc/middle/typeck/infer/skolemize.rs
+++ b/src/librustc/middle/typeck/infer/skolemize.rs
@@ -148,7 +148,6 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeSkolemizer<'a, 'tcx> {
                 self.tcx().sess.bug("Cannot skolemize an open existential type");
             }
 
-            ty::ty_nil |
             ty::ty_bool |
             ty::ty_char |
             ty::ty_int(..) |
diff --git a/src/librustc/middle/typeck/mod.rs b/src/librustc/middle/typeck/mod.rs
index f348e6155a2..2c8d1ce3f4f 100644
--- a/src/librustc/middle/typeck/mod.rs
+++ b/src/librustc/middle/typeck/mod.rs
@@ -382,7 +382,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
                 sig: ty::FnSig {
                     binder_id: main_id,
                     inputs: Vec::new(),
-                    output: ty::FnConverging(ty::mk_nil()),
+                    output: ty::FnConverging(ty::mk_nil(tcx)),
                     variadic: false
                 }
             });
diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs
index 3a2dc1d5ff0..97d7f9f1863 100644
--- a/src/librustc/middle/typeck/variance.rs
+++ b/src/librustc/middle/typeck/variance.rs
@@ -728,7 +728,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
         debug!("add_constraints_from_ty(ty={})", ty.repr(self.tcx()));
 
         match ty::get(ty).sty {
-            ty::ty_nil | ty::ty_bool |
+            ty::ty_bool |
             ty::ty_char | ty::ty_int(_) | ty::ty_uint(_) |
             ty::ty_float(_) | ty::ty_str => {
                 /* leaf type -- noop */
diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs
index 60a7436dbaa..bcd70510edd 100644
--- a/src/librustc/util/ppaux.rs
+++ b/src/librustc/util/ppaux.rs
@@ -19,7 +19,7 @@ use middle::ty::{ReSkolemized, ReVar, BrEnv};
 use middle::ty::{mt, t, ParamTy};
 use middle::ty::{ty_bool, ty_char, ty_struct, ty_enum};
 use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn, ty_closure};
-use middle::ty::{ty_nil, ty_param, ty_ptr, ty_rptr, ty_tup, ty_open};
+use middle::ty::{ty_param, ty_ptr, ty_rptr, ty_tup, ty_open};
 use middle::ty::{ty_unboxed_closure};
 use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_infer};
 use middle::ty;
@@ -384,7 +384,6 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String {
 
     // pretty print the structural type representation:
     match ty::get(typ).sty {
-        ty_nil => "()".to_string(),
         ty_bool => "bool".to_string(),
         ty_char => "char".to_string(),
         ty_int(t) => ast_util::int_ty_to_string(t, None).to_string(),