Skip to content

Commit 3f752b4

Browse files
committed
Address review comments.
1 parent 5101c8e commit 3f752b4

File tree

2 files changed

+18
-11
lines changed

2 files changed

+18
-11
lines changed

clippy_lints/src/empty_line_after.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use rustc_errors::{Applicability, Diag, SuggestionStyle};
88
use rustc_lexer::TokenKind;
99
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
1010
use rustc_session::impl_lint_pass;
11-
use rustc_span::symbol::kw;
12-
use rustc_span::{BytePos, ExpnKind, Ident, InnerSpan, Span, SpanData, Symbol, sym};
11+
use rustc_span::{BytePos, ExpnKind, Ident, InnerSpan, Span, SpanData, Symbol, kw};
1312

1413
declare_clippy_lint! {
1514
/// ### What it does
@@ -375,14 +374,16 @@ impl EmptyLineAfter {
375374
&mut self,
376375
cx: &EarlyContext<'_>,
377376
kind: &ItemKind,
378-
ident: &Option<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: if let Some(ident) = ident { ident.name } else { sym::dummy },
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 },
386387
span: if let Some(ident) = ident {
387388
span.with_hi(ident.span.hi())
388389
} else {
@@ -471,7 +472,7 @@ impl EarlyLintPass for EmptyLineAfter {
471472
self.check_item_kind(
472473
cx,
473474
&item.kind.clone().into(),
474-
&item.kind.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.kind.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.kind.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
}

clippy_utils/src/ast_utils/mod.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -567,20 +567,23 @@ pub fn eq_foreign_item_kind(l: &ForeignItemKind, r: &ForeignItemKind) -> bool {
567567
(
568568
TyAlias(box ast::TyAlias {
569569
defaultness: ld,
570+
ident: li,
570571
generics: lg,
572+
where_clauses: _,
571573
bounds: lb,
572574
ty: lt,
573-
..
574575
}),
575576
TyAlias(box ast::TyAlias {
576577
defaultness: rd,
578+
ident: ri,
577579
generics: rg,
580+
where_clauses: _,
578581
bounds: rb,
579582
ty: rt,
580-
..
581583
}),
582584
) => {
583585
eq_defaultness(*ld, *rd)
586+
&& eq_id(*li, *ri)
584587
&& eq_generics(lg, rg)
585588
&& over(lb, rb, eq_generic_bound)
586589
&& both(lt.as_ref(), rt.as_ref(), |l, r| eq_ty(l, r))
@@ -647,20 +650,23 @@ pub fn eq_assoc_item_kind(l: &AssocItemKind, r: &AssocItemKind) -> bool {
647650
(
648651
Type(box TyAlias {
649652
defaultness: ld,
653+
ident: li,
650654
generics: lg,
655+
where_clauses: _,
651656
bounds: lb,
652657
ty: lt,
653-
..
654658
}),
655659
Type(box TyAlias {
656660
defaultness: rd,
661+
ident: ri,
657662
generics: rg,
663+
where_clauses: _,
658664
bounds: rb,
659665
ty: rt,
660-
..
661666
}),
662667
) => {
663668
eq_defaultness(*ld, *rd)
669+
&& eq_id(*li, *ri)
664670
&& eq_generics(lg, rg)
665671
&& over(lb, rb, eq_generic_bound)
666672
&& both(lt.as_ref(), rt.as_ref(), |l, r| eq_ty(l, r))

0 commit comments

Comments
 (0)