mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 22:54:58 +00:00
fix panic on ellipsis in pattern
This commit is contained in:
parent
8d296be109
commit
408f914bf4
2 changed files with 59 additions and 3 deletions
|
@ -484,3 +484,52 @@ fn main() {
|
|||
|
||||
assert_eq!("()", super::type_at_pos(&db, pos));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_3999_slice() {
|
||||
assert_snapshot!(
|
||||
infer(r#"
|
||||
fn foo(params: &[usize]) {
|
||||
match params {
|
||||
[ps @ .., _] => {}
|
||||
}
|
||||
}
|
||||
"#),
|
||||
@r###"
|
||||
[8; 14) 'params': &[usize]
|
||||
[26; 81) '{ ... } }': ()
|
||||
[32; 79) 'match ... }': ()
|
||||
[38; 44) 'params': &[usize]
|
||||
[55; 67) '[ps @ .., _]': [usize]
|
||||
[65; 66) '_': usize
|
||||
[71; 73) '{}': ()
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_3999_struct() {
|
||||
// rust-analyzer should not panic on seeing this malformed
|
||||
// record pattern.
|
||||
assert_snapshot!(
|
||||
infer(r#"
|
||||
struct Bar {
|
||||
a: bool,
|
||||
}
|
||||
fn foo(b: Bar) {
|
||||
match b {
|
||||
Bar { a: .. } => {},
|
||||
}
|
||||
}
|
||||
"#),
|
||||
@r###"
|
||||
[36; 37) 'b': Bar
|
||||
[44; 96) '{ ... } }': ()
|
||||
[50; 94) 'match ... }': ()
|
||||
[56; 57) 'b': Bar
|
||||
[68; 81) 'Bar { a: .. }': Bar
|
||||
[77; 79) '..': bool
|
||||
[85; 87) '{}': ()
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue