diff options
Diffstat (limited to 'crates/ra_assists/src/handlers/early_return.rs')
-rw-r--r-- | crates/ra_assists/src/handlers/early_return.rs | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/crates/ra_assists/src/handlers/early_return.rs b/crates/ra_assists/src/handlers/early_return.rs index 22f88884f..f57ecd07a 100644 --- a/crates/ra_assists/src/handlers/early_return.rs +++ b/crates/ra_assists/src/handlers/early_return.rs | |||
@@ -112,16 +112,19 @@ pub(crate) fn convert_to_guarded_return(ctx: AssistCtx) -> Option<Assist> { | |||
112 | Some((path, bound_ident)) => { | 112 | Some((path, bound_ident)) => { |
113 | // If-let. | 113 | // If-let. |
114 | let match_expr = { | 114 | let match_expr = { |
115 | let happy_arm = make::match_arm( | 115 | let happy_arm = { |
116 | once( | 116 | let pat = make::tuple_struct_pat( |
117 | make::tuple_struct_pat( | 117 | path, |
118 | path, | 118 | once(make::bind_pat(make::name("it")).into()), |
119 | once(make::bind_pat(make::name("it")).into()), | 119 | ); |
120 | ) | 120 | let expr = { |
121 | .into(), | 121 | let name_ref = make::name_ref("it"); |
122 | ), | 122 | let segment = make::path_segment(name_ref); |
123 | make::expr_path(make::path_from_name_ref(make::name_ref("it"))), | 123 | let path = make::path_unqalified(segment); |
124 | ); | 124 | make::expr_path(path) |
125 | }; | ||
126 | make::match_arm(once(pat.into()), expr) | ||
127 | }; | ||
125 | 128 | ||
126 | let sad_arm = make::match_arm( | 129 | let sad_arm = make::match_arm( |
127 | // FIXME: would be cool to use `None` or `Err(_)` if appropriate | 130 | // FIXME: would be cool to use `None` or `Err(_)` if appropriate |