@@ -86,26 +86,13 @@ fn on_opening_brace_typed(file: &SourceFile, offset: TextSize) -> Option<TextEdi
86
86
// We expect a block expression enclosing exactly 1 preexisting expression. It can be parsed as
87
87
// either the trailing expr or an ExprStmt.
88
88
let offset = {
89
- match block. tail_expr ( ) {
90
- Some ( expr) => {
91
- if block. statements ( ) . next ( ) . is_some ( ) {
92
- return None ;
93
- }
94
- expr. syntax ( ) . text_range ( ) . end ( )
95
- }
96
- None => {
97
- if block. statements ( ) . count ( ) != 1 {
98
- return None ;
99
- }
100
-
101
- match block. statements ( ) . next ( ) ? {
102
- ast:: Stmt :: ExprStmt ( it) => {
103
- // Use the expression span to place `}` before the `;`
104
- it. expr ( ) ?. syntax ( ) . text_range ( ) . end ( )
105
- }
106
- _ => return None ,
107
- }
108
- }
89
+ match block. statements ( ) . next ( ) {
90
+ Some ( ast:: Stmt :: ExprStmt ( it) ) => {
91
+ // Use the expression span to place `}` before the `;`
92
+ it. expr ( ) ?. syntax ( ) . text_range ( ) . end ( )
93
+ } ,
94
+ None => block. tail_expr ( ) ?. syntax ( ) . text_range ( ) . end ( ) ,
95
+ _ => return None ,
109
96
}
110
97
} ;
111
98
@@ -417,5 +404,33 @@ fn main() {
417
404
type_char ( '{' , r"fn f() { match () { _ => $0() } }" , r"fn f() { match () { _ => {()} } }" ) ;
418
405
type_char ( '{' , r"fn f() { $0(); }" , r"fn f() { {()}; }" ) ;
419
406
type_char ( '{' , r"fn f() { let x = $0(); }" , r"fn f() { let x = {()}; }" ) ;
407
+ type_char (
408
+ '{' ,
409
+ r"
410
+ const S: () = $0();
411
+ fn f() {}
412
+ " ,
413
+ r"
414
+ const S: () = {()};
415
+ fn f() {}
416
+ " ,
417
+ ) ;
418
+ type_char (
419
+ '{' ,
420
+ r"
421
+ fn f() {
422
+ match x {
423
+ 0 => $0(),
424
+ 1 => (),
425
+ }
426
+ }" ,
427
+ r"
428
+ fn f() {
429
+ match x {
430
+ 0 => {()},
431
+ 1 => (),
432
+ }
433
+ }" ,
434
+ ) ;
420
435
}
421
436
}
0 commit comments