Skip to content

Commit

Permalink
Rollup merge of rust-lang#58785 - euclio:tool-lint-attrs, r=estebank
Browse files Browse the repository at this point in the history
allow specifying attributes for tool lints

Needed for clippy to fix `unused_doc_comments` warnings that will be exposed by rust-lang#57882 (and thus unblock it).
  • Loading branch information
Centril committed Feb 28, 2019
2 parents 2c3926a + a998b1f commit e53a8bd
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 e53a8bd

Please sign in to comment.