Added test

This commit is contained in:
Ole Strohm 2022-02-22 22:48:44 +00:00
parent 94a221ae8d
commit 5cdbfa5b70

View file

@ -79,10 +79,10 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext) ->
Peekable<Box<dyn Iterator<Item = (ast::Pat, bool)>>>,
bool,
) = if let Some(enum_def) = resolve_enum_def(&ctx.sema, &expr) {
let variants = enum_def.variants(ctx.db());
let is_non_exhaustive = enum_def.is_non_exhaustive(ctx.db());
let variants = enum_def.variants(ctx.db());
let missing_pats = variants
.into_iter()
.filter_map(|variant| {
@ -1598,7 +1598,7 @@ fn foo(t: E, b: bool) {
}
#[test]
fn does_notfill_wildcard_with_partial_wildcard_and_wildcard() {
fn does_not_fill_wildcard_with_partial_wildcard_and_wildcard() {
check_assist(
add_missing_match_arms,
r#"
@ -1618,6 +1618,30 @@ fn foo(t: E, b: bool) {
_ if b => todo!(),
_ => todo!(),
}
}"#,
);
}
#[test]
fn non_exhaustive_doc_hidden_tuple_fills_wildcard() {
check_assist(
add_missing_match_arms,
r#"
enum E { A, #[doc(hidden)] B, }
fn foo(t: E, b: bool) {
match $0(t, b) {
}
}"#,
r#"
enum E { A, #[doc(hidden)] B, }
fn foo(t: E, b: bool) {
match (t, b) {
$0(E::A, true) => todo!(),
(E::A, false) => todo!(),
_ => todo!(),
}
}"#,
);
}