Skip to content

Commit b1fd0b3

Browse files
Rollup merge of #150393 - Urgau:remap-path-relative-doc, r=jieyouxu
Document relative and absolute paths handling in `--remap-path-prefix` After what we have been through with #150110 and #150283 in the compiler, I think it would be good to document the user-facing parts of the relative and absolute paths handling in `--remap-path-prefix`. r? `@jieyouxu`
2 parents c7aa99f + 90e80f5 commit b1fd0b3

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/doc/rustc/src/remap-source-paths.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,20 @@ The replacement is purely textual, with no consideration of the current system's
1717

1818
When multiple remappings are given and several of them match, the **last** matching one is applied.
1919

20+
### Relative paths
21+
22+
Some build systems, such as Cargo, may compile crates using relative paths (for example,
23+
`src/main.rs` instead of `/home/user/project/src/main.rs)`.
24+
25+
`rustc` preserves these relative paths where possible. However, certain inputs
26+
(like `#[path = "..."]`) and outputs (such as debug information) may still contain absolute paths.
27+
28+
To ensure consistency, it’s recommended to remap both relative and absolute paths.
29+
30+
```bash
31+
rustc --remap-path-prefix "src/=/redacted/src" --remap-path-prefix "/home/user/project=/redacted"
32+
```
33+
2034
### Example
2135

2236
```bash

0 commit comments

Comments
 (0)