Skip to content

Commit fd840ca

Browse files
committed
code cleanup and do not suggest for external macro except we get better solution
1 parent d6d9c2e commit fd840ca

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
@@ -1883,9 +1883,7 @@ impl<'tcx, 'exprs, E: AsCoercionSite> CoerceMany<'tcx, 'exprs, E> {
18831883
fcx.err_ctxt().report_mismatched_types(cause, fcx.param_env, expected, found, ty_err);
18841884

18851885
let due_to_block = matches!(fcx.tcx.hir_node(block_or_return_id), hir::Node::Block(..));
1886-
1887-
let parent_id = fcx.tcx.parent_hir_id(block_or_return_id);
1888-
let parent = fcx.tcx.hir_node(parent_id);
1886+
let parent = fcx.tcx.parent_hir_node(block_or_return_id);
18891887
if let Some(expr) = expression
18901888
&& let hir::Node::Expr(hir::Expr {
18911889
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
@@ -790,16 +790,14 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
790790
);
791791
}
792792
}
793-
ExprKind::Path(..) | ExprKind::Lit(_) if parent_is_closure => {
793+
ExprKind::Path(..) | ExprKind::Lit(_)
794+
if parent_is_closure && !in_external_macro(self.tcx.sess, expression.span) =>
795+
{
794796
err.span_suggestion_verbose(
795797
expression.span.shrink_to_lo(),
796798
"consider ignoring the value",
797799
"_ = ",
798-
if in_external_macro(self.tcx.sess, expression.span) {
799-
Applicability::MaybeIncorrect
800-
} else {
801-
Applicability::MachineApplicable
802-
},
800+
Applicability::MachineApplicable,
803801
);
804802
}
805803
_ => (),

0 commit comments

Comments
 (0)