(startDir: string | null, rest: string[])
| 1638 | // `<seg>.rs` or `<seg>/mod.rs` file. Returns the leaf module's file, or null |
| 1639 | // if `startDir` is null or any segment has no file on disk. |
| 1640 | const resolveUnder = (startDir: string | null, rest: string[]): string | null => { |
| 1641 | if (!startDir) return null; |
| 1642 | let dir = startDir; |
| 1643 | let targetFile: string | null = null; |
| 1644 | for (const seg of rest) { |
| 1645 | if (seg === 'self' || seg === 'crate' || seg === 'super') continue; |
| 1646 | const asFile = toRel(path.join(dir, seg + '.rs')); |
| 1647 | const asMod = toRel(path.join(dir, seg, 'mod.rs')); |
| 1648 | if (context.fileExists(asFile)) targetFile = asFile; |
| 1649 | else if (context.fileExists(asMod)) targetFile = asMod; |
| 1650 | else return null; |
| 1651 | dir = path.join(dir, seg); |
| 1652 | } |
| 1653 | return targetFile; |
| 1654 | }; |
| 1655 | |
| 1656 | const first = segments[0]!; |
| 1657 | if (first === 'crate') { |
no test coverage detected