Tweak output
This commit is contained in:
parent
1fa6ada9dd
commit
031e085450
4 changed files with 44 additions and 66 deletions
|
|
@ -224,14 +224,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
let mut ret_span: MultiSpan = semi_span.into();
|
||||
ret_span.push_span_label(
|
||||
expr.span,
|
||||
"this could be implicitly returned but it is a statement, not a \
|
||||
tail expression",
|
||||
"this could be implicitly returned but it is a statement, not a tail expression",
|
||||
);
|
||||
ret_span.push_span_label(ret, "the `match` arms can conform to this return type");
|
||||
ret_span.push_span_label(
|
||||
semi_span,
|
||||
"the `match` is a statement because of this semicolon, consider \
|
||||
removing it",
|
||||
"the `match` is a statement because of this semicolon, consider removing it",
|
||||
);
|
||||
diag.span_note(ret_span, "you might have meant to return the `match` expression");
|
||||
diag.tool_only_span_suggestion(
|
||||
|
|
|
|||
|
|
@ -1699,20 +1699,20 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
|||
return;
|
||||
}
|
||||
let [.., stmt] = block.stmts else {
|
||||
err.span_help(block.span, "this empty block is missing a tail expression");
|
||||
err.span_label(block.span, "this empty block is missing a tail expression");
|
||||
return;
|
||||
};
|
||||
let hir::StmtKind::Semi(tail_expr) = stmt.kind else { return; };
|
||||
let Some(ty) = self.node_ty_opt(tail_expr.hir_id) else { return; };
|
||||
if self.can_eq(self.param_env, expected_ty, ty).is_ok() {
|
||||
err.span_suggestion_verbose(
|
||||
err.span_suggestion_short(
|
||||
stmt.span.with_lo(tail_expr.span.hi()),
|
||||
"remove this semicolon",
|
||||
"",
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
} else {
|
||||
err.span_help(block.span, "this block is missing a tail expression");
|
||||
err.span_label(block.span, "this block is missing a tail expression");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1077,12 +1077,12 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
return;
|
||||
}
|
||||
let [.., stmt] = block.stmts else {
|
||||
err.span_help(block.span, "this empty block is missing a tail expression");
|
||||
err.span_label(block.span, "this empty block is missing a tail expression");
|
||||
return;
|
||||
};
|
||||
let hir::StmtKind::Semi(tail_expr) = stmt.kind else { return; };
|
||||
let Some(ty) = typeck.expr_ty_opt(tail_expr) else {
|
||||
err.span_help(block.span, "this block is missing a tail expression");
|
||||
err.span_label(block.span, "this block is missing a tail expression");
|
||||
return;
|
||||
};
|
||||
let ty = self.resolve_numeric_literals_with_default(self.resolve_vars_if_possible(ty));
|
||||
|
|
@ -1091,14 +1091,14 @@ impl<'tcx> TypeErrCtxtExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
|
|||
let new_obligation =
|
||||
self.mk_trait_obligation_with_new_self_ty(obligation.param_env, trait_pred_and_self);
|
||||
if self.predicate_must_hold_modulo_regions(&new_obligation) {
|
||||
err.span_suggestion_verbose(
|
||||
err.span_suggestion_short(
|
||||
stmt.span.with_lo(tail_expr.span.hi()),
|
||||
"remove this semicolon",
|
||||
"",
|
||||
Applicability::MachineApplicable,
|
||||
);
|
||||
} else {
|
||||
err.span_help(block.span, "this block is missing a tail expression");
|
||||
err.span_label(block.span, "this block is missing a tail expression");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue