You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: clippy_lints/src/allow_attribute.rs
+35-49Lines changed: 35 additions & 49 deletions
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,27 @@
1
-
use ast::{AttrStyle,MetaItemKind};
2
-
use clippy_utils::{diagnostics::span_lint_and_sugg, source::snippet};
1
+
use ast::AttrStyle;
2
+
use clippy_utils::diagnostics::span_lint_and_sugg;
3
3
use rustc_ast as ast;
4
4
use rustc_errors::Applicability;
5
5
use rustc_lint::{LateContext,LateLintPass};
6
-
use rustc_session::{declare_tool_lint, impl_lint_pass};
7
-
use rustc_span::{symbol::Ident,BytePos};
6
+
use rustc_session::{declare_lint_pass, declare_tool_lint};
8
7
9
8
declare_clippy_lint!{
10
-
/// ### What it does
11
-
/// Detects uses of the `#[allow]` attribute and suggests to replace it with the new `#[expect]` attribute implemented by `#![feature(lint_reasons)]` ([RFC 2383](https://rust-lang.github.io/rfcs/2383-lint-reasons.html))
9
+
/// Detects uses of the `#[allow]` attribute and suggests replacing it with
10
+
/// the `#[expect]` (See [RFC 2383](https://rust-lang.github.io/rfcs/2383-lint-reasons.html))
11
+
///
12
+
/// The expect attribute is still unstable and requires the `lint_reasons`
13
+
/// on nightly. It can be enabled by adding `#![feature(lint_reasons)]` to
14
+
/// the crate root.
15
+
///
16
+
/// This lint only warns outer attributes (`#[allow]`), as inner attributes
17
+
/// (`#![allow]`) are usually used to enable or disable lints on a global scale.
18
+
///
12
19
/// ### Why is this bad?
13
-
/// Using `#[allow]` isn't bad, but `#[expect]` may be preferred as it lints if the code **doesn't** produce a warning.
20
+
///
21
+
/// `#[expect]` attributes suppress the lint emission, but emit a warning, if
22
+
/// the expectation is unfulfilled. This can be useful to be notified when the
23
+
/// lint is no longer triggered.
24
+
///
14
25
/// ### Example
15
26
/// ```rust,ignore
16
27
/// #[allow(unused_mut)]
@@ -34,59 +45,34 @@ declare_clippy_lint! {
34
45
"`#[allow]` will not trigger if a warning isn't found. `#[expect]` triggers if there are no warnings."
0 commit comments