Skip to content

refactor: fix bug in comments right before a Use - #1926

Open
ahomescu wants to merge 1 commit into
ahomescu/fix_reorganize_definitions/multi_namespace_import_splittingfrom
ahomescu/fix_reorganize_definitions/use_comments
Open

refactor: fix bug in comments right before a Use#1926
ahomescu wants to merge 1 commit into
ahomescu/fix_reorganize_definitions/multi_namespace_import_splittingfrom
ahomescu/fix_reorganize_definitions/use_comments

Conversation

@ahomescu

Copy link
Copy Markdown
Contributor

Root cause (in rewrite/base.rs, not the transform): the
Right/insert branches of rewrite_seq and rewrite_seq_comma_sep anchored
insertions at the neighbors' raw splice_span() boundaries, while the
neighbors' own rewrites and deletions claim their comment-extended spans
(extend_span_comments) — so an insertion anchored at the raw start of a
commented, rewritten item landed inside that item's claimed region and
cleanup_rewrites panicked. The insert branches now extend the neighbor
anchor spans over comments the same way the delete branch always did, and an
insertion at position 0 anchors before the first item's comment-extended span
(the sequence's outer span can start inside it). Inserting exactly at the
extended start of the next item is safe: cleanup_rewrites sorts the
insertion ahead of the following rewrite. The regression test keeps the
comment attached to the import and so covers this fix too.


Stack created with GitHub Stacks CLIGive Feedback 💬

@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from 74694e1 to c890caf Compare July 25, 2026 01:40
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from c890caf to a67f9d6 Compare July 25, 2026 01:57
@ahomescu
ahomescu changed the base branch from ahomescu/fix_reorganize_definitions/multi_namespace_import_splitting to ahomescu/fix_reorganize_definitions/deterministic_externs July 25, 2026 02:11
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from a67f9d6 to 8c413df Compare July 25, 2026 02:11
@ahomescu
ahomescu changed the base branch from ahomescu/fix_reorganize_definitions/deterministic_externs to ahomescu/fix_reorganize_definitions/compare_extern_fn_sigs July 25, 2026 02:16
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch 2 times, most recently from 5363886 to 5f41b0c Compare July 25, 2026 02:35
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from 5f41b0c to ecd1cf4 Compare July 25, 2026 03:17
@ahomescu
ahomescu changed the base branch from ahomescu/fix_reorganize_definitions/compare_extern_fn_sigs to ahomescu/fix_reorganize_definitions/widen_matched_defs July 25, 2026 03:17
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from ecd1cf4 to a6456cc Compare July 25, 2026 05:09
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from a6456cc to 4d62f14 Compare July 25, 2026 05:33
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from 4d62f14 to c85f8dc Compare July 25, 2026 05:41
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from c85f8dc to bdeeb18 Compare July 25, 2026 05:42
@ahomescu
ahomescu changed the base branch from ahomescu/fix_reorganize_definitions/widen_matched_defs to ahomescu/fix_reorganize_definitions/multi_namespace_import_splitting July 25, 2026 05:47
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from bdeeb18 to 96a61f2 Compare July 25, 2026 05:47
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from 96a61f2 to c0c2151 Compare July 25, 2026 05:59
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch 3 times, most recently from eb58868 to cc04f4f Compare July 25, 2026 06:26
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch 2 times, most recently from e3dc557 to c51dcef Compare July 25, 2026 06:51
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from c51dcef to 0b5b380 Compare July 29, 2026 23:18
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch 2 times, most recently from 218e270 to 2835adb Compare July 30, 2026 00:31
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch 2 times, most recently from cb45e42 to f1a4052 Compare July 30, 2026 22:56
Root cause (in `rewrite/base.rs`, not the transform): the
`Right`/insert branches of `rewrite_seq` and `rewrite_seq_comma_sep` anchored
insertions at the neighbors' raw `splice_span()` boundaries, while the
neighbors' own rewrites and deletions claim their *comment-extended* spans
(`extend_span_comments`) — so an insertion anchored at the raw start of a
commented, rewritten item landed inside that item's claimed region and
`cleanup_rewrites` panicked. The insert branches now extend the neighbor
anchor spans over comments the same way the delete branch always did, and an
insertion at position 0 anchors before the first item's comment-extended span
(the sequence's outer span can start inside it). Inserting exactly at the
extended start of the next item is safe: `cleanup_rewrites` sorts the
insertion ahead of the following rewrite. The regression test keeps the
comment attached to the import and so covers this fix too.
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/use_comments branch from f1a4052 to c0cd6fb Compare July 30, 2026 22:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant