Skip to content

Commit 622e1a8

Browse files
committed
Add a test case to add_missing_match_arms
Although it doesn't panic now, further changes to how we recover from incomplete syntax may cause this assist to panic. To mitigate this a test case has been added.
1 parent 145a101 commit 622e1a8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

crates/ide-assists/src/handlers/add_missing_match_arms.rs

+31
Original file line numberDiff line numberDiff line change
@@ -1944,4 +1944,35 @@ fn main() {
19441944
"#,
19451945
);
19461946
}
1947+
1948+
/// See [`discussion`](https://github.com/rust-lang/rust-analyzer/pull/15594#discussion_r1322960614)
1949+
#[test]
1950+
fn missing_field_name() {
1951+
check_assist(
1952+
add_missing_match_arms,
1953+
r#"
1954+
enum A {
1955+
A,
1956+
Missing { a: u32, : u32, c: u32 }
1957+
}
1958+
1959+
fn a() {
1960+
let b = A::A;
1961+
match b$0 {}
1962+
}"#,
1963+
r#"
1964+
enum A {
1965+
A,
1966+
Missing { a: u32, : u32, c: u32 }
1967+
}
1968+
1969+
fn a() {
1970+
let b = A::A;
1971+
match b {
1972+
$0A::A => todo!(),
1973+
A::Missing { a, u32, c } => todo!(),
1974+
}
1975+
}"#,
1976+
)
1977+
}
19471978
}

0 commit comments

Comments
 (0)