Skip to content

Commit 30085b0

Browse files
Check in push_suggestion
1 parent 8ac80a9 commit 30085b0

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

compiler/rustc_errors/src/diagnostic.rs

+9
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,15 @@ impl Diagnostic {
531531

532532
/// Helper for pushing to `self.suggestions`, if available (not disable).
533533
fn push_suggestion(&mut self, suggestion: CodeSuggestion) {
534+
let in_derive = suggestion
535+
.substitutions
536+
.iter()
537+
.any(|subst| subst.parts.iter().any(|part| part.span.in_derive_expansion()));
538+
if in_derive {
539+
// Ignore if spans is from derive macro.
540+
return;
541+
}
542+
534543
if let Ok(suggestions) = &mut self.suggestions {
535544
suggestions.push(suggestion);
536545
}

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

-5
Original file line numberDiff line numberDiff line change
@@ -2692,11 +2692,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26922692
return false;
26932693
}
26942694

2695-
if expr.span.in_derive_expansion() {
2696-
// Ignore if span is from derive macro.
2697-
return false;
2698-
}
2699-
27002695
let Ok(src) = self.tcx.sess.source_map().span_to_snippet(expr.span) else {
27012696
return false;
27022697
};

0 commit comments

Comments
 (0)