From a998b1f425bc13d891ed5b28f1b708970f9db4b4 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Wed, 27 Feb 2019 10:56:58 -0500 Subject: [PATCH] allow specifying attributes for tool lints --- src/librustc/lint/mod.rs | 20 +++++++++++++------ .../ui-fulldeps/auxiliary/lint_tool_test.rs | 6 +++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index dd003e44bea09..496ff568b31b4 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -132,14 +132,22 @@ macro_rules! declare_lint { #[macro_export] macro_rules! declare_tool_lint { - ($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr) => ( - declare_tool_lint!{$vis $tool::$NAME, $Level, $desc, false} + ( + $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level: ident, $desc: expr + ) => ( + declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false} ); - ($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr, - report_in_external_macro: $rep: expr) => ( - declare_tool_lint!{$vis $tool::$NAME, $Level, $desc, $rep} + ( + $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr, + report_in_external_macro: $rep:expr + ) => ( + declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, $rep} ); - ($vis: vis $tool: ident ::$NAME: ident, $Level: ident, $desc: expr, $external: expr) => ( + ( + $(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr, + $external:expr + ) => ( + $(#[$attr])* $vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint { name: &concat!(stringify!($tool), "::", stringify!($NAME)), default_level: $crate::lint::$Level, diff --git a/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs b/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs index 1a9bd9e66dbac..d25a5ea374627 100644 --- a/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs +++ b/src/test/ui-fulldeps/auxiliary/lint_tool_test.rs @@ -13,7 +13,11 @@ use rustc::lint::{EarlyContext, LintContext, LintPass, EarlyLintPass, use rustc_plugin::Registry; use syntax::ast; declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff"); -declare_tool_lint!(pub clippy::TEST_GROUP, Warn, "Warn about other stuff"); +declare_tool_lint!( + /// Some docs + pub clippy::TEST_GROUP, + Warn, "Warn about other stuff" +); struct Pass;