Skip to content

Commit f65403d

Browse files
committed
Supress swapping lhs and rhs in equality suggestion in extern macro
Signed-off-by: xizheyin <[email protected]>
1 parent 907e2b8 commit f65403d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3533,6 +3533,12 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
35333533
.must_apply_modulo_regions()
35343534
{
35353535
let sm = self.tcx.sess.source_map();
3536+
// If the span of rhs_expr is in an external macro,
3537+
// we should not suggest to swap the equality. See issue #139050
3538+
if rhs_expr.span.in_external_macro(sm) {
3539+
return;
3540+
}
3541+
35363542
if let Ok(rhs_snippet) = sm.span_to_snippet(rhs_expr.span)
35373543
&& let Ok(lhs_snippet) = sm.span_to_snippet(lhs_expr.span)
35383544
{

0 commit comments

Comments
 (0)