renamed is_nil to is_unit
This commit is contained in:
parent
7f8160409f
commit
a0e7b6bf6b
10 changed files with 18 additions and 18 deletions
|
@ -1458,7 +1458,7 @@ impl RegionKind {
|
|||
|
||||
/// Type utilities
|
||||
impl<'a, 'gcx, 'tcx> TyS<'tcx> {
|
||||
pub fn is_nil(&self) -> bool {
|
||||
pub fn is_unit(&self) -> bool {
|
||||
match self.sty {
|
||||
Tuple(ref tys) => tys.is_empty(),
|
||||
_ => false,
|
||||
|
|
|
@ -234,7 +234,7 @@ impl PrintContext {
|
|||
}
|
||||
}
|
||||
write!(f, ")")?;
|
||||
if !output.is_nil() {
|
||||
if !output.is_unit() {
|
||||
print!(f, self, write(" -> "), print_display(output))?;
|
||||
}
|
||||
|
||||
|
|
|
@ -160,7 +160,7 @@ pub fn push_debuginfo_type_name<'a, 'tcx>(cx: &CodegenCx<'a, 'tcx>,
|
|||
|
||||
output.push(')');
|
||||
|
||||
if !sig.output().is_nil() {
|
||||
if !sig.output().is_unit() {
|
||||
output.push_str(" -> ");
|
||||
push_debuginfo_type_name(cx, sig.output(), true, output);
|
||||
}
|
||||
|
|
|
@ -566,7 +566,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
) -> &'ll Value {
|
||||
let is_float = input_ty.is_fp();
|
||||
let is_signed = input_ty.is_signed();
|
||||
let is_nil = input_ty.is_nil();
|
||||
let is_unit = input_ty.is_unit();
|
||||
match op {
|
||||
mir::BinOp::Add => if is_float {
|
||||
bx.fadd(lhs, rhs)
|
||||
|
@ -604,7 +604,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
|
|||
mir::BinOp::Shl => common::build_unchecked_lshift(bx, lhs, rhs),
|
||||
mir::BinOp::Shr => common::build_unchecked_rshift(bx, input_ty, lhs, rhs),
|
||||
mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt |
|
||||
mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_nil {
|
||||
mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => if is_unit {
|
||||
C_bool(bx.cx, match op {
|
||||
mir::BinOp::Ne | mir::BinOp::Lt | mir::BinOp::Gt => false,
|
||||
mir::BinOp::Eq | mir::BinOp::Le | mir::BinOp::Ge => true,
|
||||
|
|
|
@ -691,7 +691,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
let sig = cx.erase_late_bound_regions(&sig);
|
||||
if !sig.output().is_nil() {
|
||||
if !sig.output().is_unit() {
|
||||
let r = self.check_type_for_ffi(cache, sig.output());
|
||||
match r {
|
||||
FfiSafe => {}
|
||||
|
@ -767,7 +767,7 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
|
||||
if let hir::Return(ref ret_hir) = decl.output {
|
||||
let ret_ty = sig.output();
|
||||
if !ret_ty.is_nil() {
|
||||
if !ret_ty.is_unit() {
|
||||
self.check_type_for_ffi_and_report_errors(ret_hir.span, ret_ty);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -177,7 +177,7 @@ impl<'a, 'gcx, 'tcx> Builder<'a, 'gcx, 'tcx> {
|
|||
// the case of `!`, no return value is required, as the block will never return.
|
||||
let tcx = this.hir.tcx();
|
||||
let ty = destination.ty(&this.local_decls, tcx).to_ty(tcx);
|
||||
if ty.is_nil() {
|
||||
if ty.is_unit() {
|
||||
// We only want to assign an implicit `()` as the return value of the block if the
|
||||
// block does not diverge. (Otherwise, we may try to assign a unit to a `!`-type.)
|
||||
this.cfg.push_assign_unit(block, source_info, destination);
|
||||
|
|
|
@ -368,7 +368,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
|
|||
|
||||
output.push(')');
|
||||
|
||||
if !sig.output().is_nil() {
|
||||
if !sig.output().is_unit() {
|
||||
output.push_str(" -> ");
|
||||
self.push_type_name(sig.output(), output);
|
||||
}
|
||||
|
|
|
@ -677,14 +677,14 @@ https://doc.rust-lang.org/reference/types.html#trait-objects");
|
|||
// Handle the fallback arm of a desugared if-let like a missing else.
|
||||
let is_if_let_fallback = match match_src {
|
||||
hir::MatchSource::IfLetDesugar { contains_else_clause: false } => {
|
||||
i == arms.len() - 1 && arm_ty.is_nil()
|
||||
i == arms.len() - 1 && arm_ty.is_unit()
|
||||
}
|
||||
_ => false
|
||||
};
|
||||
|
||||
if is_if_let_fallback {
|
||||
let cause = self.cause(expr.span, ObligationCauseCode::IfExpressionWithNoElse);
|
||||
assert!(arm_ty.is_nil());
|
||||
assert!(arm_ty.is_unit());
|
||||
coercion.coerce_forced_unit(self, &cause, &mut |_| (), true);
|
||||
} else {
|
||||
let cause = self.cause(expr.span, ObligationCauseCode::MatchExpressionArm {
|
||||
|
|
|
@ -1146,8 +1146,8 @@ impl<'gcx, 'tcx, 'exprs, E> CoerceMany<'gcx, 'tcx, 'exprs, E>
|
|||
// `expression_ty` will be unit).
|
||||
//
|
||||
// Another example is `break` with no argument expression.
|
||||
assert!(expression_ty.is_nil());
|
||||
assert!(expression_ty.is_nil(), "if let hack without unit type");
|
||||
assert!(expression_ty.is_unit());
|
||||
assert!(expression_ty.is_unit(), "if let hack without unit type");
|
||||
fcx.at(cause, fcx.param_env)
|
||||
.eq_exp(label_expression_as_expected, expression_ty, self.merged_ty())
|
||||
.map(|infer_ok| {
|
||||
|
|
|
@ -2808,9 +2808,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
} else {
|
||||
// is the missing argument of type `()`?
|
||||
let sugg_unit = if expected_arg_tys.len() == 1 && supplied_arg_count == 0 {
|
||||
self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_nil()
|
||||
self.resolve_type_vars_if_possible(&expected_arg_tys[0]).is_unit()
|
||||
} else if fn_inputs.len() == 1 && supplied_arg_count == 0 {
|
||||
self.resolve_type_vars_if_possible(&fn_inputs[0]).is_nil()
|
||||
self.resolve_type_vars_if_possible(&fn_inputs[0]).is_unit()
|
||||
} else {
|
||||
false
|
||||
};
|
||||
|
@ -3958,7 +3958,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
if let Some(ref e) = *expr_opt {
|
||||
coerce.coerce(self, &cause, e, e_ty);
|
||||
} else {
|
||||
assert!(e_ty.is_nil());
|
||||
assert!(e_ty.is_unit());
|
||||
coerce.coerce_forced_unit(self, &cause, &mut |_| (), true);
|
||||
}
|
||||
} else {
|
||||
|
@ -4752,7 +4752,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
expression: &'gcx hir::Expr,
|
||||
expected: Ty<'tcx>,
|
||||
cause_span: Span) {
|
||||
if expected.is_nil() {
|
||||
if expected.is_unit() {
|
||||
// `BlockTailExpression` only relevant if the tail expr would be
|
||||
// useful on its own.
|
||||
match expression.node {
|
||||
|
@ -4795,7 +4795,7 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
|
|||
can_suggest: bool) {
|
||||
// Only suggest changing the return type for methods that
|
||||
// haven't set a return type at all (and aren't `fn main()` or an impl).
|
||||
match (&fn_decl.output, found.is_suggestable(), can_suggest, expected.is_nil()) {
|
||||
match (&fn_decl.output, found.is_suggestable(), can_suggest, expected.is_unit()) {
|
||||
(&hir::FunctionRetTy::DefaultReturn(span), true, true, true) => {
|
||||
err.span_suggestion_with_applicability(
|
||||
span,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue