Skip to content

Commit 74dcc70

Browse files
Make duplicated_attributes a late lint
1 parent 7b0cf1a commit 74dcc70

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

clippy_lints/src/attrs/duplicated_attributes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ use super::DUPLICATED_ATTRIBUTES;
22
use clippy_utils::diagnostics::span_lint_and_then;
33
use rustc_ast::{Attribute, MetaItem};
44
use rustc_data_structures::fx::FxHashMap;
5-
use rustc_lint::EarlyContext;
5+
use rustc_lint::LateContext;
66
use rustc_span::{sym, Span};
77
use std::collections::hash_map::Entry;
88

99
fn emit_if_duplicated(
10-
cx: &EarlyContext<'_>,
10+
cx: &LateContext<'_>,
1111
attr: &MetaItem,
1212
attr_paths: &mut FxHashMap<String, Span>,
1313
complete_path: String,
@@ -26,7 +26,7 @@ fn emit_if_duplicated(
2626
}
2727

2828
fn check_duplicated_attr(
29-
cx: &EarlyContext<'_>,
29+
cx: &LateContext<'_>,
3030
attr: &MetaItem,
3131
attr_paths: &mut FxHashMap<String, Span>,
3232
parent: &mut Vec<String>,
@@ -64,7 +64,7 @@ fn check_duplicated_attr(
6464
}
6565
}
6666

67-
pub fn check(cx: &EarlyContext<'_>, attrs: &[Attribute]) {
67+
pub fn check(cx: &LateContext<'_>, attrs: &[Attribute]) {
6868
let mut attr_paths = FxHashMap::default();
6969

7070
for attr in attrs {

clippy_lints/src/attrs/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ mod useless_attribute;
1717
mod utils;
1818

1919
use clippy_config::msrvs::Msrv;
20-
use rustc_ast::{Attribute, Crate, MetaItemKind, NestedMetaItem};
20+
use rustc_ast::{Attribute, MetaItemKind, NestedMetaItem};
2121
use rustc_hir::{ImplItem, Item, ItemKind, TraitItem};
2222
use rustc_lint::{EarlyContext, EarlyLintPass, LateContext, LateLintPass};
2323
use rustc_session::{declare_lint_pass, impl_lint_pass};
@@ -534,11 +534,13 @@ declare_lint_pass!(Attributes => [
534534
BLANKET_CLIPPY_RESTRICTION_LINTS,
535535
SHOULD_PANIC_WITHOUT_EXPECT,
536536
MIXED_ATTRIBUTES_STYLE,
537+
DUPLICATED_ATTRIBUTES,
537538
]);
538539

539540
impl<'tcx> LateLintPass<'tcx> for Attributes {
540541
fn check_crate(&mut self, cx: &LateContext<'tcx>) {
541542
blanket_clippy_restriction_lints::check_command_line(cx);
543+
duplicated_attributes::check(cx, cx.tcx.hir().krate_attrs());
542544
}
543545

544546
fn check_attribute(&mut self, cx: &LateContext<'tcx>, attr: &'tcx Attribute) {
@@ -578,6 +580,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
578580
_ => {},
579581
}
580582
mixed_attributes_style::check(cx, item.span, attrs);
583+
duplicated_attributes::check(cx, attrs);
581584
}
582585

583586
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
@@ -606,17 +609,11 @@ impl_lint_pass!(EarlyAttributes => [
606609
MAYBE_MISUSED_CFG,
607610
DEPRECATED_CLIPPY_CFG_ATTR,
608611
UNNECESSARY_CLIPPY_CFG,
609-
DUPLICATED_ATTRIBUTES,
610612
]);
611613

612614
impl EarlyLintPass for EarlyAttributes {
613-
fn check_crate(&mut self, cx: &EarlyContext<'_>, krate: &Crate) {
614-
duplicated_attributes::check(cx, &krate.attrs);
615-
}
616-
617615
fn check_item(&mut self, cx: &EarlyContext<'_>, item: &rustc_ast::Item) {
618616
empty_line_after::check(cx, item);
619-
duplicated_attributes::check(cx, &item.attrs);
620617
}
621618

622619
fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) {

0 commit comments

Comments
 (0)