1 #![warn(clippy::match_same_arms)]
3 clippy::blacklisted_name,
4 clippy::collapsible_if,
5 clippy::cognitive_complexity,
7 clippy::needless_continue,
8 clippy::needless_return,
10 clippy::zero_divided_by_zero,
25 #[allow(clippy::unused_unit)]
26 fn match_same_arms() {
30 let mut a = 42 + [23].len() as i32;
38 //~ ERROR match arms have same body
40 let mut a = 42 + [23].len() as i32;
49 let _ = match Abc::A {
52 _ => 0, //~ ERROR match arms have same body
57 51 => foo(), //~ ERROR match arms have same body
61 let _ = match Some(42) {
63 None => 24, //~ ERROR match arms have same body
66 let _ = match Some(42) {
71 let _ = match Some(42) {
73 Some(a) => 24, // bindings are different
77 let _ = match Some(42) {
78 Some(a) if a > 0 => 24,
79 Some(a) => 24, // one arm has a guard
83 match (Some(42), Some(42)) {
84 (Some(a), None) => bar(a),
85 (None, Some(a)) => bar(a), //~ ERROR match arms have same body
89 match (Some(42), Some(42)) {
90 (Some(a), ..) => bar(a),
91 (.., Some(a)) => bar(a), //~ ERROR match arms have same body
97 (.., 3) => 42, //~ ERROR match arms have same body
101 let _ = match Some(()) {
106 match (Some(42), Some("")) {
107 (Some(a), None) => bar(a),
108 (None, Some(a)) => bar(a), // bindings have different types
114 51 => 1, //~ ERROR match arms have same body
116 52 => 2, //~ ERROR match arms have same body
122 2 => 2, //~ ERROR 2nd matched arms have same body
123 3 => 2, //~ ERROR 3rd matched arms have same body
130 #[derive(PartialEq, PartialOrd, Eq, Ord)]
131 pub enum CommandInfo {
132 BuiltIn { name: String, about: Option<String> },
133 External { name: String, path: std::path::PathBuf },
137 pub fn name(&self) -> String {
139 CommandInfo::BuiltIn { name, .. } => name.to_string(),
140 CommandInfo::External { name, .. } => name.to_string(),