]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | #![allow(unused)] |
2 | #![warn(clippy::match_as_ref)] | |
3 | ||
4 | fn match_as_ref() { | |
5 | let owned: Option<()> = None; | |
6 | let borrowed: Option<&()> = owned.as_ref(); | |
7 | ||
8 | let mut mut_owned: Option<()> = None; | |
9 | let borrow_mut: Option<&mut ()> = mut_owned.as_mut(); | |
10 | } | |
11 | ||
12 | mod issue4437 { | |
add651ee FG |
13 | use std::error::Error; |
14 | use std::fmt; | |
15 | use std::num::ParseIntError; | |
f20569fa XL |
16 | |
17 | #[derive(Debug)] | |
18 | struct E { | |
19 | source: Option<ParseIntError>, | |
20 | } | |
21 | ||
22 | impl Error for E { | |
23 | fn source(&self) -> Option<&(dyn Error + 'static)> { | |
24 | self.source.as_ref().map(|x| x as _) | |
25 | } | |
26 | } | |
27 | ||
28 | impl fmt::Display for E { | |
29 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | |
30 | unimplemented!() | |
31 | } | |
32 | } | |
33 | } | |
34 | ||
5e7ed085 FG |
35 | fn main() { |
36 | // Don't lint | |
37 | let _ = match Some(0) { | |
38 | #[cfg(feature = "foo")] | |
39 | Some(ref x) if *x > 50 => None, | |
40 | Some(ref x) => Some(x), | |
41 | None => None, | |
42 | }; | |
43 | } |