@@ -8,8 +8,7 @@ use rustc_errors::{Applicability, Diag, SuggestionStyle};
8
8
use rustc_lexer:: TokenKind ;
9
9
use rustc_lint:: { EarlyContext , EarlyLintPass , LintContext } ;
10
10
use 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} ;
13
12
14
13
declare_clippy_lint ! {
15
14
/// ### What it does
@@ -375,21 +374,23 @@ impl EmptyLineAfter {
375
374
& mut self ,
376
375
cx : & EarlyContext < ' _ > ,
377
376
kind : & ItemKind ,
378
- ident : & Ident ,
377
+ ident : Option < Ident > ,
379
378
span : Span ,
380
379
attrs : & [ Attribute ] ,
381
380
id : NodeId ,
382
381
) {
383
382
self . items . push ( ItemInfo {
384
383
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 {
387
388
span. with_hi ( ident. span . hi ( ) )
388
389
} else {
389
390
span. with_hi ( span. lo ( ) )
390
391
} ,
391
392
mod_items : match kind {
392
- ItemKind :: Mod ( _, ModKind :: Loaded ( items, _, _, _) ) => items
393
+ ItemKind :: Mod ( _, _ , ModKind :: Loaded ( items, _, _, _) ) => items
393
394
. iter ( )
394
395
. filter ( |i| !matches ! ( i. span. ctxt( ) . outer_expn_data( ) . kind, ExpnKind :: AstPass ( _) ) )
395
396
. map ( |i| i. id )
@@ -471,7 +472,7 @@ impl EarlyLintPass for EmptyLineAfter {
471
472
self . check_item_kind (
472
473
cx,
473
474
& item. kind . clone ( ) . into ( ) ,
474
- & item. ident ,
475
+ item. kind . ident ( ) ,
475
476
item. span ,
476
477
& item. attrs ,
477
478
item. id ,
@@ -482,14 +483,14 @@ impl EarlyLintPass for EmptyLineAfter {
482
483
self . check_item_kind (
483
484
cx,
484
485
& item. kind . clone ( ) . into ( ) ,
485
- & item. ident ,
486
+ item. kind . ident ( ) ,
486
487
item. span ,
487
488
& item. attrs ,
488
489
item. id ,
489
490
) ;
490
491
}
491
492
492
493
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 ) ;
494
495
}
495
496
}
0 commit comments