Skip to content

Commit 539743b

Browse files
committed
code cleanup and do not suggest for external macro except we get better solution
1 parent 9a6d414 commit 539743b

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

Diff for: compiler/rustc_hir_typeck/src/coercion.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1889,9 +1889,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
18891889
fcx.err_ctxt().report_mismatched_types(cause, fcx.param_env, expected, found, ty_err);
18901890

18911891
let due_to_block = matches!(fcx.tcx.hir_node(block_or_return_id), hir::Node::Block(..));
1892-
1893-
let parent_id = fcx.tcx.parent_hir_id(block_or_return_id);
1894-
let parent = fcx.tcx.hir_node(parent_id);
1892+
let parent = fcx.tcx.parent_hir_node(block_or_return_id);
18951893
if let Some(expr) = expression
18961894
&& let hir::Node::Expr(hir::Expr {
18971895
kind: hir::ExprKind::Closure(&hir::Closure { body, .. }),

Diff for: compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -788,16 +788,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
788788
);
789789
}
790790
}
791-
ExprKind::Path(..) | ExprKind::Lit(_) if parent_is_closure => {
791+
ExprKind::Path(..) | ExprKind::Lit(_)
792+
if parent_is_closure && !in_external_macro(self.tcx.sess, expression.span) =>
793+
{
792794
err.span_suggestion_verbose(
793795
expression.span.shrink_to_lo(),
794796
"consider ignoring the value",
795797
"_ = ",
796-
if in_external_macro(self.tcx.sess, expression.span) {
797-
Applicability::MaybeIncorrect
798-
} else {
799-
Applicability::MachineApplicable
800-
},
798+
Applicability::MachineApplicable,
801799
);
802800
}
803801
_ => (),

0 commit comments

Comments
 (0)