Skip to content

Commit aae222c

Browse files
calebcartwrightytmimi
authored andcommitted
fix: correct span for structs with const generics
1 parent ee2bed9 commit aae222c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/items.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ fn format_unit_struct(
12451245
) -> Option<String> {
12461246
let header_str = format_header(context, p.prefix, p.ident, p.vis, offset);
12471247
let generics_str = if let Some(generics) = p.generics {
1248-
let hi = context.snippet_provider.span_before(p.span, ";");
1248+
let hi = context.snippet_provider.span_before_last(p.span, ";");
12491249
format_generics(
12501250
context,
12511251
generics,

tests/target/issue_5668.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
type Foo = impl Send;
2+
struct Struct<
3+
const C: usize = {
4+
let _: Foo = ();
5+
//~^ ERROR: mismatched types
6+
0
7+
},
8+
>;

0 commit comments

Comments
 (0)