From 87ea0d76fe1ae997a11fbc914daf33644d5c65bf Mon Sep 17 00:00:00 2001 From: long-long-float Date: Wed, 13 Dec 2023 01:43:10 +0900 Subject: [PATCH] Suppress suggestions in derive macro --- compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs index 5395ffda1d1..aeab3629ece 100644 --- a/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs +++ b/compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs @@ -2698,6 +2698,11 @@ pub(crate) fn suggest_cast( return false; } + if expr.span.in_derive_expansion() { + // Ignore if span is from derive macro. + return false; + } + let Ok(src) = self.tcx.sess.source_map().span_to_snippet(expr.span) else { return false; };