parent
ad46f9af95
commit
7e2fcc27e1
13
src/items.rs
13
src/items.rs
@ -839,7 +839,18 @@ fn format_struct_struct(context: &RewriteContext,
|
||||
|
||||
// FIXME(#919): properly format empty structs and their comments.
|
||||
if fields.is_empty() {
|
||||
result.push_str(&context.snippet(mk_sp(body_lo, span.hi)));
|
||||
let snippet = context.snippet(mk_sp(body_lo, span.hi - BytePos(1)));
|
||||
if snippet.trim().is_empty() {
|
||||
// `struct S {}`
|
||||
} else if snippet.trim_right_matches(&[' ', '\t'][..]).ends_with('\n') {
|
||||
// fix indent
|
||||
result.push_str(&snippet.trim_right());
|
||||
result.push('\n');
|
||||
result.push_str(&offset.to_string(context.config));
|
||||
} else {
|
||||
result.push_str(&snippet);
|
||||
}
|
||||
result.push('}');
|
||||
return Some(result);
|
||||
}
|
||||
|
||||
|
@ -153,4 +153,15 @@ struct Issue677 {
|
||||
}
|
||||
|
||||
struct Foo {}
|
||||
struct Foo {
|
||||
}
|
||||
struct Foo {
|
||||
// comment
|
||||
}
|
||||
struct Foo {
|
||||
// trailing space ->
|
||||
|
||||
|
||||
}
|
||||
struct Foo { /* comment */ }
|
||||
struct Foo();
|
||||
|
@ -161,4 +161,12 @@ struct Issue677 {
|
||||
}
|
||||
|
||||
struct Foo {}
|
||||
struct Foo {}
|
||||
struct Foo {
|
||||
// comment
|
||||
}
|
||||
struct Foo {
|
||||
// trailing space ->
|
||||
}
|
||||
struct Foo { /* comment */ }
|
||||
struct Foo();
|
||||
|
Loading…
x
Reference in New Issue
Block a user