-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathallow_attributes_without_reason.rs
59 lines (52 loc) · 1.26 KB
/
allow_attributes_without_reason.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//@aux-build:proc_macros.rs
#![deny(clippy::allow_attributes_without_reason)]
#![allow(unfulfilled_lint_expectations, clippy::duplicated_attributes)]
//~^ allow_attributes_without_reason
extern crate proc_macros;
use proc_macros::{external, with_span};
// These should trigger the lint
#[allow(dead_code)]
//~^ allow_attributes_without_reason
#[allow(dead_code, deprecated)]
//~^ allow_attributes_without_reason
#[expect(dead_code)]
//~^ allow_attributes_without_reason
// These should be fine
#[allow(dead_code, reason = "This should be allowed")]
#[warn(dyn_drop, reason = "Warnings can also have reasons")]
#[warn(deref_nullptr)]
#[deny(deref_nullptr)]
#[forbid(deref_nullptr)]
fn main() {
external! {
#[allow(dead_code)]
fn a() {}
}
with_span! {
span
#[allow(dead_code)]
fn b() {}
}
}
// Make sure this is not triggered on `?` desugaring
pub fn trigger_fp_option() -> Option<()> {
Some(())?;
None?;
Some(())
}
pub fn trigger_fp_result() -> Result<(), &'static str> {
Ok(())?;
Err("asdf")?;
Ok(())
}
#[clippy::msrv = "1.81"]
fn msrv_1_81() {
#[allow(unused)]
//~^ allow_attributes_without_reason
let _ = 1;
}
#[clippy::msrv = "1.80"]
fn msrv_1_80() {
#[allow(unused)]
let _ = 1;
}