fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

master
921 B43 linesraw
1#![allow(unused)]
2#![warn(clippy::match_as_ref)]
3
4fn 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
12mod issue4437 {
13    use std::error::Error;
14    use std::fmt;
15    use std::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
35fn 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}