Skip to content

Commit

Permalink
renamed mk_nil to mk_unit
Browse files Browse the repository at this point in the history
  • Loading branch information
kenta7777 committed Sep 10, 2018
1 parent 6f685ff commit 5c3ba4a
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 40 deletions.
2 changes: 1 addition & 1 deletion src/librustc/traits/error_reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
{
let predicate = trait_predicate.map_bound(|mut trait_pred| {
trait_pred.trait_ref.substs = self.tcx.mk_substs_trait(
self.tcx.mk_nil(),
self.tcx.mk_unit(),
&trait_pred.trait_ref.substs[1..],
);
trait_pred
Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2492,7 +2492,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
}

pub fn mk_nil_ptr(self) -> Ty<'tcx> {
self.mk_imm_ptr(self.mk_nil())
self.mk_imm_ptr(self.mk_unit())
}

pub fn mk_array(self, ty: Ty<'tcx>, n: u64) -> Ty<'tcx> {
Expand All @@ -2511,7 +2511,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
iter.intern_with(|ts| self.mk_ty(Tuple(self.intern_type_list(ts))))
}

pub fn mk_nil(self) -> Ty<'tcx> {
pub fn mk_unit(self) -> Ty<'tcx> {
self.intern_tup(&[])
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc/ty/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl PrimitiveExt for Primitive {
Int(i, signed) => i.to_ty(tcx, signed),
Float(FloatTy::F32) => tcx.types.f32,
Float(FloatTy::F64) => tcx.types.f64,
Pointer => tcx.mk_mut_ptr(tcx.mk_nil()),
Pointer => tcx.mk_mut_ptr(tcx.mk_unit()),
}
}
}
Expand Down Expand Up @@ -1606,7 +1606,7 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
// (which may have no non-DST form), and will work as long
// as the `Abi` or `FieldPlacement` is checked by users.
if i == 0 {
let nil = tcx.mk_nil();
let nil = tcx.mk_unit();
let ptr_ty = if this.ty.is_unsafe_ptr() {
tcx.mk_mut_ptr(nil)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -968,7 +968,7 @@ fn get_rust_try_fn<'ll, 'tcx>(
let i8p = tcx.mk_mut_ptr(tcx.types.i8);
let fn_ty = tcx.mk_fn_ptr(ty::Binder::bind(tcx.mk_fn_sig(
iter::once(i8p),
tcx.mk_nil(),
tcx.mk_unit(),
false,
hir::Unsafety::Unsafe,
Abi::Rust
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_driver/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ impl<'a, 'gcx, 'tcx> Env<'a, 'gcx, 'tcx> {
}

pub fn t_nil(&self) -> Ty<'tcx> {
self.infcx.tcx.mk_nil()
self.infcx.tcx.mk_unit()
}

pub fn t_pair(&self, ty1: Ty<'tcx>, ty2: Ty<'tcx>) -> Ty<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/hair/cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> {
}

pub fn unit_ty(&mut self) -> Ty<'tcx> {
self.tcx.mk_nil()
self.tcx.mk_unit()
}

pub fn true_literal(&mut self) -> &'tcx ty::Const<'tcx> {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> {
layout: self.layout_of(self.tcx.mk_mut_ptr(place.layout.ty))?,
};

let ty = self.tcx.mk_nil(); // return type is ()
let ty = self.tcx.mk_unit(); // return type is ()
let dest = PlaceTy::null(&self, self.layout_of(ty)?);

self.eval_fn_call(
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/transform/generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ fn compute_layout<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}

let upvar_len = mir.upvar_decls.len();
let dummy_local = LocalDecl::new_internal(tcx.mk_nil(), mir.span);
let dummy_local = LocalDecl::new_internal(tcx.mk_unit(), mir.span);

// Gather live locals and their indices replacing values in mir.local_decls with a dummy
// to avoid changing local indices
Expand Down Expand Up @@ -655,7 +655,7 @@ fn create_generator_drop_shim<'a, 'tcx>(
// Replace the return variable
mir.local_decls[RETURN_PLACE] = LocalDecl {
mutability: Mutability::Mut,
ty: tcx.mk_nil(),
ty: tcx.mk_unit(),
name: None,
source_info,
visibility_scope: source_info.scope,
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir/util/elaborate_drops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
mutbl: hir::Mutability::MutMutable
});
let ref_place = self.new_temp(ref_ty);
let unit_temp = Place::Local(self.new_temp(tcx.mk_nil()));
let unit_temp = Place::Local(self.new_temp(tcx.mk_unit()));

let result = BasicBlockData {
statements: vec![self.assign(
Expand Down Expand Up @@ -891,7 +891,7 @@ impl<'l, 'b, 'tcx, D> DropCtxt<'l, 'b, 'tcx, D>
unwind: Unwind
) -> BasicBlock {
let tcx = self.tcx();
let unit_temp = Place::Local(self.new_temp(tcx.mk_nil()));
let unit_temp = Place::Local(self.new_temp(tcx.mk_unit()));
let free_func = tcx.require_lang_item(lang_items::BoxFreeFnLangItem);
let args = adt.variants[0].fields.iter().enumerate().map(|(i, f)| {
let field = Field::new(i);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/astconv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ impl<'o, 'gcx: 'tcx, 'tcx> dyn AstConv<'gcx, 'tcx>+'o {

let output_ty = match decl.output {
hir::Return(ref output) => self.ast_ty_to_ty(output),
hir::DefaultReturn(..) => tcx.mk_nil(),
hir::DefaultReturn(..) => tcx.mk_unit(),
};

debug!("ty_of_fn: output_ty={:?}", output_ty);
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/_match.rs
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,7 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
// us to give better error messages (pointing to a usually better
// arm for inconsistent arms or to the whole match when a `()` type
// is required).
Expectation::ExpectHasType(ety) if ety != self.tcx.mk_nil() => ety,
Expectation::ExpectHasType(ety) if ety != self.tcx.mk_unit() => ety,
_ => self.next_ty_var(TypeVariableOrigin::MiscVariable(expr.span)),
};
CoerceMany::with_coercion_sites(coerce_first, arms)
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/coercion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1077,7 +1077,7 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
self.coerce_inner(fcx,
cause,
None,
fcx.tcx.mk_nil(),
fcx.tcx.mk_unit(),
Some(augment_error),
label_unit_as_expected)
}
Expand Down
28 changes: 14 additions & 14 deletions src/librustc_typeck/check/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
"load" => (1, vec![tcx.mk_imm_ptr(param(0))],
param(0)),
"store" => (1, vec![tcx.mk_mut_ptr(param(0)), param(0)],
tcx.mk_nil()),
tcx.mk_unit()),

"xchg" | "xadd" | "xsub" | "and" | "nand" | "or" | "xor" | "max" |
"min" | "umax" | "umin" => {
(1, vec![tcx.mk_mut_ptr(param(0)), param(0)],
param(0))
}
"fence" | "singlethreadfence" => {
(0, Vec::new(), tcx.mk_nil())
(0, Vec::new(), tcx.mk_unit())
}
op => {
struct_span_err!(tcx.sess, it.span, E0092,
Expand All @@ -121,7 +121,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
_ => hir::Unsafety::Unsafe,
};
let (n_tps, inputs, output) = match &name[..] {
"breakpoint" => (0, Vec::new(), tcx.mk_nil()),
"breakpoint" => (0, Vec::new(), tcx.mk_unit()),
"size_of" |
"pref_align_of" | "min_align_of" => (1, Vec::new(), tcx.types.usize),
"size_of_val" | "min_align_of_val" => {
Expand All @@ -141,18 +141,18 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx.mk_mut_ptr(param(0)),
param(0)
],
tcx.mk_nil())
tcx.mk_unit())
}
"prefetch_read_data" | "prefetch_write_data" |
"prefetch_read_instruction" | "prefetch_write_instruction" => {
(1, vec![tcx.mk_ptr(ty::TypeAndMut {
ty: param(0),
mutbl: hir::MutImmutable
}), tcx.types.i32],
tcx.mk_nil())
tcx.mk_unit())
}
"drop_in_place" => {
(1, vec![tcx.mk_mut_ptr(param(0))], tcx.mk_nil())
(1, vec![tcx.mk_mut_ptr(param(0))], tcx.mk_unit())
}
"needs_drop" => (1, Vec::new(), tcx.types.bool),

Expand Down Expand Up @@ -185,7 +185,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}),
tcx.types.usize,
],
tcx.mk_nil())
tcx.mk_unit())
}
"volatile_copy_memory" | "volatile_copy_nonoverlapping_memory" => {
(1,
Expand All @@ -200,7 +200,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}),
tcx.types.usize,
],
tcx.mk_nil())
tcx.mk_unit())
}
"write_bytes" | "volatile_set_memory" => {
(1,
Expand All @@ -212,7 +212,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
tcx.types.u8,
tcx.types.usize,
],
tcx.mk_nil())
tcx.mk_unit())
}
"sqrtf32" => (0, vec![ tcx.types.f32 ], tcx.types.f32),
"sqrtf64" => (0, vec![ tcx.types.f64 ], tcx.types.f64),
Expand Down Expand Up @@ -280,7 +280,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
"volatile_load" | "unaligned_volatile_load" =>
(1, vec![ tcx.mk_imm_ptr(param(0)) ], param(0)),
"volatile_store" | "unaligned_volatile_store" =>
(1, vec![ tcx.mk_mut_ptr(param(0)), param(0) ], tcx.mk_nil()),
(1, vec![ tcx.mk_mut_ptr(param(0)), param(0) ], tcx.mk_unit()),

