@@ -19,7 +19,7 @@ use std::str::FromStr;
19
19
use std:: rc:: Rc ;
20
20
use syntax:: ast:: { self , LitKind } ;
21
21
use syntax:: attr;
22
- use syntax:: codemap:: { CompilerDesugaringKind , ExpnFormat , ExpnInfo , Span , DUMMY_SP } ;
22
+ use syntax:: codemap:: { CompilerDesugaringKind , ExpnFormat , Span , DUMMY_SP } ;
23
23
use syntax:: errors:: DiagnosticBuilder ;
24
24
use syntax:: ptr:: P ;
25
25
use syntax:: symbol:: keywords;
@@ -78,33 +78,9 @@ pub fn is_range_expression(span: Span) -> bool {
78
78
}
79
79
80
80
/// Returns true if the macro that expanded the crate was outside of the
81
- /// current crate or was a
82
- /// compiler plugin.
81
+ /// current crate or was a compiler plugin.
83
82
pub fn in_external_macro < ' a , T : LintContext < ' a > > ( cx : & T , span : Span ) -> bool {
84
- /// Invokes `in_macro` with the expansion info of the given span slightly
85
- /// heavy, try to use
86
- /// this after other checks have already happened.
87
- fn in_macro_ext < ' a , T : LintContext < ' a > > ( cx : & T , info : & ExpnInfo ) -> bool {
88
- // no ExpnInfo = no macro
89
- if let ExpnFormat :: MacroAttribute ( ..) = info. format {
90
- // these are all plugins
91
- return true ;
92
- }
93
- // no span for the callee = external macro
94
- info. def_site . map_or ( true , |span| {
95
- // no snippet = external macro or compiler-builtin expansion
96
- cx. sess ( )
97
- . codemap ( )
98
- . span_to_snippet ( span)
99
- . ok ( )
100
- . map_or ( true , |code| !code. starts_with ( "macro_rules" ) )
101
- } )
102
- }
103
-
104
- span. ctxt ( )
105
- . outer ( )
106
- . expn_info ( )
107
- . map_or ( false , |info| in_macro_ext ( cx, & info) )
83
+ :: rustc:: lint:: in_external_macro ( cx. sess ( ) , span)
108
84
}
109
85
110
86
/// Check if a `DefId`'s path matches the given absolute type path usage.
0 commit comments