]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/usefulness/non-exhaustive-match-nested.rs
Auto merge of #63871 - BatmanAoD:FloatFnMustUse, r=withoutboats
[rust.git] / src / test / ui / pattern / usefulness / non-exhaustive-match-nested.rs
1 #![feature(slice_patterns)]
2
3 enum T { A(U), B }
4 enum U { C, D }
5
6 fn match_nested_vecs<'a, T>(l1: Option<&'a [T]>, l2: Result<&'a [T], ()>) -> &'static str {
7     match (l1, l2) { //~ ERROR non-exhaustive patterns: `(Some(&[]), Err(_))` not covered
8         (Some(&[]), Ok(&[])) => "Some(empty), Ok(empty)",
9         (Some(&[_, ..]), Ok(_)) | (Some(&[_, ..]), Err(())) => "Some(non-empty), any",
10         (None, Ok(&[])) | (None, Err(())) | (None, Ok(&[_])) => "None, Ok(less than one element)",
11         (None, Ok(&[_, _, ..])) => "None, Ok(at least two elements)"
12     }
13 }
14
15 fn main() {
16     let x = T::A(U::C);
17     match x { //~ ERROR non-exhaustive patterns: `A(C)` not covered
18         T::A(U::D) => { panic!("hello"); }
19         T::B => { panic!("goodbye"); }
20     }
21 }