"ctpop" | "ctlz" | "ctlz_nonzero" | "cttz" | "cttz_nonzero" |
"bswap" | "bitreverse" =>
Expand All @@ -300,7 +300,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
"fadd_fast" | "fsub_fast" | "fmul_fast" | "fdiv_fast" | "frem_fast" =>
(1, vec![param(0), param(0)], param(0)),

"assume" => (0, vec![tcx.types.bool], tcx.mk_nil()),
"assume" => (0, vec![tcx.types.bool], tcx.mk_unit()),
"likely" => (0, vec![tcx.types.bool], tcx.types.bool),
"unlikely" => (0, vec![tcx.types.bool], tcx.types.bool),

Expand All @@ -313,7 +313,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let mut_u8 = tcx.mk_mut_ptr(tcx.types.u8);
let fn_ty = ty::Binder::bind(tcx.mk_fn_sig(
iter::once(mut_u8),
tcx.mk_nil(),
tcx.mk_unit(),
false,
hir::Unsafety::Normal,
Abi::Rust,
Expand All @@ -322,7 +322,7 @@ pub fn check_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
}

"nontemporal_store" => {
(1, vec![ tcx.mk_mut_ptr(param(0)), param(0) ], tcx.mk_nil())
(1, vec![ tcx.mk_mut_ptr(param(0)), param(0) ], tcx.mk_unit())
}

ref other => {
Expand Down Expand Up @@ -376,7 +376,7 @@ pub fn check_platform_intrinsic_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
(3, vec![param(0), param(1), param(2)], param(0))
}
"simd_scatter" => {
(3, vec![param(0), param(1), param(2)], tcx.mk_nil())
(3, vec![param(0), param(1), param(2)], tcx.mk_unit())
}
"simd_insert" => (2, vec![param(0), tcx.types.u32, param(1)], param(0)),
"simd_extract" => (2, vec![param(0), tcx.types.u32], param(1)),
Expand Down
16 changes: 8 additions & 8 deletions src/librustc_typeck/check/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3918,7 +3918,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
for input in inputs {
self.check_expr(input);
}
tcx.mk_nil()
tcx.mk_unit()
}
hir::ExprKind::Break(destination, ref expr_opt) => {
if let Ok(target_id) = destination.target_id {
Expand All @@ -3945,7 +3945,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
} else {
// Otherwise, this is a break *without* a value. That's
// always legal, and is equivalent to `break ()`.
e_ty = tcx.mk_nil();
e_ty = tcx.mk_unit();
cause = self.misc(expr.span);
}

Expand Down Expand Up @@ -4052,7 +4052,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
if lhs_ty.references_error() || rhs_ty.references_error() {
tcx.types.err
} else {
tcx.mk_nil()
tcx.mk_unit()
}
}
hir::ExprKind::If(ref cond, ref then_expr, ref opt_else_expr) => {
Expand Down Expand Up @@ -4081,7 +4081,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
self.diverges.set(Diverges::Maybe);
}

