Skip to content

Commit 3973cdd

Browse files
committed
Use correct span for tuple struct's body
1 parent 84526ab commit 3973cdd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/items.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,12 +1189,13 @@ fn format_tuple_struct(
11891189
result.push_str(&header_str);
11901190

11911191
let body_lo = if fields.is_empty() {
1192-
context.codemap.span_after(span, "(")
1192+
let lo = get_bytepos_after_visibility(context, vis, span, ")");
1193+
context.codemap.span_after(mk_sp(lo, span.hi()), "(")
11931194
} else {
11941195
fields[0].span.lo()
11951196
};
11961197
let body_hi = if fields.is_empty() {
1197-
context.codemap.span_after(span, ")")
1198+
context.codemap.span_after(mk_sp(body_lo, span.hi()), ")")
11981199
} else {
11991200
// This is a dirty hack to work around a missing `)` from the span of the last field.
12001201
let last_arg_span = fields[fields.len() - 1].span;
@@ -1242,7 +1243,10 @@ fn format_tuple_struct(
12421243
.to_string(context.config))
12431244
}
12441245
result.push('(');
1245-
let snippet = context.snippet(mk_sp(body_lo, context.codemap.span_before(span, ")")));
1246+
let snippet = context.snippet(mk_sp(
1247+
body_lo,
1248+
context.codemap.span_before(mk_sp(body_lo, span.hi()), ")"),
1249+
));
12461250
if snippet.is_empty() {
12471251
// `struct S ()`
12481252
} else if snippet.trim_right_matches(&[' ', '\t'][..]).ends_with('\n') {

0 commit comments

Comments
 (0)