File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
src/tools/rust-analyzer/crates/ide-assists/src/handlers Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,9 @@ pub(crate) fn replace_is_method_with_if_let_method(
3131 ast:: Expr :: MethodCallExpr ( call) => call,
3232 _ => return None ,
3333 } ;
34+ if ctx. offset ( ) > if_expr. then_branch ( ) ?. stmt_list ( ) ?. l_curly_token ( ) ?. text_range ( ) . end ( ) {
35+ return None ;
36+ }
3437
3538 let name_ref = call_expr. name_ref ( ) ?;
3639 match name_ref. text ( ) . as_str ( ) {
@@ -188,6 +191,21 @@ fn main() {
188191 let x = Ok(1);
189192 if x.is_e$0rr() {}
190193}
194+ "# ,
195+ ) ;
196+ }
197+
198+ #[ test]
199+ fn replace_is_some_with_if_let_some_not_applicable_after_l_curly ( ) {
200+ check_assist_not_applicable (
201+ replace_is_method_with_if_let_method,
202+ r#"
203+ fn main() {
204+ let x = Some(1);
205+ if x.is_some() {
206+ ()$0
207+ }
208+ }
191209"# ,
192210 ) ;
193211 }
You can’t perform that action at this time.
0 commit comments