This repository was archived by the owner on May 28, 2025. It is now read-only.
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 {
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 ( ) ) ) ;
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+ } ) ;
526529 if in_derive {
527530 // Ignore if spans is from derive macro.
528531 return ;
Original file line number Diff line number Diff line change @@ -627,6 +627,13 @@ impl Span {
627627 span. lo < other. hi && other. lo < span. hi
628628 }
629629
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+
630637 /// Returns `true` if the spans are equal with regards to the source text.
631638 ///
632639 /// Use this instead of `==` when either span could be generated code,
You can’t perform that action at this time.
0 commit comments