1
Fork 0

Check with overlaps_or_adjacent

This commit is contained in:
long-long-float 2024-02-09 01:03:38 +09:00
parent 8cc5084950
commit 4e7941c2c5
2 changed files with 14 additions and 4 deletions

View file

@ -519,10 +519,13 @@ 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()));
let in_derive = suggestion.substitutions.iter().any(|subst| {
subst.parts.iter().any(|part| {
let span = part.span;
let call_site = span.ctxt().outer_expn_data().call_site;
span.in_derive_expansion() && span.overlaps_or_adjacent(call_site)
})
});
if in_derive {
// Ignore if spans is from derive macro.
return;