mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 10:39:45 +00:00
Improve make::struct_ field_list whitespace
Example
---
**Before this PR**:
```rust
struct Variant{
field: u32
}
```
**After this PR**:
```rust
struct Variant {
field: u32
}
```
This commit is contained in:
parent
1f4e5e82ff
commit
7e2dc40642
3 changed files with 39 additions and 36 deletions
|
|
@ -1244,14 +1244,17 @@ pub fn struct_(
|
|||
generic_param_list: Option<ast::GenericParamList>,
|
||||
field_list: ast::FieldList,
|
||||
) -> ast::Struct {
|
||||
let semicolon = if matches!(field_list, ast::FieldList::TupleFieldList(_)) { ";" } else { "" };
|
||||
let (semicolon, ws) =
|
||||
if matches!(field_list, ast::FieldList::TupleFieldList(_)) { (";", "") } else { ("", " ") };
|
||||
let type_params = generic_param_list.map_or_else(String::new, |it| it.to_string());
|
||||
let visibility = match visibility {
|
||||
None => String::new(),
|
||||
Some(it) => format!("{it} "),
|
||||
};
|
||||
|
||||
ast_from_text(&format!("{visibility}struct {strukt_name}{type_params}{field_list}{semicolon}",))
|
||||
ast_from_text(&format!(
|
||||
"{visibility}struct {strukt_name}{type_params}{ws}{field_list}{semicolon}"
|
||||
))
|
||||
}
|
||||
|
||||
pub fn enum_(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue