Skip to content

Commit

Permalink
allow specifying attributes for tool lints
Browse files Browse the repository at this point in the history
  • Loading branch information
euclio committed Feb 27, 2019
1 parent ea43c3c commit a998b1f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
20 changes: 14 additions & 6 deletions src/librustc/lint/mod.rs
Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion src/test/ui-fulldeps/auxiliary/lint_tool_test.rs
Expand Up @@ -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;

Expand Down

0 comments on commit a998b1f

Please sign in to comment.