diff options
author | Dániel Buga <[email protected]> | 2021-01-22 22:29:51 +0000 |
---|---|---|
committer | Dániel Buga <[email protected]> | 2021-01-22 22:29:51 +0000 |
commit | 24f0cd8293c73b376a5e448dcbadcf189e8698aa (patch) | |
tree | b71a6ee26c86248d3e8ddb779b3194851f3c52d6 /crates/ide_db/src | |
parent | f301da3c3d1c73dd9d438cb0736e23430287dba7 (diff) |
replace_if_let_with_match: don't assume sad pattern
Diffstat (limited to 'crates/ide_db/src')
-rw-r--r-- | crates/ide_db/src/ty_filter.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/crates/ide_db/src/ty_filter.rs b/crates/ide_db/src/ty_filter.rs index 63a945282..f8406851b 100644 --- a/crates/ide_db/src/ty_filter.rs +++ b/crates/ide_db/src/ty_filter.rs | |||
@@ -49,6 +49,21 @@ impl TryEnum { | |||
49 | } | 49 | } |
50 | } | 50 | } |
51 | 51 | ||
52 | pub fn happy_pattern(self) -> ast::Pat { | ||
53 | match self { | ||
54 | TryEnum::Result => make::tuple_struct_pat( | ||
55 | make::path_unqualified(make::path_segment(make::name_ref("Ok"))), | ||
56 | iter::once(make::wildcard_pat().into()), | ||
57 | ) | ||
58 | .into(), | ||
59 | TryEnum::Option => make::tuple_struct_pat( | ||
60 | make::path_unqualified(make::path_segment(make::name_ref("Some"))), | ||
61 | iter::once(make::wildcard_pat().into()), | ||
62 | ) | ||
63 | .into(), | ||
64 | } | ||
65 | } | ||
66 | |||
52 | fn type_name(self) -> &'static str { | 67 | fn type_name(self) -> &'static str { |
53 | match self { | 68 | match self { |
54 | TryEnum::Result => "Result", | 69 | TryEnum::Result => "Result", |