self.tcx.mk_nil()
self.tcx.mk_unit()
}
hir::ExprKind::Loop(ref body, _, source) => {
let coerce = match source {
Expand Down Expand Up @@ -4121,7 +4121,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
// [1]
self.tcx.sess.delay_span_bug(body.span, "no coercion, but loop may not break");
}
ctxt.coerce.map(|c| c.complete(self)).unwrap_or(self.tcx.mk_nil())
ctxt.coerce.map(|c| c.complete(self)).unwrap_or(self.tcx.mk_unit())
}
hir::ExprKind::Match(ref discrim, ref arms, match_src) => {
self.check_match(expr, &discrim, arms, expected, match_src)
Expand Down Expand Up @@ -4352,7 +4352,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
"yield statement outside of generator literal").emit();
}
}
tcx.mk_nil()
tcx.mk_unit()
}
}
}
Expand Down Expand Up @@ -4516,7 +4516,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}
hir::StmtKind::Expr(ref expr, _) => {
// Check with expected type of ()
self.check_expr_has_type_or_error(&expr, self.tcx.mk_nil());
self.check_expr_has_type_or_error(&expr, self.tcx.mk_unit());
}
hir::StmtKind::Semi(ref expr, _) => {
self.check_expr(&expr);
Expand All @@ -4529,7 +4529,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
}

pub fn check_block_no_value(&self, blk: &'gcx hir::Block) {
let unit = self.tcx.mk_nil();
let unit = self.tcx.mk_unit();
let ty = self.check_block_with_expected(blk, ExpectHasType(unit));

// if the block produces a `!` value, that can always be
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/check/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
let ty = if !lhs_ty.is_ty_var() && !rhs_ty.is_ty_var()
&& is_builtin_binop(lhs_ty, rhs_ty, op) {
self.enforce_builtin_binop_types(lhs_expr, lhs_ty, rhs_expr, rhs_ty, op);
self.tcx.mk_nil()
self.tcx.mk_unit()
} else {
return_ty
};
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_typeck/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ fn check_main_fn_ty<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
actual.output().skip_binder()
} else {
// standard () main return type
tcx.mk_nil()
tcx.mk_unit()
};

let se_ty = tcx.mk_fn_ptr(ty::Binder::bind(
Expand Down

0 comments on commit 5c3ba4a

Please sign in to comment.