X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=clippy_lints%2Fsrc%2Fattrs.rs;h=45250e1eca629cec41924c74935a9a97f471adf0;hb=6feed2713c7740eb5868eba43745bc508b8b77aa;hp=d56e1e88fcef32c2e8cb99224bc665814c06cf81;hpb=3e760cc93a4820c1f8fbb0d5e125567e065776d3;p=rust.git diff --git a/clippy_lints/src/attrs.rs b/clippy_lints/src/attrs.rs index d56e1e88fce..45250e1eca6 100644 --- a/clippy_lints/src/attrs.rs +++ b/clippy_lints/src/attrs.rs @@ -12,7 +12,7 @@ LintContext, LintPass, }; use rustc::ty; -use rustc::{declare_tool_lint, lint_array}; +use rustc::{declare_lint_pass, declare_tool_lint}; use rustc_errors::Applicability; use semver::Version; use syntax::ast::{AttrStyle, Attribute, Lit, LitKind, MetaItemKind, NestedMetaItem}; @@ -187,26 +187,15 @@ "usage of `cfg_attr(rustfmt)` instead of `tool_attributes`" } -#[derive(Copy, Clone)] -pub struct AttrPass; +declare_lint_pass!(Attributes => [ + INLINE_ALWAYS, + DEPRECATED_SEMVER, + USELESS_ATTRIBUTE, + EMPTY_LINE_AFTER_OUTER_ATTR, + UNKNOWN_CLIPPY_LINTS, +]); -impl LintPass for AttrPass { - fn get_lints(&self) -> LintArray { - lint_array!( - INLINE_ALWAYS, - DEPRECATED_SEMVER, - USELESS_ATTRIBUTE, - EMPTY_LINE_AFTER_OUTER_ATTR, - UNKNOWN_CLIPPY_LINTS, - ) - } - - fn name(&self) -> &'static str { - "Attributes" - } -} - -impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass { +impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Attributes { fn check_attribute(&mut self, cx: &LateContext<'a, 'tcx>, attr: &'tcx Attribute) { if let Some(items) = &attr.meta_item_list() { if let Some(ident) = attr.ident() { @@ -506,20 +495,9 @@ fn is_present_in_source(cx: &LateContext<'_, '_>, span: Span) -> bool { true } -#[derive(Copy, Clone)] -pub struct CfgAttrPass; - -impl LintPass for CfgAttrPass { - fn get_lints(&self) -> LintArray { - lint_array!(DEPRECATED_CFG_ATTR,) - } - - fn name(&self) -> &'static str { - "DeprecatedCfgAttribute" - } -} +declare_lint_pass!(DeprecatedCfgAttribute => [DEPRECATED_CFG_ATTR]); -impl EarlyLintPass for CfgAttrPass { +impl EarlyLintPass for DeprecatedCfgAttribute { fn check_attribute(&mut self, cx: &EarlyContext<'_>, attr: &Attribute) { if_chain! { // check cfg_attr