2019-04-19 05:08:00 -05:00
|
|
|
#![allow(unused)]
|
|
|
|
#![warn(clippy::match_as_ref)]
|
|
|
|
|
|
|
|
fn match_as_ref() {
|
|
|
|
let owned: Option<()> = None;
|
|
|
|
let borrowed: Option<&()> = match owned {
|
|
|
|
None => None,
|
|
|
|
Some(ref v) => Some(v),
|
|
|
|
};
|
|
|
|
|
|
|
|
let mut mut_owned: Option<()> = None;
|
|
|
|
let borrow_mut: Option<&mut ()> = match mut_owned {
|
|
|
|
None => None,
|
|
|
|
Some(ref mut v) => Some(v),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2019-08-25 00:10:45 -05:00
|
|
|
mod issue4437 {
|
2023-07-17 03:19:29 -05:00
|
|
|
use std::error::Error;
|
|
|
|
use std::fmt;
|
|
|
|
use std::num::ParseIntError;
|
2019-08-25 00:10:45 -05:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
struct E {
|
|
|
|
source: Option<ParseIntError>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Error for E {
|
|
|
|
fn source(&self) -> Option<&(dyn Error + 'static)> {
|
|
|
|
match self.source {
|
|
|
|
Some(ref s) => Some(s),
|
|
|
|
None => None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl fmt::Display for E {
|
|
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
|
|
unimplemented!()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-26 07:26:21 -06:00
|
|
|
fn main() {
|
|
|
|
// Don't lint
|
|
|
|
let _ = match Some(0) {
|
|
|
|
#[cfg(feature = "foo")]
|
|
|
|
Some(ref x) if *x > 50 => None,
|
|
|
|
Some(ref x) => Some(x),
|
|
|
|
None => None,
|
|
|
|
};
|
|
|
|
}
|