]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | #![allow(unused)] |
2 | #![warn(clippy::ref_option_ref)] | |
3 | ||
4 | // This lint is not tagged as run-rustfix because automatically | |
5 | // changing the type of a variable would also means changing | |
6 | // all usages of this variable to match and This is not handled | |
7 | // by this lint. | |
8 | ||
9 | static THRESHOLD: i32 = 10; | |
10 | static REF_THRESHOLD: &Option<&i32> = &Some(&THRESHOLD); | |
11 | const CONST_THRESHOLD: &i32 = &10; | |
cdc7bbd5 | 12 | const REF_CONST: &Option<&i32> = &Some(CONST_THRESHOLD); |
f20569fa XL |
13 | |
14 | type RefOptRefU32<'a> = &'a Option<&'a u32>; | |
15 | type RefOptRef<'a, T> = &'a Option<&'a T>; | |
16 | ||
17 | fn foo(data: &Option<&u32>) {} | |
18 | ||
19 | fn bar(data: &u32) -> &Option<&u32> { | |
20 | &None | |
21 | } | |
22 | ||
23 | struct StructRef<'a> { | |
24 | data: &'a Option<&'a u32>, | |
25 | } | |
26 | ||
27 | struct StructTupleRef<'a>(u32, &'a Option<&'a u32>); | |
28 | ||
29 | enum EnumRef<'a> { | |
30 | Variant1(u32), | |
31 | Variant2(&'a Option<&'a u32>), | |
32 | } | |
33 | ||
34 | trait RefOptTrait { | |
35 | type A; | |
36 | fn foo(&self, _: Self::A); | |
37 | } | |
38 | ||
39 | impl RefOptTrait for u32 { | |
40 | type A = &'static Option<&'static Self>; | |
41 | ||
42 | fn foo(&self, _: Self::A) {} | |
43 | } | |
44 | ||
45 | fn main() { | |
46 | let x: &Option<&u32> = &None; | |
47 | } |