Skip to content

Commit fd1a399

Browse files
committed
Allow tool-lints to specify a feature-gate too
1 parent 7f115e3 commit fd1a399

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

compiler/rustc_lint/src/levels.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -440,8 +440,10 @@ impl<'s> LintLevelsBuilder<'s> {
440440
sp,
441441
reason,
442442
);
443-
for id in ids {
444-
self.insert_spec(*id, (level, src));
443+
for &id in ids {
444+
if self.check_gated_lint(id, attr.span) {
445+
self.insert_spec(id, (level, src));
446+
}
445447
}
446448
if let Level::Expect(expect_id) = level {
447449
self.lint_expectations.push((

compiler/rustc_lint_defs/src/lib.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -658,18 +658,21 @@ macro_rules! declare_lint {
658658
macro_rules! declare_tool_lint {
659659
(
660660
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level: ident, $desc: expr
661+
$(, @feature_gate = $gate:expr;)?
661662
) => (
662-
$crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false}
663+
$crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, false $(, @feature_gate = $gate;)?}
663664
);
664665
(
665666
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr,
666667
report_in_external_macro: $rep:expr
668+
$(, @feature_gate = $gate:expr;)?
667669
) => (
668-
$crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, $rep}
670+
$crate::declare_tool_lint!{$(#[$attr])* $vis $tool::$NAME, $Level, $desc, $rep $(, @feature_gate = $gate;)?}
669671
);
670672
(
671673
$(#[$attr:meta])* $vis:vis $tool:ident ::$NAME:ident, $Level:ident, $desc:expr,
672674
$external:expr
675+
$(, @feature_gate = $gate:expr;)?
673676
) => (
674677
$(#[$attr])*
675678
$vis static $NAME: &$crate::Lint = &$crate::Lint {
@@ -680,8 +683,9 @@ macro_rules! declare_tool_lint {
680683
report_in_external_macro: $external,
681684
future_incompatible: None,
682685
is_plugin: true,
683-
feature_gate: None,
686+
$(feature_gate: Some($gate),)?
684687
crate_level_only: false,
688+
..$crate::Lint::default_fields_for_macro()
685689
};
686690
);
687691
}

0 commit comments

Comments
 (0)