]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/tests/ui/map_err.rs
Rollup merge of #84221 - ABouttefeux:generic-arg-elision, r=estebank
[rust.git] / src / tools / clippy / tests / ui / map_err.rs
1 #![warn(clippy::map_err_ignore)]
2 #![allow(clippy::unnecessary_wraps)]
3 use std::convert::TryFrom;
4 use std::error::Error;
5 use std::fmt;
6
7 #[derive(Debug)]
8 enum Errors {
9     Ignored,
10 }
11
12 impl Error for Errors {}
13
14 impl fmt::Display for Errors {
15     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
16         write!(f, "Error")
17     }
18 }
19
20 fn main() -> Result<(), Errors> {
21     let x = u32::try_from(-123_i32);
22
23     println!("{:?}", x.map_err(|_| Errors::Ignored));
24
25     // Should not warn you because you explicitly ignore the parameter
26     // using a named wildcard value
27     println!("{:?}", x.map_err(|_foo| Errors::Ignored));
28
29     Ok(())
30 }