introduce future-compatibility warning for forbidden lint groups
We used to ignore `forbid(group)` scenarios completely. This changed in #78864, but that led to a number of regressions (#80988, #81218). This PR introduces a future compatibility warning for the case where a group is forbidden but then an individual lint within that group is allowed. We now issue a FCW when we see the "allow", but permit it to take effect.
This commit is contained in:
parent
c0b64d97be
commit
b6b897b02c
|
@ -39,6 +39,7 @@ use rustc_session::SessionLintStore;
|
|||
use rustc_span::lev_distance::find_best_match_for_name;
|
||||
use rustc_span::{symbol::Symbol, MultiSpan, Span, DUMMY_SP};
|
||||
use rustc_target::abi::LayoutOf;
|
||||
use tracing::debug;
|
||||
|
||||
use std::cell::Cell;
|
||||
use std::slice;
|
||||
|
@ -336,6 +337,20 @@ impl LintStore {
|
|||
}
|
||||
}
|
||||
|
||||
/// True if this symbol represents a lint group name.
|
||||
pub fn is_lint_group(&self, lint_name: Symbol) -> bool {
|
||||
debug!(
|
||||
"is_lint_group(lint_name={:?}, lint_groups={:?})",
|
||||
lint_name,
|
||||
self.lint_groups.keys().collect::<Vec<_>>()
|
||||
);
|
||||
let lint_name_str = &*lint_name.as_str();
|
||||
self.lint_groups.contains_key(&lint_name_str) || {
|
||||
let warnings_name_str = crate::WARNINGS.name_lower();
|
||||
lint_name_str == &*warnings_name_str
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks the name of a lint for its existence, and whether it was
|
||||
/// renamed or removed. Generates a DiagnosticBuilder containing a
|
||||
/// warning for renamed and removed lints. This is over both lint
|
||||
|
|
|
@ -5,7 +5,7 @@ use rustc_ast::attr;
|
|||
use rustc_ast::unwrap_or;
|
||||
use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_errors::{struct_span_err, Applicability};
|
||||
use rustc_errors::{struct_span_err, Applicability, DiagnosticBuilder};
|
||||
use rustc_hir as hir;
|
||||
use rustc_hir::def_id::{CrateNum, LOCAL_CRATE};
|
||||
use rustc_hir::{intravisit, HirId};
|
||||
|
@ -17,11 +17,15 @@ use rustc_middle::lint::{
|
|||
};
|
||||
use rustc_middle::ty::query::Providers;
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::lint::{builtin, Level, Lint, LintId};
|
||||
use rustc_session::lint::{
|
||||
builtin::{self, FORBIDDEN_LINT_GROUPS},
|
||||
Level, Lint, LintId,
|
||||
};
|
||||
use rustc_session::parse::feature_err;
|
||||
use rustc_session::Session;
|
||||
use rustc_span::symbol::{sym, Symbol};
|
||||
use rustc_span::{source_map::MultiSpan, Span, DUMMY_SP};
|
||||
use tracing::debug;
|
||||
|
||||
use std::cmp;
|
||||
|
||||
|
@ -51,6 +55,7 @@ pub struct LintLevelsBuilder<'s> {
|
|||
id_to_set: FxHashMap<HirId, u32>,
|
||||
cur: u32,
|
||||
warn_about_weird_lints: bool,
|
||||
store: &'s LintStore,
|
||||
}
|
||||
|
||||
pub struct BuilderPush {
|
||||
|
@ -59,13 +64,14 @@ pub struct BuilderPush {
|
|||
}
|
||||
|
||||
impl<'s> LintLevelsBuilder<'s> {
|
||||
pub fn new(sess: &'s Session, warn_about_weird_lints: bool, store: &LintStore) -> Self {
|
||||
pub fn new(sess: &'s Session, warn_about_weird_lints: bool, store: &'s LintStore) -> Self {
|
||||
let mut builder = LintLevelsBuilder {
|
||||
sess,
|
||||
sets: LintLevelSets::new(),
|
||||
cur: 0,
|
||||
id_to_set: Default::default(),
|
||||
warn_about_weird_lints,
|
||||
store,
|
||||
};
|
||||
builder.process_command_line(sess, store);
|
||||
assert_eq!(builder.sets.list.len(), 1);
|
||||
|
@ -120,36 +126,75 @@ impl<'s> LintLevelsBuilder<'s> {
|
|||
if let (Level::Forbid, old_src) =
|
||||
self.sets.get_lint_level(id.lint, self.cur, Some(&specs), &self.sess)
|
||||
{
|
||||
let mut diag_builder = struct_span_err!(
|
||||
self.sess,
|
||||
src.span(),
|
||||
E0453,
|
||||
"{}({}) incompatible with previous forbid",
|
||||
level.as_str(),
|
||||
src.name(),
|
||||
// Backwards compatibility check:
|
||||
//
|
||||
// We used to not consider `forbid(lint_group)`
|
||||
// as preventing `allow(lint)` for some lint `lint` in
|
||||
// `lint_group`. For now, issue a future-compatibility
|
||||
// warning for this case.
|
||||
let id_name = id.lint.name_lower();
|
||||
let fcw_warning = match old_src {
|
||||
LintLevelSource::Default => false,
|
||||
LintLevelSource::Node(symbol, _, _) => self.store.is_lint_group(symbol),
|
||||
LintLevelSource::CommandLine(symbol, _) => self.store.is_lint_group(symbol),
|
||||
};
|
||||
debug!(
|
||||
"fcw_warning={:?}, specs.get(&id) = {:?}, old_src={:?}, id_name={:?}",
|
||||
fcw_warning, specs, old_src, id_name
|
||||
);
|
||||
diag_builder.span_label(src.span(), "overruled by previous forbid");
|
||||
match old_src {
|
||||
LintLevelSource::Default => {
|
||||
diag_builder.note(&format!(
|
||||
"`forbid` lint level is the default for {}",
|
||||
id.to_string()
|
||||
));
|
||||
}
|
||||
LintLevelSource::Node(_, forbid_source_span, reason) => {
|
||||
diag_builder.span_label(forbid_source_span, "`forbid` level set here");
|
||||
if let Some(rationale) = reason {
|
||||
diag_builder.note(&rationale.as_str());
|
||||
|
||||
let decorate_diag_builder = |mut diag_builder: DiagnosticBuilder<'_>| {
|
||||
diag_builder.span_label(src.span(), "overruled by previous forbid");
|
||||
match old_src {
|
||||
LintLevelSource::Default => {
|
||||
diag_builder.note(&format!(
|
||||
"`forbid` lint level is the default for {}",
|
||||
id.to_string()
|
||||
));
|
||||
}
|
||||
LintLevelSource::Node(_, forbid_source_span, reason) => {
|
||||
diag_builder.span_label(forbid_source_span, "`forbid` level set here");
|
||||
if let Some(rationale) = reason {
|
||||
diag_builder.note(&rationale.as_str());
|
||||
}
|
||||
}
|
||||
LintLevelSource::CommandLine(_, _) => {
|
||||
diag_builder.note("`forbid` lint level was set on command line");
|
||||
}
|
||||
}
|
||||
LintLevelSource::CommandLine(_, _) => {
|
||||
diag_builder.note("`forbid` lint level was set on command line");
|
||||
}
|
||||
diag_builder.emit();
|
||||
};
|
||||
if !fcw_warning {
|
||||
let diag_builder = struct_span_err!(
|
||||
self.sess,
|
||||
src.span(),
|
||||
E0453,
|
||||
"{}({}) incompatible with previous forbid",
|
||||
level.as_str(),
|
||||
src.name(),
|
||||
);
|
||||
decorate_diag_builder(diag_builder);
|
||||
} else {
|
||||
self.struct_lint(
|
||||
FORBIDDEN_LINT_GROUPS,
|
||||
Some(src.span().into()),
|
||||
|diag_builder| {
|
||||
let diag_builder = diag_builder.build(&format!(
|
||||
"{}({}) incompatible with previous forbid",
|
||||
level.as_str(),
|
||||
src.name(),
|
||||
));
|
||||
decorate_diag_builder(diag_builder);
|
||||
},
|
||||
);
|
||||
}
|
||||
diag_builder.emit();
|
||||
|
||||
// Retain the forbid lint level
|
||||
return;
|
||||
// Retain the forbid lint level, unless we are
|
||||
// issuing a FCW. In the FCW case, we want to
|
||||
// respect the new setting.
|
||||
if !fcw_warning {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
specs.insert(id, (level, src));
|
||||
|
|
|
@ -4,10 +4,48 @@
|
|||
//! compiler code, rather than using their own custom pass. Those
|
||||
//! lints are all available in `rustc_lint::builtin`.
|
||||
|
||||
// ignore-tidy-filelength
|
||||
|
||||
use crate::{declare_lint, declare_lint_pass};
|
||||
use rustc_span::edition::Edition;
|
||||
use rustc_span::symbol::sym;
|
||||
|
||||
declare_lint! {
|
||||
/// The `forbidden_lint_groups` lint detects violations of
|
||||
/// `forbid` applied to a lint group. Due to a bug in the compiler,
|
||||
/// these used to be overlooked entirely. They now generate a warning.
|
||||
///
|
||||
/// ### Example
|
||||
///
|
||||
/// ```rust
|
||||
/// #![forbid(warnings)]
|
||||
/// #![deny(bad_style)]
|
||||
///
|
||||
/// fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// {{produces}}
|
||||
///
|
||||
/// ### Recommended fix
|
||||
///
|
||||
/// If your crate is using `#![forbid(warnings)]`,
|
||||
/// we recommend that you change to `#![deny(warnings)]`.
|
||||
///
|
||||
/// ### Explanation
|
||||
///
|
||||
/// Due to a compiler bug, applying `forbid` to lint groups
|
||||
/// previously had no effect. The bug is now fixed but instead of
|
||||
/// enforcing `forbid` we issue this future-compatibility warning
|
||||
/// to avoid breaking existing crates.
|
||||
pub FORBIDDEN_LINT_GROUPS,
|
||||
Warn,
|
||||
"applying forbid to lint-groups",
|
||||
@future_incompatible = FutureIncompatibleInfo {
|
||||
reference: "issue #81670 <https://github.com/rust-lang/rust/issues/81670>",
|
||||
edition: None,
|
||||
};
|
||||
}
|
||||
|
||||
declare_lint! {
|
||||
/// The `ill_formed_attribute_input` lint detects ill-formed attribute
|
||||
/// inputs that were previously accepted and used in practice.
|
||||
|
@ -2837,6 +2875,7 @@ declare_lint_pass! {
|
|||
/// Does nothing as a lint pass, but registers some `Lint`s
|
||||
/// that are used by other parts of the compiler.
|
||||
HardwiredLints => [
|
||||
FORBIDDEN_LINT_GROUPS,
|
||||
ILLEGAL_FLOATING_POINT_LITERAL_PATTERN,
|
||||
ARITHMETIC_OVERFLOW,
|
||||
UNCONDITIONAL_PANIC,
|
||||
|
|
|
@ -5,7 +5,10 @@ use rustc_data_structures::fx::FxHashMap;
|
|||
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
||||
use rustc_errors::{DiagnosticBuilder, DiagnosticId};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_session::lint::{builtin, Level, Lint, LintId};
|
||||
use rustc_session::lint::{
|
||||
builtin::{self, FORBIDDEN_LINT_GROUPS},
|
||||
Level, Lint, LintId,
|
||||
};
|
||||
use rustc_session::{DiagnosticMessageId, Session};
|
||||
use rustc_span::hygiene::MacroKind;
|
||||
use rustc_span::source_map::{DesugaringKind, ExpnKind, MultiSpan};
|
||||
|
@ -89,7 +92,12 @@ impl LintLevelSets {
|
|||
// If we're about to issue a warning, check at the last minute for any
|
||||
// directives against the warnings "lint". If, for example, there's an
|
||||
// `allow(warnings)` in scope then we want to respect that instead.
|
||||
if level == Level::Warn {
|
||||
//
|
||||
// We exempt `FORBIDDEN_LINT_GROUPS` from this because it specifically
|
||||
// triggers in cases (like #80988) where you have `forbid(warnings)`,
|
||||
// and so if we turned that into an error, it'd defeat the purpose of the
|
||||
// future compatibility warning.
|
||||
if level == Level::Warn && LintId::of(lint) != LintId::of(FORBIDDEN_LINT_GROUPS) {
|
||||
let (warnings_level, warnings_src) =
|
||||
self.get_lint_id_level(LintId::of(builtin::WARNINGS), idx, aux);
|
||||
if let Some(configured_warning_level) = warnings_level {
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
// Check what happens when we forbid a smaller group but
|
||||
// then allow a superset of that group.
|
||||
|
||||
#![forbid(nonstandard_style)]
|
||||
|
||||
// FIXME: Arguably this should be an error, but the WARNINGS group is
|
||||
// treated in a very special (and rather ad-hoc) way and
|
||||
// it fails to trigger.
|
||||
#[allow(warnings)]
|
||||
fn main() {
|
||||
let A: ();
|
||||
//~^ ERROR should have a snake case name
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
error: variable `A` should have a snake case name
|
||||
--> $DIR/forbid-group-group-1.rs:11:9
|
||||
|
|
||||
LL | let A: ();
|
||||
| ^ help: convert the identifier to snake case: `a`
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/forbid-group-group-1.rs:4:11
|
||||
|
|
||||
LL | #![forbid(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
= note: `#[forbid(non_snake_case)]` implied by `#[forbid(nonstandard_style)]`
|
||||
|
||||
error: aborting due to previous error
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
// Check what happens when we forbid a bigger group but
|
||||
// then deny a subset of that group.
|
||||
|
||||
#![forbid(warnings)]
|
||||
#![deny(forbidden_lint_groups)]
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
//~^ ERROR incompatible with previous
|
||||
//~| WARNING previously accepted by the compiler
|
||||
//~| ERROR incompatible with previous
|
||||
//~| WARNING previously accepted by the compiler
|
||||
//~| ERROR incompatible with previous
|
||||
//~| WARNING previously accepted by the compiler
|
||||
//~| ERROR incompatible with previous
|
||||
//~| WARNING previously accepted by the compiler
|
||||
//~| ERROR incompatible with previous
|
||||
//~| WARNING previously accepted by the compiler
|
||||
//~| ERROR incompatible with previous
|
||||
//~| WARNING previously accepted by the compiler
|
||||
//~| ERROR incompatible with previous
|
||||
//~| WARNING previously accepted by the compiler
|
||||
//~| ERROR incompatible with previous
|
||||
//~| WARNING previously accepted by the compiler
|
||||
//~| ERROR incompatible with previous
|
||||
//~| WARNING previously accepted by the compiler
|
||||
fn main() {}
|
|
@ -0,0 +1,115 @@
|
|||
error: allow(nonstandard_style) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-group-2.rs:7:9
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
...
|
||||
LL | #[allow(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/forbid-group-group-2.rs:5:9
|
||||
|
|
||||
LL | #![deny(forbidden_lint_groups)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: allow(nonstandard_style) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-group-2.rs:7:9
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
...
|
||||
LL | #[allow(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: allow(nonstandard_style) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-group-2.rs:7:9
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
...
|
||||
LL | #[allow(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: allow(nonstandard_style) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-group-2.rs:7:9
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
...
|
||||
LL | #[allow(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: allow(nonstandard_style) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-group-2.rs:7:9
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
...
|
||||
LL | #[allow(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: allow(nonstandard_style) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-group-2.rs:7:9
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
...
|
||||
LL | #[allow(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: allow(nonstandard_style) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-group-2.rs:7:9
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
...
|
||||
LL | #[allow(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: allow(nonstandard_style) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-group-2.rs:7:9
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
...
|
||||
LL | #[allow(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: allow(nonstandard_style) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-group-2.rs:7:9
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
...
|
||||
LL | #[allow(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
// Check what happens when we forbid a group but
|
||||
// then allow a member of that group.
|
||||
//
|
||||
// check-pass
|
||||
|
||||
#![forbid(unused)]
|
||||
|
||||
#[allow(unused_variables)]
|
||||
//~^ WARNING incompatible with previous forbid
|
||||
//~| WARNING previously accepted
|
||||
//~| WARNING incompatible with previous forbid
|
||||
//~| WARNING previously accepted
|
||||
//~| WARNING incompatible with previous forbid
|
||||
//~| WARNING previously accepted
|
||||
//~| WARNING incompatible with previous forbid
|
||||
//~| WARNING previously accepted
|
||||
fn main() {
|
||||
let a: ();
|
||||
}
|
|
@ -0,0 +1,51 @@
|
|||
warning: allow(unused_variables) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-member.rs:8:9
|
||||
|
|
||||
LL | #![forbid(unused)]
|
||||
| ------ `forbid` level set here
|
||||
LL |
|
||||
LL | #[allow(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= note: `#[warn(forbidden_lint_groups)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
warning: allow(unused_variables) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-member.rs:8:9
|
||||
|
|
||||
LL | #![forbid(unused)]
|
||||
| ------ `forbid` level set here
|
||||
LL |
|
||||
LL | #[allow(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
warning: allow(unused_variables) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-member.rs:8:9
|
||||
|
|
||||
LL | #![forbid(unused)]
|
||||
| ------ `forbid` level set here
|
||||
LL |
|
||||
LL | #[allow(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
warning: allow(unused_variables) incompatible with previous forbid
|
||||
--> $DIR/forbid-group-member.rs:8:9
|
||||
|
|
||||
LL | #![forbid(unused)]
|
||||
| ------ `forbid` level set here
|
||||
LL |
|
||||
LL | #[allow(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
warning: 4 warnings emitted
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
// Check what happens when we forbid a member of
|
||||
// a group but then allow the group.
|
||||
|
||||
#![forbid(unused_variables)]
|
||||
|
||||
#[allow(unused)]
|
||||
//~^ ERROR incompatible with previous forbid
|
||||
//~| ERROR incompatible with previous forbid
|
||||
//~| ERROR incompatible with previous forbid
|
||||
fn main() {
|
||||
let a: ();
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
error[E0453]: allow(unused) incompatible with previous forbid
|
||||
--> $DIR/forbid-member-group.rs:6:9
|
||||
|
|
||||
LL | #![forbid(unused_variables)]
|
||||
| ---------------- `forbid` level set here
|
||||
LL |
|
||||
LL | #[allow(unused)]
|
||||
| ^^^^^^ overruled by previous forbid
|
||||
|
||||
error[E0453]: allow(unused) incompatible with previous forbid
|
||||
--> $DIR/forbid-member-group.rs:6:9
|
||||
|
|
||||
LL | #![forbid(unused_variables)]
|
||||
| ---------------- `forbid` level set here
|
||||
LL |
|
||||
LL | #[allow(unused)]
|
||||
| ^^^^^^ overruled by previous forbid
|
||||
|
||||
error[E0453]: allow(unused) incompatible with previous forbid
|
||||
--> $DIR/forbid-member-group.rs:6:9
|
||||
|
|
||||
LL | #![forbid(unused_variables)]
|
||||
| ---------------- `forbid` level set here
|
||||
LL |
|
||||
LL | #[allow(unused)]
|
||||
| ^^^^^^ overruled by previous forbid
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0453`.
|
|
@ -14,14 +14,17 @@
|
|||
|
||||
// compile-flags: -Z deduplicate-diagnostics=yes
|
||||
|
||||
#![forbid(forbidden_lint_groups)]
|
||||
|
||||
fn forbid_first(num: i32) -> i32 {
|
||||
#![forbid(unused)]
|
||||
#![deny(unused)]
|
||||
//~^ ERROR: deny(unused) incompatible with previous forbid
|
||||
//~| WARNING being phased out
|
||||
//~| ERROR: deny(unused) incompatible with previous forbid
|
||||
//~| WARNING being phased out
|
||||
#![warn(unused)]
|
||||
//~^ ERROR: warn(unused) incompatible with previous forbid
|
||||
#![allow(unused)]
|
||||
//~^ ERROR: allow(unused) incompatible with previous forbid
|
||||
|
||||
num * num
|
||||
}
|
||||
|
|
|
@ -1,29 +1,29 @@
|
|||
error[E0453]: deny(unused) incompatible with previous forbid
|
||||
--> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:19:13
|
||||
error: deny(unused) incompatible with previous forbid
|
||||
--> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:21:13
|
||||
|
|
||||
LL | #![forbid(unused)]
|
||||
| ------ `forbid` level set here
|
||||
LL | #![deny(unused)]
|
||||
| ^^^^^^ overruled by previous forbid
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:17:11
|
||||
|
|
||||
LL | #![forbid(forbidden_lint_groups)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error[E0453]: warn(unused) incompatible with previous forbid
|
||||
error: deny(unused) incompatible with previous forbid
|
||||
--> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:21:13
|
||||
|
|
||||
LL | #![forbid(unused)]
|
||||
| ------ `forbid` level set here
|
||||
...
|
||||
LL | #![warn(unused)]
|
||||
LL | #![deny(unused)]
|
||||
| ^^^^^^ overruled by previous forbid
|
||||
|
||||
error[E0453]: allow(unused) incompatible with previous forbid
|
||||
--> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:23:14
|
||||
|
|
||||
LL | #![forbid(unused)]
|
||||
| ------ `forbid` level set here
|
||||
...
|
||||
LL | #![allow(unused)]
|
||||
| ^^^^^^ overruled by previous forbid
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0453`.
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
// Regression test for #80988
|
||||
//
|
||||
// check-pass
|
||||
|
||||
#![forbid(warnings)]
|
||||
|
||||
#[deny(warnings)]
|
||||
//~^ WARNING incompatible with previous forbid
|
||||
//~| WARNING being phased out
|
||||
//~| WARNING incompatible with previous forbid
|
||||
//~| WARNING being phased out
|
||||
//~| WARNING incompatible with previous forbid
|
||||
//~| WARNING being phased out
|
||||
//~| WARNING incompatible with previous forbid
|
||||
//~| WARNING being phased out
|
||||
fn main() {}
|
|
@ -0,0 +1,51 @@
|
|||
warning: deny(warnings) incompatible with previous forbid
|
||||
--> $DIR/issue-80988.rs:7:8
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
LL |
|
||||
LL | #[deny(warnings)]
|
||||
| ^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= note: `#[warn(forbidden_lint_groups)]` on by default
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
warning: deny(warnings) incompatible with previous forbid
|
||||
--> $DIR/issue-80988.rs:7:8
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
LL |
|
||||
LL | #[deny(warnings)]
|
||||
| ^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
warning: deny(warnings) incompatible with previous forbid
|
||||
--> $DIR/issue-80988.rs:7:8
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
LL |
|
||||
LL | #[deny(warnings)]
|
||||
| ^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
warning: deny(warnings) incompatible with previous forbid
|
||||
--> $DIR/issue-80988.rs:7:8
|
||||
|
|
||||
LL | #![forbid(warnings)]
|
||||
| -------- `forbid` level set here
|
||||
LL |
|
||||
LL | #[deny(warnings)]
|
||||
| ^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
warning: 4 warnings emitted
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
// Regression test for #81218
|
||||
//
|
||||
// check-pass
|
||||
|
||||
#![forbid(warnings)]
|
||||
|
||||
#[allow(unused_variables)]
|
||||
fn main() {
|
||||
// We want to ensure that you don't get an error
|
||||
// here. The idea is that a derive might generate
|
||||
// code that would otherwise trigger the "unused variables"
|
||||
// lint, but it is meant to be suppressed.
|
||||
let x: ();
|
||||
}
|
|
@ -15,11 +15,16 @@
|
|||
// compile-flags: -Z deduplicate-diagnostics=yes
|
||||
|
||||
#![forbid(unused, non_snake_case)]
|
||||
#![forbid(forbidden_lint_groups)]
|
||||
|
||||
#[allow(unused_variables)] //~ ERROR incompatible with previous
|
||||
//~^ ERROR incompatible with previous
|
||||
//~| WARNING this was previously accepted by the compiler
|
||||
//~| WARNING this was previously accepted by the compiler
|
||||
fn foo() {}
|
||||
|
||||
#[allow(unused)] //~ ERROR incompatible with previous
|
||||
//~^ WARNING this was previously accepted by the compiler
|
||||
fn bar() {}
|
||||
|
||||
#[allow(nonstandard_style)] //~ ERROR incompatible with previous
|
||||
|
|
|
@ -1,23 +1,34 @@
|
|||
error[E0453]: allow(unused_variables) incompatible with previous forbid
|
||||
--> $DIR/outer-forbid.rs:19:9
|
||||
error: allow(unused_variables) incompatible with previous forbid
|
||||
--> $DIR/outer-forbid.rs:20:9
|
||||
|
|
||||
LL | #![forbid(unused, non_snake_case)]
|
||||
| ------ `forbid` level set here
|
||||
LL |
|
||||
...
|
||||
LL | #[allow(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
note: the lint level is defined here
|
||||
--> $DIR/outer-forbid.rs:18:11
|
||||
|
|
||||
LL | #![forbid(forbidden_lint_groups)]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error[E0453]: allow(unused) incompatible with previous forbid
|
||||
--> $DIR/outer-forbid.rs:22:9
|
||||
error: allow(unused) incompatible with previous forbid
|
||||
--> $DIR/outer-forbid.rs:26:9
|
||||
|
|
||||
LL | #![forbid(unused, non_snake_case)]
|
||||
| ------ `forbid` level set here
|
||||
...
|
||||
LL | #[allow(unused)]
|
||||
| ^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error[E0453]: allow(nonstandard_style) incompatible with previous forbid
|
||||
--> $DIR/outer-forbid.rs:25:9
|
||||
--> $DIR/outer-forbid.rs:30:9
|
||||
|
|
||||
LL | #![forbid(unused, non_snake_case)]
|
||||
| -------------- `forbid` level set here
|
||||
|
@ -25,6 +36,18 @@ LL | #![forbid(unused, non_snake_case)]
|
|||
LL | #[allow(nonstandard_style)]
|
||||
| ^^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
error: allow(unused_variables) incompatible with previous forbid
|
||||
--> $DIR/outer-forbid.rs:20:9
|
||||
|
|
||||
LL | #![forbid(unused, non_snake_case)]
|
||||
| ------ `forbid` level set here
|
||||
...
|
||||
LL | #[allow(unused_variables)]
|
||||
| ^^^^^^^^^^^^^^^^ overruled by previous forbid
|
||||
|
|
||||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
|
||||
= note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0453`.
|
||||
|
|
Loading…
Reference in New Issue