Skip to content

Commit a0e7b6b

Browse files
committed
renamed is_nil to is_unit
1 parent 7f81604 commit a0e7b6b

File tree

10 files changed

+18
-18
lines changed

10 files changed

+18
-18
lines changed

src/librustc/ty/sty.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ impl RegionKind {
14581458

14591459
/// Type utilities
14601460
impl<'a, 'gcx, 'tcx> TyS<'tcx> {
1461-
pub fn is_nil(&self) -> bool {
1461+
pub fn is_unit(&self) -> bool {
14621462
match self.sty {
14631463
Tuple(ref tys) => tys.is_empty(),
14641464
_ => false,

src/librustc/util/ppaux.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl PrintContext {
234234
}
235235
}
236236
write!(f, ")")?;
237-
if !output.is_nil() {
237+
if !output.is_unit() {
238238
print!(f, self, write(" -> "), print_display(output))?;
239239
}
240240

src/librustc_codegen_llvm/debuginfo/type_names.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
160160

161161
output.push(')');
162162

163-
if !sig.output().is_nil() {
163+
if !sig.output().is_unit() {
164164
output.push_str(" -> ");
165165
push_debuginfo_type_name(cx, sig.output(), true, output);
166166
}

src/librustc_codegen_llvm/mir/rvalue.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
566566
) -> &'ll Value {
567567
let is_float = input_ty.is_fp();
568568
let is_signed = input_ty.is_signed();
569-
let is_nil = input_ty.is_nil();
569+
let is_unit = input_ty.is_unit();
570570
match op {
571571
mir::BinOp::Add => if is_float {
572572
bx.fadd(lhs, rhs)
@@ -604,7 +604,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
604604
mir::BinOp::Shl => common::build_unchecked_lshift(bx, lhs, rhs),
605605
mir::BinOp::Shr => common::build_unchecked_rshift(bx, input_ty, lhs, rhs),
606606
mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt |
607-
mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_nil {
607+
mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_unit {
608608
C_bool(bx.cx, match op {
609609
mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt => false,
610610
mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => true,

src/librustc_lint/types.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
691691
}
692692

693693
let sig = cx.erase_late_bound_regions(&sig);
694-
if !sig.output().is_nil() {
694+
if !sig.output().is_unit() {
695695
let r = self.check_type_for_ffi(cache, sig.output());
696696
match r {
697697
FfiSafe => {}
@@ -767,7 +767,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
767767

768768
if let hir::Return(ref ret_hir) = decl.output {
769769
let ret_ty = sig.output();
770-
if !ret_ty.is_nil() {
770+
if !ret_ty.is_unit() {
771771
self.check_type_for_ffi_and_report_errors(ret_hir.span, ret_ty);
772772
}
773773
}

src/librustc_mir/build/block.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
177177
// the case of `!`, no return value is required, as the block will never return.
178178
let tcx = this.hir.tcx();
179179
let ty = destination.ty(&this.local_decls, tcx).to_ty(tcx);
180-
if ty.is_nil() {
180+
if ty.is_unit() {
181181
// We only want to assign an implicit `()` as the return value of the block if the
182182
// block does not diverge. (Otherwise, we may try to assign a unit to a `!`-type.)
183183
this.cfg.push_assign_unit(block, source_info, destination);

src/librustc_mir/monomorphize/item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
368368

369369
output.push(')');
370370

371-
if !sig.output().is_nil() {
371+
if !sig.output().is_unit() {
372372
output.push_str(" -> ");
373373
self.push_type_name(sig.output(), output);
374374
}

src/librustc_typeck/check/_match.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -677,14 +677,14 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
677677
// Handle the fallback arm of a desugared if-let like a missing else.
678678
let is_if_let_fallback = match match_src {
679679
hir::MatchSource::IfLetDesugar { contains_else_clause: false } => {
680-
i == arms.len() - 1 && arm_ty.is_nil()
680+
i == arms.len() - 1 && arm_ty.is_unit()
681681
}
682682
_ => false
683683
};
684684

685685
if is_if_let_fallback {
686686
let cause = self.cause(expr.span, ObligationCauseCode::IfExpressionWithNoElse);
687-
assert!(arm_ty.is_nil());
687+
assert!(arm_ty.is_unit());
688688
coercion.coerce_forced_unit(self, &cause, &mut |_| (), true);
689689
} else {
690690
let cause = self.cause(expr.span, ObligationCauseCode::MatchExpressionArm {

src/librustc_typeck/check/coercion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1146,8 +1146,8 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
11461146
// `expression_ty` will be unit).
11471147
//
11481148
// Another example is `break` with no argument expression.
1149-
assert!(expression_ty.is_nil());
1150-
assert!(expression_ty.is_nil(), "if let hack without unit type");
1149+
assert!(expression_ty.is_unit());
1150+
assert!(expression_ty.is_unit(), "if let hack without unit type");
11511151
fcx.at(cause, fcx.param_env)
11521152
.eq_exp(label_expression_as_expected, expression_ty, self.merged_ty())
11531153
.map(|infer_ok| {

src/librustc_typeck/check/mod.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2808,9 +2808,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
28082808
} else {
28092809
// is the missing argument of type `()`?
28102810
let sugg_unit = if expected_arg_tys.len() == 1 && supplied_arg_count == 0 {
2811-
self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_nil()
2811+
self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_unit()
28122812
} else if fn_inputs.len() == 1 && supplied_arg_count == 0 {
2813-
self.resolve_type_vars_if_possible(&fn_inputs[0]).is_nil()
2813+
self.resolve_type_vars_if_possible(&fn_inputs[0]).is_unit()
28142814
} else {
28152815
false
28162816
};
@@ -3958,7 +3958,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
39583958
if let Some(ref e) = *expr_opt {
39593959
coerce.coerce(self, &cause, e, e_ty);
39603960
} else {
3961-
assert!(e_ty.is_nil());
3961+
assert!(e_ty.is_unit());
39623962
coerce.coerce_forced_unit(self, &cause, &mut |_| (), true);
39633963
}
39643964
} else {
@@ -4752,7 +4752,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47524752
expression: &'gcx hir::Expr,
47534753
expected: Ty<'tcx>,
47544754
cause_span: Span) {
4755-
if expected.is_nil() {
4755+
if expected.is_unit() {
47564756
// `BlockTailExpression` only relevant if the tail expr would be
47574757
// useful on its own.
47584758
match expression.node {
@@ -4795,7 +4795,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
47954795
can_suggest: bool) {
47964796
// Only suggest changing the return type for methods that
47974797
// haven't set a return type at all (and aren't `fn main()` or an impl).
4798-
match (&fn_decl.output, found.is_suggestable(), can_suggest, expected.is_nil()) {
4798+
match (&fn_decl.output, found.is_suggestable(), can_suggest, expected.is_unit()) {
47994799
(&hir::FunctionRetTy::DefaultReturn(span), true, true, true) => {
48004800
err.span_suggestion_with_applicability(
48014801
span,

0 commit comments

Comments
 (0)