match single prefix slice

This commit is contained in:
Josh Mcguigan 2020-03-01 06:25:38 -08:00
parent 6db2da4993
commit f353625705
2 changed files with 48 additions and 1 deletions

View file

@ -136,6 +136,39 @@ fn test() {
);
}
#[test]
fn infer_pattern_match_slice() {
assert_snapshot!(
infer(r#"
fn test() {
let slice: &[f64] = &[0.0];
match slice {
&[a] => {
a;
}
_ => {}
}
}
"#),
@r###"
[11; 129) '{ ... } }': ()
[21; 26) 'slice': &[f64]
[37; 43) '&[0.0]': &[f64; _]
[38; 43) '[0.0]': [f64; _]
[39; 42) '0.0': f64
[49; 127) 'match ... }': ()
[55; 60) 'slice': &[f64]
[71; 75) '&[a]': &[f64]
[72; 75) '[a]': [f64]
[73; 74) 'a': f64
[79; 105) '{ ... }': ()
[93; 94) 'a': f64
[114; 115) '_': &[f64]
[119; 121) '{}': ()
"###
);
}
#[test]
fn infer_adt_pattern() {
assert_snapshot!(