(startDir: string | null, rest: string[])
| 1886 | // `<seg>.rs` or `<seg>/mod.rs` file. Returns the leaf module's file, or null |
| 1887 | // if `startDir` is null or any segment has no file on disk. |
| 1888 | const resolveUnder = (startDir: string | null, rest: string[]): string | null => { |
| 1889 | if (!startDir) return null; |
| 1890 | let dir = startDir; |
| 1891 | let targetFile: string | null = null; |
| 1892 | for (const seg of rest) { |
| 1893 | if (seg === 'self' || seg === 'crate' || seg === 'super') continue; |
| 1894 | const asFile = toRel(path.join(dir, seg + '.rs')); |
| 1895 | const asMod = toRel(path.join(dir, seg, 'mod.rs')); |
| 1896 | if (context.fileExists(asFile)) targetFile = asFile; |
| 1897 | else if (context.fileExists(asMod)) targetFile = asMod; |
| 1898 | else return null; |
| 1899 | dir = path.join(dir, seg); |
| 1900 | } |
| 1901 | return targetFile; |
| 1902 | }; |
| 1903 | |
| 1904 | const first = segments[0]!; |
| 1905 | if (first === 'crate') { |
no test coverage detected