File tree 1 file changed +30
-3
lines changed
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(
175
175
}
176
176
}
177
177
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
+ }
181
193
}
182
194
183
195
// Insert the closing bracket right after the expression.
@@ -824,6 +836,21 @@ fn f() {
824
836
0 => {()},
825
837
1 => (),
826
838
}
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()};
827
854
}
828
855
"# ,
829
856
) ;
You can’t perform that action at this time.
0 commit comments