(startDir: string | null, rest: string[])
| 2160 | // `<seg>.rs` or `<seg>/mod.rs` file. Returns the leaf module's file, or null |
| 2161 | // if `startDir` is null or any segment has no file on disk. |
| 2162 | const resolveUnder = (startDir: string | null, rest: string[]): string | null => { |
| 2163 | if (!startDir) return null; |
| 2164 | let dir = startDir; |
| 2165 | let targetFile: string | null = null; |
| 2166 | for (const seg of rest) { |
| 2167 | if (seg === 'self' || seg === 'crate' || seg === 'super') continue; |
| 2168 | const asFile = toRel(path.join(dir, seg + '.rs')); |
| 2169 | const asMod = toRel(path.join(dir, seg, 'mod.rs')); |
| 2170 | if (context.fileExists(asFile)) targetFile = asFile; |
| 2171 | else if (context.fileExists(asMod)) targetFile = asMod; |
| 2172 | else return null; |
| 2173 | dir = path.join(dir, seg); |
| 2174 | } |
| 2175 | return targetFile; |
| 2176 | }; |
| 2177 | |
| 2178 | const first = segments[0]!; |
| 2179 | if (first === 'crate') { |
no test coverage detected