Skip to content

Commit

Permalink
Split up some single_match UI tests
Browse files Browse the repository at this point in the history
As part of rust-lang#2038
  • Loading branch information
phansch committed Apr 5, 2018
1 parent 62d595b commit b49027d
Show file tree
Hide file tree
Showing 4 changed files with 309 additions and 313 deletions.
66 changes: 0 additions & 66 deletions tests/ui/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@
#![allow(unused, if_let_redundant_pattern_matching)]
#![warn(single_match_else, match_same_arms)]

use std::borrow::Cow;

enum Foo { Bar, Baz(u8) }
use Foo::*;

enum ExprNode {
ExprAddrOf,
Butterflies,
Expand All @@ -29,67 +24,6 @@ fn unwrap_addr() -> Option<&'static ExprNode> {
}
}

fn single_match(){
let x = Some(1u8);

match x {
Some(y) => { println!("{:?}", y); }
_ => ()
};

let z = (1u8,1u8);
match z {
(2...3, 7...9) => dummy(),
_ => {}
};

// Not linted (pattern guards used)
match x {
Some(y) if y == 0 => println!("{:?}", y),
_ => ()
}

// Not linted (no block with statements in the single arm)
match z {
(2...3, 7...9) => println!("{:?}", z),
_ => println!("nope"),
}
}

fn single_match_know_enum() {
let x = Some(1u8);
let y : Result<_, i8> = Ok(1i8);

match x {
Some(y) => dummy(),
None => ()
};

match y {
Ok(y) => dummy(),
Err(..) => ()
};

let c = Cow::Borrowed("");

match c {
Cow::Borrowed(..) => dummy(),
Cow::Owned(..) => (),
};

let z = Foo::Bar;
// no warning
match z {
Bar => println!("42"),
Baz(_) => (),
}

match z {
Baz(_) => println!("42"),
Bar => (),
}
}

fn match_bool() {
let test: bool = true;

Expand Down
Loading

0 comments on commit b49027d

Please sign in to comment.