diff --git a/src/items.rs b/src/items.rs index 755a41f6bf0..063a6428a08 100644 --- a/src/items.rs +++ b/src/items.rs @@ -1245,7 +1245,7 @@ fn format_unit_struct( ) -> Option { let header_str = format_header(context, p.prefix, p.ident, p.vis, offset); let generics_str = if let Some(generics) = p.generics { - let hi = context.snippet_provider.span_before(p.span, ";"); + let hi = context.snippet_provider.span_before_last(p.span, ";"); format_generics( context, generics, diff --git a/tests/target/issue_5668.rs b/tests/target/issue_5668.rs new file mode 100644 index 00000000000..bbd9a530b81 --- /dev/null +++ b/tests/target/issue_5668.rs @@ -0,0 +1,8 @@ +type Foo = impl Send; +struct Struct< + const C: usize = { + let _: Foo = (); + //~^ ERROR: mismatched types + 0 + }, +>;