1
Fork 0

Support lint expectations for --force-warn lints (RFC 2383)

This commit is contained in:
xFrednet 2022-06-05 12:33:45 +02:00
parent ec55c61305
commit 8527a3d369
No known key found for this signature in database
GPG key ID: F5C59D0E669E5302
19 changed files with 317 additions and 71 deletions

View file

@ -162,13 +162,19 @@ pub enum Level {
///
/// See RFC 2383.
///
/// The `LintExpectationId` is used to later link a lint emission to the actual
/// The [`LintExpectationId`] is used to later link a lint emission to the actual
/// expectation. It can be ignored in most cases.
Expect(LintExpectationId),
/// The `warn` level will produce a warning if the lint was violated, however the
/// compiler will continue with its execution.
Warn,
ForceWarn,
/// This lint level is a special case of [`Warn`], that can't be overridden. This is used
/// to ensure that a lint can't be suppressed. This lint level can currently only be set
/// via the console and is therefore session specific.
///
/// The [`LintExpectationId`] is intended to fulfill expectations marked via the
/// `#[expect]` attribute, that will still be suppressed due to the level.
ForceWarn(Option<LintExpectationId>),
/// The `deny` level will produce an error and stop further execution after the lint
/// pass is complete.
Deny,
@ -184,7 +190,7 @@ impl Level {
Level::Allow => "allow",
Level::Expect(_) => "expect",
Level::Warn => "warn",
Level::ForceWarn => "force-warn",
Level::ForceWarn(_) => "force-warn",
Level::Deny => "deny",
Level::Forbid => "forbid",
}
@ -219,7 +225,7 @@ impl Level {
pub fn is_error(self) -> bool {
match self {
Level::Allow | Level::Expect(_) | Level::Warn | Level::ForceWarn => false,
Level::Allow | Level::Expect(_) | Level::Warn | Level::ForceWarn(_) => false,
Level::Deny | Level::Forbid => true,
}
}