]>
Commit | Line | Data |
---|---|---|
f20569fa XL |
1 | // run-rustfix |
2 | ||
3 | #![allow(unused)] | |
4 | #![warn(clippy::match_as_ref)] | |
5 | ||
6 | fn match_as_ref() { | |
7 | let owned: Option<()> = None; | |
8 | let borrowed: Option<&()> = owned.as_ref(); | |
9 | ||
10 | let mut mut_owned: Option<()> = None; | |
11 | let borrow_mut: Option<&mut ()> = mut_owned.as_mut(); | |
12 | } | |
13 | ||
14 | mod issue4437 { | |
15 | use std::{error::Error, fmt, num::ParseIntError}; | |
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 | ||
35 | fn main() {} |