File tree Expand file tree Collapse file tree 3 files changed +7
-11
lines changed Expand file tree Collapse file tree 3 files changed +7
-11
lines changed Original file line number Diff line number Diff line change @@ -494,11 +494,3 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
494494 ExpnKind :: Macro ( ..) => true , // definitely a plugin
495495 }
496496}
497-
498- /// Returns `true` if `span` originates in a derive-macro's expansion.
499- pub fn in_derive_expansion ( span : Span ) -> bool {
500- if let ExpnKind :: Macro ( MacroKind :: Derive , _) = span. ctxt ( ) . outer_expn_data ( ) . kind {
501- return true ;
502- }
503- false
504- }
Original file line number Diff line number Diff line change 33
44pub use self :: StabilityLevel :: * ;
55
6- use crate :: lint:: in_derive_expansion;
76use crate :: session:: { DiagnosticMessageId , Session } ;
87use crate :: ty:: { self , TyCtxt } ;
98use rustc_data_structures:: fx:: { FxHashMap , FxHashSet } ;
@@ -201,7 +200,7 @@ pub fn early_report_deprecation(
201200 lint : & ' static Lint ,
202201 span : Span ,
203202) {
204- if in_derive_expansion ( span ) {
203+ if span . in_derive_expansion ( ) {
205204 return ;
206205 }
207206
@@ -218,7 +217,7 @@ fn late_report_deprecation(
218217 def_id : DefId ,
219218 hir_id : HirId ,
220219) {
221- if in_derive_expansion ( span ) {
220+ if span . in_derive_expansion ( ) {
222221 return ;
223222 }
224223
Original file line number Diff line number Diff line change @@ -309,6 +309,11 @@ impl Span {
309309 self . ctxt ( ) != SyntaxContext :: root ( )
310310 }
311311
312+ /// Returns `true` if `span` originates in a derive-macro's expansion.
313+ pub fn in_derive_expansion ( self ) -> bool {
314+ matches ! ( self . ctxt( ) . outer_expn_data( ) . kind, ExpnKind :: Macro ( MacroKind :: Derive , _) )
315+ }
316+
312317 #[ inline]
313318 pub fn with_root_ctxt ( lo : BytePos , hi : BytePos ) -> Span {
314319 Span :: new ( lo, hi, SyntaxContext :: root ( ) )
You can’t perform that action at this time.
0 commit comments