Skip to content

Commit

Permalink
Check in push_suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
long-long-float committed Feb 5, 2024
1 parent 87ea0d7 commit 4909258
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
9 changes: 9 additions & 0 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,15 @@ impl Diagnostic {

/// Helper for pushing to `self.suggestions`, if available (not disable).
fn push_suggestion(&mut self, suggestion: CodeSuggestion) {
let in_derive = suggestion
.substitutions
.iter()
.any(|subst| subst.parts.iter().any(|part| part.span.in_derive_expansion()));
if in_derive {
// Ignore if spans is from derive macro.
return;
}

if let Ok(suggestions) = &mut self.suggestions {
suggestions.push(suggestion);
}
Expand Down
5 changes: 0 additions & 5 deletions compiler/rustc_hir_typeck/src/fn_ctxt/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2698,11 +2698,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
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;
};
Expand Down

0 comments on commit 4909258

Please sign in to comment.