Description
I was working on a rustc suggestion which turns tuple struct literal into a named struct literal. That is, it changes Struct(a)
into Struct { 0: a }
.
This change consists of two parts:
- Changing parens into braces (
()
->{}
) - Adding indices (
0:
)
The trivial way to do this is to replace the span of (
with {
and then add 0:
before a
. However, this causes rustfix to panic with "cannot replace slice of data that was already replaced", even though the spans aren't overlapping!
The two spans are "the span of (
(1 length)" and "the span between (
and a
(zero-length)". They are touching, but importantly not overlapping.
I made a workaround for this in rustc, but ideally rustfix would support this.
https://github.com/rust-lang/rust/blob/8f765fc7a15b6a2f1de93251b9f65c6156fbfe33/compiler/rustc_resolve/src/late/diagnostics.rs#L1979-L1987