File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change @@ -519,10 +519,13 @@ impl Diagnostic {
519
519
520
520
/// Helper for pushing to `self.suggestions`, if available (not disable).
521
521
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 ( ) ) ) ;
522
+ let in_derive = suggestion. substitutions . iter ( ) . any ( |subst| {
523
+ subst. parts . iter ( ) . any ( |part| {
524
+ let span = part. span ;
525
+ let call_site = span. ctxt ( ) . outer_expn_data ( ) . call_site ;
526
+ span. in_derive_expansion ( ) && span. overlaps_or_adjacent ( call_site)
527
+ } )
528
+ } ) ;
526
529
if in_derive {
527
530
// Ignore if spans is from derive macro.
528
531
return ;
Original file line number Diff line number Diff line change @@ -627,6 +627,13 @@ impl Span {
627
627
span. lo < other. hi && other. lo < span. hi
628
628
}
629
629
630
+ /// Returns `true` if `self` touches or adjoins `other`.
631
+ pub fn overlaps_or_adjacent ( self , other : Span ) -> bool {
632
+ let span = self . data ( ) ;
633
+ let other = other. data ( ) ;
634
+ span. lo <= other. hi && other. lo <= span. hi
635
+ }
636
+
630
637
/// Returns `true` if the spans are equal with regards to the source text.
631
638
///
632
639
/// Use this instead of `==` when either span could be generated code,
You can’t perform that action at this time.
0 commit comments