Skip to content

Commit 7753df3

Browse files
committed
Suppress suggestions on deref in macro when == is in extern macro
Signed-off-by: xizheyin <[email protected]>
1 parent c0c69cf commit 7753df3

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs

+4
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,10 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
449449
err: &mut Diag<'_>,
450450
trait_pred: ty::PolyTraitPredicate<'tcx>,
451451
) -> bool {
452+
if obligation.cause.span.in_external_macro(self.infcx.tcx.sess.source_map()) {
453+
return false;
454+
}
455+
452456
let mut code = obligation.cause.code();
453457
if let ObligationCauseCode::FunctionArg { arg_hir_id, call_hir_id, .. } = code
454458
&& let Some(typeck_results) = &self.typeck_results

tests/ui/macros/dont-suggest-within-macro-issue-139251.stderr

+10
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ LL | assert_eq!(y, 2);
1717
| ^^^^^^^^^^^^^^^^ no implementation for `&{integer} == {integer}`
1818
|
1919
= help: the trait `PartialEq<{integer}>` is not implemented for `&{integer}`
20+
= help: the following other types implement trait `PartialEq<Rhs>`:
21+
f128
22+
f16
23+
f32
24+
f64
25+
i128
26+
i16
27+
i32
28+
i64
29+
and 8 others
2030
= note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
2131

2232
error[E0277]: can't compare `&{integer}` with `{integer}`

0 commit comments

Comments
 (0)