PrimeIntellect/SWE-rebench-V2-Filtered-Easy-Verified huggingface dataset:
Repository: rust-lang/rustfmt (rust)
Issue: rustfmt generates invalid code with for const int generic with default argument
This struct

```
struct Regs<
    const BEGIN: u64,
    const END: u64,
    const DIM: usize,
    const N: usize = { (END - BEGIN) as usize / (8 * DIM) + 1 },
>
{
    _foo: u64,
}
```

gets reformatted to

```
struct Regs<
    const BEGIN: u64,
    const END: u64,
    const DIM: usize,
    const N: usize = { (END - BEGIN) as usize / (8 * DIM) + 1 },
>
{ (END - BEGIN) as usize / (8 * DIM) + 1 },
>
{
    _foo: u64,
}
```

Pull request description: adjust span derivation for const generics
Fixes #5935

r? @ytmimi if you have time, otherwise I may just pull this in for the release later given the trivial nature of the change

Patch:
diff --git a/src/items.rs b/src/items.rs
index 48c37df8..c31d425a 100644
--- a/src/items.rs
+++ b/src/items.rs
@@ -3244,7 +3244,7 @@ fn format_generics(
                     if brace_pos == BracePos::None {
                         span.hi()
                     } else {
-                        context.snippet_provider.span_before(span, "{")
+                        context.snippet_provider.span_before_last(span, "{")
                     },
                 ),
                 shape,


Test patch:
diff --git a/tests/source/issue-5935.rs b/tests/source/issue-5935.rs
new file mode 100644
index 00000000..a1aac056
--- /dev/null
+++ b/tests/source/issue-5935.rs
@@ -0,0 +1,9 @@
+struct Regs<
+    const BEGIN: u64,
+    const END: u64,
+    const DIM: usize,
+    const N: usize = { (END - BEGIN) as usize / (8 * DIM) + 1 },
+>
+{
+    _foo: u64,
+}
\ No newline at end of file
diff --git a/tests/target/issue-5935.rs b/tests/target/issue-5935.rs
new file mode 100644
index 00000000..ebc62c46
--- /dev/null
+++ b/tests/target/issue-5935.rs
@@ -0,0 +1,8 @@
+struct Regs<
+    const BEGIN: u64,
+    const END: u64,
+    const DIM: usize,
+    const N: usize = { (END - BEGIN) as usize / (8 * DIM) + 1 },
+> {
+    _foo: u64,
+}