refactor: canonicalize moved paths that refer to item left behind - #1928
Open
ahomescu wants to merge 1 commit into
Conversation
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 01:40
47f0497 to
2cf3f8e
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 01:57
2cf3f8e to
daf6325
Compare
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
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 02:07
daf6325 to
81140ff
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 02:11
81140ff to
1d8d52c
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
2 times, most recently
from
July 25, 2026 02:35
d45e97c to
87a82b0
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 03:17
87a82b0 to
ff8ac98
Compare
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
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 03:26
ff8ac98 to
6438594
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 05:09
6438594 to
6012d94
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 05:33
6012d94 to
d20e8ed
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 05:41
d20e8ed to
a4044e4
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 05:42
a4044e4 to
252f1c9
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 05:48
252f1c9 to
5750c0c
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 05:53
5750c0c to
4090222
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 06:00
4090222 to
0a47a51
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
2 times, most recently
from
July 25, 2026 06:16
b5154fb to
2aaa81d
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 06:26
2aaa81d to
fc29a79
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 06:43
fc29a79 to
27b4464
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 25, 2026 06:51
27b4464 to
01bfdb2
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 29, 2026 23:18
01bfdb2 to
dc274b3
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
2 times, most recently
from
July 30, 2026 00:31
2d41b43 to
9885cdf
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
July 30, 2026 22:54
9885cdf to
314a319
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
2 times, most recently
from
July 30, 2026 22:58
4055c03 to
9609486
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
2 times, most recently
from
August 5, 2026 00:10
cec27ff to
b67a574
Compare
ahomescu
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
2 times, most recently
from
August 5, 2026 00:22
9cbbba7 to
486931c
Compare
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
force-pushed
the
ahomescu/fix_reorganize_definitions/canonicalize_moved_paths
branch
from
August 5, 2026 00:43
486931c to
4cddd79
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
thingthat resolved through the glob wasnot canonicalized on the way out (
is_relative_pathtreats onlyself::/super::as relative), so the moved item failed to compile withE0412.
move_itemsnow runscanonicalize_moved_decl_pathsover everymoved declaration (and its
implblock): 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
usetargets are now recorded inModuleInfo::import_targets, mirroringupdate_module_info_items), orbecause 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_pathsviapath_mapping. Thereorganize_glob_importtest now uses the barethingfield type andverifies it becomes
crate::defs::thing.Stack created with GitHub Stacks CLI • Give Feedback 💬