Skip to content

Commit 957f9c9

Browse files
authored
Merge pull request #21111 from A4-Tacks/fill-guarded-match-arm
Fix not fill guarded match arm for add_missing_match_arms
2 parents be52a1e + 01d7b58 commit 957f9c9

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/tools/rust-analyzer/crates/ide-assists/src/handlers/add_missing_match_arms.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ pub(crate) fn add_missing_match_arms(acc: &mut Assists, ctx: &AssistContext<'_>)
6767
}
6868
.map(move |pat| (pat, has_guard))
6969
})
70-
.map(|(pat, has_guard)| {
70+
.filter_map(|(pat, has_guard)| {
7171
has_catch_all_arm |= !has_guard && matches!(pat, Pat::WildcardPat(_));
72-
pat
72+
(!has_guard).then_some(pat)
7373
})
7474
// Exclude top level wildcards so that they are expanded by this assist, retains status quo in #8129.
7575
.filter(|pat| !matches!(pat, Pat::WildcardPat(_)))
@@ -998,7 +998,8 @@ fn main() {
998998
A::Ds(_value) => { let x = 1; }
999999
A::Es(B::Xs) => (),
10001000
A::As => ${1:todo!()},
1001-
A::Cs => ${2:todo!()},$0
1001+
A::Bs => ${2:todo!()},
1002+
A::Cs => ${3:todo!()},$0
10021003
}
10031004
}
10041005
"#,

0 commit comments

Comments
 (0)