@@ -8,8 +8,7 @@ use rustc_errors::{Applicability, Diag, SuggestionStyle};
88use rustc_lexer:: TokenKind ;
99use rustc_lint:: { EarlyContext , EarlyLintPass , LintContext } ;
1010use rustc_session:: impl_lint_pass;
11- use rustc_span:: symbol:: kw;
12- use rustc_span:: { BytePos , ExpnKind , Ident , InnerSpan , Span , SpanData , Symbol } ;
11+ use rustc_span:: { BytePos , ExpnKind , Ident , InnerSpan , Span , SpanData , Symbol , kw} ;
1312
1413declare_clippy_lint ! {
1514 /// ### What it does
@@ -375,21 +374,23 @@ impl EmptyLineAfter {
375374 & mut self ,
376375 cx : & EarlyContext < ' _ > ,
377376 kind : & ItemKind ,
378- ident : & Ident ,
377+ ident : Option < Ident > ,
379378 span : Span ,
380379 attrs : & [ Attribute ] ,
381380 id : NodeId ,
382381 ) {
383382 self . items . push ( ItemInfo {
384383 kind : kind. descr ( ) ,
385- name : ident. name ,
386- span : if span. contains ( ident. span ) {
384+ // FIXME: this `sym::empty` can be leaked, see
385+ // https://github.com/rust-lang/rust/pull/138740#discussion_r2021979899
386+ name : if let Some ( ident) = ident { ident. name } else { kw:: Empty } ,
387+ span : if let Some ( ident) = ident {
387388 span. with_hi ( ident. span . hi ( ) )
388389 } else {
389390 span. with_hi ( span. lo ( ) )
390391 } ,
391392 mod_items : match kind {
392- ItemKind :: Mod ( _, ModKind :: Loaded ( items, _, _, _) ) => items
393+ ItemKind :: Mod ( _, _ , ModKind :: Loaded ( items, _, _, _) ) => items
393394 . iter ( )
394395 . filter ( |i| !matches ! ( i. span. ctxt( ) . outer_expn_data( ) . kind, ExpnKind :: AstPass ( _) ) )
395396 . map ( |i| i. id )
@@ -471,7 +472,7 @@ impl EarlyLintPass for EmptyLineAfter {
471472 self . check_item_kind (
472473 cx,
473474 & item. kind . clone ( ) . into ( ) ,
474- & item. ident ,
475+ item. kind . ident ( ) ,
475476 item. span ,
476477 & item. attrs ,
477478 item. id ,
@@ -482,14 +483,14 @@ impl EarlyLintPass for EmptyLineAfter {
482483 self . check_item_kind (
483484 cx,
484485 & item. kind . clone ( ) . into ( ) ,
485- & item. ident ,
486+ item. kind . ident ( ) ,
486487 item. span ,
487488 & item. attrs ,
488489 item. id ,
489490 ) ;
490491 }
491492
492493 fn check_item ( & mut self , cx : & EarlyContext < ' _ > , item : & Item ) {
493- self . check_item_kind ( cx, & item. kind , & item. ident , item. span , & item. attrs , item. id ) ;
494+ self . check_item_kind ( cx, & item. kind , item. kind . ident ( ) , item. span , & item. attrs , item. id ) ;
494495 }
495496}
0 commit comments