Skip to content

refactor: canonicalize moved paths that refer to item left behind - #1928

Open
ahomescu wants to merge 1 commit into
ahomescu/fix_reorganize_definitions/glob_importsfrom
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
Open

refactor: canonicalize moved paths that refer to item left behind#1928
ahomescu wants to merge 1 commit into
ahomescu/fix_reorganize_definitions/glob_importsfrom
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths

Conversation

@ahomescu

Copy link
Copy Markdown
Contributor

Follow-up limitation found while writing the test — FIXED: items moved out
of a header could not rely on bindings that stay behind in the header (e.g.
the kept glob). A bare path like thing that resolved through the glob was
not canonicalized on the way out (is_relative_path treats only
self::/super:: as relative), so the moved item failed to compile with
E0412. move_items now runs canonicalize_moved_decl_paths over every
moved declaration (and its impl block): a single-segment path to a local,
non-moving item def is rewritten to its absolute path via def_qpath.
Paths are left alone when the destination module still binds the ident to
the same def — through a pre-existing import, an import moving along with
the declaration (moved use targets are now recorded in
ModuleInfo::import_targets, mirroring update_module_info_items), or
because the target is defined in the destination module itself — which
keeps the existing snapshots byte-identical. Paths to moved defs are still
rewritten later by update_paths via path_mapping. The
reorganize_glob_import test now uses the bare thing field type and
verifies it becomes crate::defs::thing.


Stack created with GitHub Stacks CLIGive Feedback 💬

@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 47f0497 to 2cf3f8e Compare July 25, 2026 01:40
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 2cf3f8e to daf6325 Compare July 25, 2026 01:57
@ahomescu
ahomescu changed the base branch from ahomescu/fix_reorganize_definitions/glob_imports to ahomescu/fix_reorganize_definitions/use_comments July 25, 2026 02:07
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from daf6325 to 81140ff Compare July 25, 2026 02:07
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 81140ff to 1d8d52c Compare July 25, 2026 02:11
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch 2 times, most recently from d45e97c to 87a82b0 Compare July 25, 2026 02:35
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 87a82b0 to ff8ac98 Compare July 25, 2026 03:17
@ahomescu
ahomescu changed the base branch from ahomescu/fix_reorganize_definitions/use_comments to ahomescu/fix_reorganize_definitions/glob_imports July 25, 2026 03:26
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from ff8ac98 to 6438594 Compare July 25, 2026 03:26
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 6438594 to 6012d94 Compare July 25, 2026 05:09
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 6012d94 to d20e8ed Compare July 25, 2026 05:33
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from d20e8ed to a4044e4 Compare July 25, 2026 05:41
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from a4044e4 to 252f1c9 Compare July 25, 2026 05:42
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 252f1c9 to 5750c0c Compare July 25, 2026 05:48
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 5750c0c to 4090222 Compare July 25, 2026 05:53
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 4090222 to 0a47a51 Compare July 25, 2026 06:00
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch 2 times, most recently from b5154fb to 2aaa81d Compare July 25, 2026 06:16
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 2aaa81d to fc29a79 Compare July 25, 2026 06:26
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from fc29a79 to 27b4464 Compare July 25, 2026 06:43
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 27b4464 to 01bfdb2 Compare July 25, 2026 06:51
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 01bfdb2 to dc274b3 Compare July 29, 2026 23:18
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch 2 times, most recently from 2d41b43 to 9885cdf Compare July 30, 2026 00:31
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 9885cdf to 314a319 Compare July 30, 2026 22:54
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch 2 times, most recently from 4055c03 to 9609486 Compare July 30, 2026 22:58
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch 2 times, most recently from cec27ff to b67a574 Compare August 5, 2026 00:10
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch 2 times, most recently from 9cbbba7 to 486931c Compare August 5, 2026 00:22
Follow-up limitation found while writing the test — FIXED: items moved out
of a header could not rely on bindings that stay behind in the header (e.g.
the kept glob). A bare path like `thing` that resolved through the glob was
not canonicalized on the way out (`is_relative_path` treats only
`self::`/`super::` as relative), so the moved item failed to compile with
E0412. `move_items` now runs `canonicalize_moved_decl_paths` over every
moved declaration (and its `impl` block): a single-segment path to a local,
non-moving item def is rewritten to its absolute path via `def_qpath`.
Paths are left alone when the destination module still binds the ident to
the same def — through a pre-existing import, an import moving along with
the declaration (moved `use` targets are now recorded in
`ModuleInfo::import_targets`, mirroring `update_module_info_items`), or
because the target is defined in the destination module itself — which
keeps the existing snapshots byte-identical. Paths to moved defs are still
rewritten later by `update_paths` via `path_mapping`. The
`reorganize_glob_import` test now uses the bare `thing` field type and
verifies it becomes `crate::defs::thing`.
@ahomescu
ahomescu force-pushed the ahomescu/fix_reorganize_definitions/canonicalize_moved_paths branch from 486931c to 4cddd79 Compare August 5, 2026 00:43
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