Skip to main content

Module pathfix

Module pathfix 

Source
Expand description

Rewrite module-relative paths inside an item that moves one level deeper.

When an item moves from module M into M::child, any path that was written relative to M must gain one level:

  • super::Xsuper::super::X
  • self::Xsuper::X

Crucially this only applies at the item’s own module depth. A super:: written inside a nested mod { … } within the item is relative to that nested module and must be left alone. We track mod nesting with a syn::visit::Visit and only rewrite at depth 0. Visibilities are handled separately (see crate::classify), so we skip them here to avoid double-editing. Paths hidden inside macro token streams are invisible to syn and therefore not rewritten — if one slips through, the compiler-verification step rolls the whole split back.

Functions§

relative_path_edits
Compute the path-rewrite edits (absolute byte coords) for one moved item.