mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 11:20:54 +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
@ -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…
x
Reference in New Issue
Block a user