mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
match single prefix slice
This commit is contained in:
parent
6db2da4993
commit
f353625705
2 changed files with 48 additions and 1 deletions
|
@ -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!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue