File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
src/tools/rust-analyzer/crates/ide-completion/src Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -460,6 +460,8 @@ pub(crate) fn is_in_condition(it: &ast::Expr) -> bool {
460460 ast:: MatchGuard ( guard) => guard. condition( ) ? == * it,
461461 ast:: BinExpr ( bin_expr) => ( bin_expr. op_token( ) ?. kind( ) == T ![ &&] )
462462 . then( || is_in_condition( & bin_expr. into( ) ) ) ?,
463+ ast:: Expr ( expr) => ( expr. syntax( ) . text_range( ) . start( ) == it. syntax( ) . text_range( ) . start( ) )
464+ . then( || is_in_condition( & expr) ) ?,
463465 _ => return None ,
464466 } } )
465467 } )
Original file line number Diff line number Diff line change @@ -3268,6 +3268,12 @@ fn foo() -> (i32, i32) {
32683268#[ test]
32693269fn let_in_condition ( ) {
32703270 check_edit ( "let" , r#"fn f() { if $0 {} }"# , r#"fn f() { if let $1 = $0 {} }"# ) ;
3271+ check_edit ( "let" , r#"fn f() { if $0x {} }"# , r#"fn f() { if let $1 = $0x {} }"# ) ;
3272+ check_edit (
3273+ "let" ,
3274+ r#"fn f() { if $0foo.bar() {} }"# ,
3275+ r#"fn f() { if let $1 = $0foo.bar() {} }"# ,
3276+ ) ;
32713277}
32723278
32733279#[ test]
You can’t perform that action at this time.
0 commit comments