fork/rust
git clone https://git.julia.blue/fork/rust
3bcad65fbf6
master
1#![warn(clippy::match_single_binding)] 2#![allow(unused_variables)] 3#![allow(clippy::uninlined_format_args)] 4 5fn main() { 6 // Lint (additional curly braces needed, see #6572) 7 struct AppendIter<I> 8 where 9 I: Iterator, 10 { 11 inner: Option<(I, <I as Iterator>::Item)>, 12 } 13 14 #[allow(dead_code)] 15 fn size_hint<I: Iterator>(iter: &AppendIter<I>) -> (usize, Option<usize>) { 16 match &iter.inner { 17 Some((iter, _item)) => { 18 let (min, max) = iter.size_hint(); 19 (min.saturating_add(1), max.and_then(|max| max.checked_add(1))) 20 }, 21 None => (0, Some(0)), 22 } 23 } 24 25 // Lint (no additional curly braces needed) 26 let opt = Some((5, 2)); 27 let get_tup = || -> (i32, i32) { (1, 2) }; 28 match opt { 29 #[rustfmt::skip] 30 Some((first, _second)) => { 31 let (a, b) = get_tup(); 32 println!("a {:?} and b {:?}", a, b) 33 }, 34 None => println!("nothing"), 35 } 36 37 fn side_effects() {} 38 39 // Lint (scrutinee has side effects) 40 // issue #7094 41 side_effects(); 42 println!("Side effects"); 43 44 // Lint (scrutinee has side effects) 45 // issue #7094 46 let x = 1; 47 match x { 48 0 => 1, 49 _ => 2, 50 }; 51 println!("Single branch") 52}