pub fn find_phantom_modules(
project: &ProjectRoot,
max_results: usize,
) -> Result<Vec<PhantomModuleEntry>>Expand description
Finds Rust mod NAME; declarations whose NAME does not appear as a
path segment anywhere else in the workspace.
Match strategy (v1, regex-only):
- Collect every
mod NAME;declaration with its parent file and line. - Build a set of referenced module names by scanning all Rust source
for tokens that look like
NAME::,::NAME;, or::NAME::. - Any declared
NAMEnot in the set is a phantom.
Tradeoffs:
- Reports
pub modtoo — re-export patterns may keep them useful; visibility is reported so callers can filter. - Does not understand path aliases (
use foo as bar;); we still catch the original name on either side of the alias.