3 #![warn(clippy::manual_map)]
4 #![allow(clippy::toplevel_ref_arg)]
7 // Lint. `y` is declared within the arm, so it isn't captured by the map closure
8 let _ = Some(0).map(|x| {
9 let y = (String::new(), String::new());
13 // Don't lint. `s` is borrowed until partway through the arm, but needs to be captured by the map
15 let s = Some(String::new());
17 Some(x) => Some((x.clone(), s)),
21 // Don't lint. `s` is borrowed until partway through the arm, but needs to be captured by the map
23 let s = Some(String::new());
26 let clone = x.clone();
33 // Don't lint. `s` is borrowed until partway through the arm, but needs to be captured as a mutable
34 // reference by the map closure
35 let mut s = Some(String::new());
38 let clone = x.clone();
45 // Lint. `s` is captured by reference, so no lifetime issues.
46 let s = Some(String::new());
47 let _ = s.as_ref().map(|x| {
48 if let Some(ref s) = s { (x.clone(), s) } else { panic!() }
52 unsafe fn f(x: u32) -> u32 {
56 let _ = Some(0).map(|x| f(x));
58 let _ = Some(0).map(|x| unsafe { f(x) });
59 let _ = Some(0).map(|x| unsafe { f(x) });