@@ -9,7 +9,6 @@ use errors::Applicability;
99use rustc_data_structures:: fx:: FxHashMap ;
1010use syntax:: ast:: { Ident , Item , ItemKind } ;
1111use syntax:: symbol:: { sym, Symbol } ;
12- use syntax_pos:: ExpnInfo ;
1312
1413declare_tool_lint ! {
1514 pub rustc:: DEFAULT_HASH_TYPES ,
@@ -228,30 +227,20 @@ impl EarlyLintPass for LintPassImpl {
228227 if let ItemKind :: Impl ( _, _, _, _, Some ( lint_pass) , _, _) = & item. node {
229228 if let Some ( last) = lint_pass. path . segments . last ( ) {
230229 if last. ident . name == sym:: LintPass {
231- match & lint_pass. path . span . ctxt ( ) . outer_expn_info ( ) {
232- Some ( info ) if is_lint_pass_expansion ( info ) => { }
233- _ => {
234- cx . struct_span_lint (
235- LINT_PASS_IMPL_WITHOUT_MACRO ,
236- lint_pass . path . span ,
237- "implementing `LintPass` by hand" ,
238- )
239- . help ( "try using `declare_lint_pass!` or `impl_lint_pass!` instead" )
240- . emit ( ) ;
241- }
230+ let expn_info = lint_pass. path . span . ctxt ( ) . outer_expn_info ( ) ;
231+ let call_site = expn_info . call_site ;
232+ if expn_info . kind . descr ( ) != sym :: impl_lint_pass &&
233+ call_site . ctxt ( ) . outer_expn_info ( ) . kind . descr ( ) != sym :: declare_lint_pass {
234+ cx . struct_span_lint (
235+ LINT_PASS_IMPL_WITHOUT_MACRO ,
236+ lint_pass . path . span ,
237+ "implementing `LintPass` by hand" ,
238+ )
239+ . help ( "try using `declare_lint_pass!` or `impl_lint_pass!` instead" )
240+ . emit ( ) ;
242241 }
243242 }
244243 }
245244 }
246245 }
247246}
248-
249- fn is_lint_pass_expansion ( expn_info : & ExpnInfo ) -> bool {
250- if expn_info. kind . descr ( ) == sym:: impl_lint_pass {
251- true
252- } else if let Some ( info) = expn_info. call_site . ctxt ( ) . outer_expn_info ( ) {
253- info. kind . descr ( ) == sym:: declare_lint_pass
254- } else {
255- false
256- }
257- }
0 commit comments