Skip to content

Commit 4909258

Browse files
Check in push_suggestion
1 parent 87ea0d7 commit 4909258

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,15 @@ impl Diagnostic {
519519

520520
/// Helper for pushing to `self.suggestions`, if available (not disable).
521521
fn push_suggestion(&mut self, suggestion: CodeSuggestion) {
522+
let in_derive = suggestion
523+
.substitutions
524+
.iter()
525+
.any(|subst| subst.parts.iter().any(|part| part.span.in_derive_expansion()));
526+
if in_derive {
527+
// Ignore if spans is from derive macro.
528+
return;
529+
}
530+
522531
if let Ok(suggestions) = &mut self.suggestions {
523532
suggestions.push(suggestion);
524533
}

compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,11 +2698,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
26982698
return false;
26992699
}
27002700

2701-
if expr.span.in_derive_expansion() {
2702-
// Ignore if span is from derive macro.
2703-
return false;
2704-
}
2705-
27062701
let Ok(src) = self.tcx.sess.source_map().span_to_snippet(expr.span) else {
27072702
return false;
27082703
};

0 commit comments

Comments
 (0)