Check with overlaps_or_adjacent
This commit is contained in:
parent
8cc5084950
commit
4e7941c2c5
2 changed files with 14 additions and 4 deletions
|
@ -519,10 +519,13 @@ impl Diagnostic {
|
||||||
|
|
||||||
/// Helper for pushing to `self.suggestions`, if available (not disable).
|
/// Helper for pushing to `self.suggestions`, if available (not disable).
|
||||||
fn push_suggestion(&mut self, suggestion: CodeSuggestion) {
|
fn push_suggestion(&mut self, suggestion: CodeSuggestion) {
|
||||||
let in_derive = suggestion
|
let in_derive = suggestion.substitutions.iter().any(|subst| {
|
||||||
.substitutions
|
subst.parts.iter().any(|part| {
|
||||||
.iter()
|
let span = part.span;
|
||||||
.any(|subst| subst.parts.iter().any(|part| part.span.in_derive_expansion()));
|
let call_site = span.ctxt().outer_expn_data().call_site;
|
||||||
|
span.in_derive_expansion() && span.overlaps_or_adjacent(call_site)
|
||||||
|
})
|
||||||
|
});
|
||||||
if in_derive {
|
if in_derive {
|
||||||
// Ignore if spans is from derive macro.
|
// Ignore if spans is from derive macro.
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -627,6 +627,13 @@ impl Span {
|
||||||
span.lo < other.hi && other.lo < span.hi
|
span.lo < other.hi && other.lo < span.hi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if `self` touches or adjoins `other`.
|
||||||
|
pub fn overlaps_or_adjacent(self, other: Span) -> bool {
|
||||||
|
let span = self.data();
|
||||||
|
let other = other.data();
|
||||||
|
span.lo <= other.hi && other.lo <= span.hi
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns `true` if the spans are equal with regards to the source text.
|
/// Returns `true` if the spans are equal with regards to the source text.
|
||||||
///
|
///
|
||||||
/// Use this instead of `==` when either span could be generated code,
|
/// Use this instead of `==` when either span could be generated code,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue