use appropriate HirID
for finding else_span
This commit is contained in:
parent
a2318651d4
commit
03622552ec
1 changed files with 10 additions and 6 deletions
|
@ -712,7 +712,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
opt_suggest_box_span,
|
opt_suggest_box_span,
|
||||||
}) => {
|
}) => {
|
||||||
let then_span = self.find_block_span_from_hir_id(then_id);
|
let then_span = self.find_block_span_from_hir_id(then_id);
|
||||||
let else_span = self.find_block_span_from_hir_id(then_id);
|
let else_span = self.find_block_span_from_hir_id(else_id);
|
||||||
err.span_label(then_span, "expected because of this");
|
err.span_label(then_span, "expected because of this");
|
||||||
if let Some(sp) = outer_span {
|
if let Some(sp) = outer_span {
|
||||||
err.span_label(sp, "`if` and `else` have incompatible types");
|
err.span_label(sp, "`if` and `else` have incompatible types");
|
||||||
|
@ -760,8 +760,12 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
||||||
second_ty: Ty<'tcx>,
|
second_ty: Ty<'tcx>,
|
||||||
second_span: Span,
|
second_span: Span,
|
||||||
) {
|
) {
|
||||||
let remove_semicolon =
|
let remove_semicolon = [
|
||||||
[(first_id, second_ty), (second_id, first_ty)].into_iter().find_map(|(id, ty)| {
|
(first_id, self.resolve_vars_if_possible(second_ty)),
|
||||||
|
(second_id, self.resolve_vars_if_possible(first_ty)),
|
||||||
|
]
|
||||||
|
.into_iter()
|
||||||
|
.find_map(|(id, ty)| {
|
||||||
let hir::Node::Block(blk) = self.tcx.hir().get(id?) else { return None };
|
let hir::Node::Block(blk) = self.tcx.hir().get(id?) else { return None };
|
||||||
self.could_remove_semicolon(blk, ty)
|
self.could_remove_semicolon(blk, ty)
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue