This repository was archived by the owner on May 28, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +35
-11
lines changed
src/tools/rust-analyzer/crates Expand file tree Collapse file tree 2 files changed +35
-11
lines changed Original file line number Diff line number Diff line change @@ -249,19 +249,23 @@ fn display_fields(
249249 }
250250 } else {
251251 f. write_char ( '{' ) ?;
252- f. write_char ( separator) ?;
253- for field in & fields[ ..count] {
254- f. write_str ( indent) ?;
255- field. hir_fmt ( f) ?;
256- f. write_char ( ',' ) ?;
257- f. write_char ( separator) ?;
258- }
259252
260- if fields. len ( ) > count {
261- f. write_str ( indent) ?;
262- f. write_str ( "/* … */" ) ?;
253+ if !fields. is_empty ( ) {
263254 f. write_char ( separator) ?;
255+ for field in & fields[ ..count] {
256+ f. write_str ( indent) ?;
257+ field. hir_fmt ( f) ?;
258+ f. write_char ( ',' ) ?;
259+ f. write_char ( separator) ?;
260+ }
261+
262+ if fields. len ( ) > count {
263+ f. write_str ( indent) ?;
264+ f. write_str ( "/* … */" ) ?;
265+ f. write_char ( separator) ?;
266+ }
264267 }
268+
265269 f. write_str ( "}" ) ?;
266270 }
267271
Original file line number Diff line number Diff line change @@ -1039,7 +1039,27 @@ fn hover_record_struct_limit() {
10391039 struct Foo { /* … */ }
10401040 ```
10411041 "# ] ] ,
1042- )
1042+ ) ;
1043+
1044+ // No extra spaces within `{}` when there are no fields
1045+ check_hover_fields_limit (
1046+ 5 ,
1047+ r#"
1048+ struct Foo$0 {}
1049+ "# ,
1050+ expect ! [ [ r#"
1051+ *Foo*
1052+
1053+ ```rust
1054+ test
1055+ ```
1056+
1057+ ```rust
1058+ // size = 0, align = 1
1059+ struct Foo {}
1060+ ```
1061+ "# ] ] ,
1062+ ) ;
10431063}
10441064
10451065#[ test]
You can’t perform that action at this time.
0 commit comments