1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 #![warn(clippy::single_match)]
26 // Note the missing block braces.
27 // We suggest `if let Some(y) = x { .. }` because the macro
28 // is expanded before we can do anything.
29 Some(y) => println!("{:?}", y),
35 (2...3, 7...9) => dummy(),
39 // Not linted (pattern guards used)
41 Some(y) if y == 0 => println!("{:?}", y),
45 // Not linted (no block with statements in the single arm)
47 (2...3, 7...9) => println!("{:?}", z),
48 _ => println!("nope"),
59 fn single_match_know_enum() {
61 let y: Result<_, i8> = Ok(1i8);
73 let c = Cow::Borrowed("");
76 Cow::Borrowed(..) => dummy(),
83 Bar => println!("42"),
88 Baz(_) => println!("42"),