File tree Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Expand file tree Collapse file tree 1 file changed +30
-3
lines changed Original file line number Diff line number Diff line change @@ -175,9 +175,21 @@ fn on_opening_bracket_typed(
175175 }
176176 }
177177
178- // If it's a statement in a block, we don't know how many statements should be included
179- if ast:: ExprStmt :: can_cast ( expr. syntax ( ) . parent ( ) ?. kind ( ) ) {
180- return None ;
178+ if let Some ( parent) = expr. syntax ( ) . parent ( ) . and_then ( ast:: Expr :: cast) {
179+ let mut node = expr. syntax ( ) . clone ( ) ;
180+ let all_prev_sib_attr = loop {
181+ match node. prev_sibling ( ) {
182+ Some ( sib) if sib. kind ( ) . is_trivia ( ) || sib. kind ( ) == SyntaxKind :: ATTR => {
183+ node = sib
184+ }
185+ Some ( _) => break false ,
186+ None => break true ,
187+ } ;
188+ } ;
189+
190+ if all_prev_sib_attr {
191+ expr = parent;
192+ }
181193 }
182194
183195 // Insert the closing bracket right after the expression.
@@ -824,6 +836,21 @@ fn f() {
824836 0 => {()},
825837 1 => (),
826838 }
839+ }
840+ "# ,
841+ ) ;
842+ type_char (
843+ '{' ,
844+ r#"
845+ fn main() {
846+ #[allow(unreachable_code)]
847+ $0g();
848+ }
849+ "# ,
850+ r#"
851+ fn main() {
852+ #[allow(unreachable_code)]
853+ {g()};
827854}
828855 "# ,
829856 ) ;
You can’t perform that action at this time.
0 commit comments