Skip to content

Commit d3bdea1

Browse files
committed
Stabilize --remap-path-prefix in rustdoc
1 parent 4dbafc3 commit d3bdea1

12 files changed

Lines changed: 34 additions & 30 deletions

src/doc/rustdoc/src/command-line-arguments.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,18 @@ affect that.
183183
The arguments to this flag are the same as those for the `-C` flag on rustc. Run `rustc -C help` to
184184
get the full list.
185185

186+
## `--remap-path-prefix`: remap source paths in output
187+
188+
This flag is the equivalent flag from `rustc`: `--remap-path-prefix`.
189+
190+
```bash
191+
$ rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo"
192+
```
193+
194+
It permits remapping (as a best effort) source path prefixes in all output, including diagnostics,
195+
debug information, macro expansions, generated documentation, etc. It takes a value of the
196+
form `FROM=TO` where a path prefix equal to `FROM` is rewritten to the value `TO`.
197+
186198
## `--test`: run code examples as tests
187199

188200
Using this flag looks like this:

src/doc/rustdoc/src/unstable-features.md

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -751,14 +751,6 @@ pass `--doctest-build-arg ARG` for each argument `ARG`.
751751

752752
This flag enables the generation of toggles to expand macros in the HTML source code pages.
753753

754-
## `--remap-path-prefix`: Remap source code paths in output
755-
756-
This flag is the equivalent flag from `rustc` `--remap-path-prefix`.
757-
758-
it permits remapping source path prefixes in all output, including compiler diagnostics,
759-
debug information, macro expansions, etc. It takes a value of the form `FROM=TO`
760-
where a path prefix equal to `FROM` is rewritten to the value `TO`.
761-
762754
## `--remap-path-scope`: Scopes to which the source remapping should be done
763755

764756
This flag is the equivalent flag from `rustc` `--remap-path-scope`.

src/librustdoc/lib.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,14 @@ fn opts() -> Vec<RustcOptGroup> {
456456
By default, it is at `forbid` level.",
457457
"LEVEL",
458458
),
459+
opt(
460+
Stable,
461+
Multi,
462+
"",
463+
"remap-path-prefix",
464+
"Remap source names in compiler messages",
465+
"FROM=TO",
466+
),
459467
opt(Unstable, Opt, "", "index-page", "Markdown file to be used as index page", "PATH"),
460468
opt(
461469
Unstable,
@@ -548,14 +556,6 @@ fn opts() -> Vec<RustcOptGroup> {
548556
"Force all doctests to be compiled as a single binary, instead of one binary per test. If merging fails, rustdoc will emit a hard error.",
549557
"yes|no|auto",
550558
),
551-
opt(
552-
Unstable,
553-
Multi,
554-
"",
555-
"remap-path-prefix",
556-
"Remap source names in compiler messages",
557-
"FROM=TO",
558-
),
559559
opt(
560560
Unstable,
561561
Opt,

tests/run-make/rustdoc-default-output/output-default.stdout

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ Options:
125125
Set the most restrictive lint level. More restrictive
126126
lints are capped at this level. By default, it is at
127127
`forbid` level.
128+
--remap-path-prefix FROM=TO
129+
Remap source names in compiler messages
128130
--index-page PATH
129131
Markdown file to be used as index page
130132
--enable-index-page
@@ -158,8 +160,6 @@ Options:
158160
Force all doctests to be compiled as a single binary,
159161
instead of one binary per test. If merging fails,
160162
rustdoc will emit a hard error.
161-
--remap-path-prefix FROM=TO
162-
Remap source names in compiler messages
163163
--remap-path-scope [macro,diagnostics,debuginfo,coverage,object,all]
164164
Defines which scopes of paths should be remapped by
165165
`--remap-path-prefix`

tests/rustdoc-html/auxiliary/remapped-paths.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//@ compile-flags:-Zunstable-options --remap-path-prefix={{src-base}}=
1+
//@ compile-flags:--remap-path-prefix={{src-base}}=
22

33
pub struct MyStruct {
44
field: u32,

tests/rustdoc-ui/lints/remap-path-prefix-lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Regression test for remapped paths in rustdoc errors
22
// <https://github.com/rust-lang/rust/issues/69264>.
33

4-
//@ compile-flags:-Z unstable-options --remap-path-prefix={{src-base}}=remapped_path
4+
//@ compile-flags:--remap-path-prefix={{src-base}}=remapped_path
55
//@ rustc-env:RUST_BACKTRACE=0
66

77
#![deny(rustdoc::invalid_html_tags)]

tests/rustdoc-ui/remap-path-prefix-doctest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//@ revisions: without-scope
1010

1111
//@ compile-flags:--test --test-args --test-threads=1
12-
//@ compile-flags:-Z unstable-options --remap-path-prefix={{src-base}}=remapped_path
12+
//@ compile-flags:--remap-path-prefix={{src-base}}=remapped_path
1313

1414
//@[with-diag-scope] compile-flags: -Zunstable-options --remap-path-scope=diagnostics
1515
//@[with-macro-scope] compile-flags: -Zunstable-options --remap-path-scope=macro

tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// adapted to use that, and that normalize line can go away
33

44
//@ failure-status: 101
5-
//@ compile-flags:--test -Z unstable-options --remap-path-prefix={{src-base}}=remapped_path --test-args --test-threads=1
5+
//@ compile-flags:--test --remap-path-prefix={{src-base}}=remapped_path --test-args --test-threads=1
66
//@ rustc-env:RUST_BACKTRACE=0
77
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
88
//@ normalize-stdout: "exit (status|code): 101" -> "exit status: 101"

tests/rustdoc-ui/remap-path-prefix-invalid-doctest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// adapted to use that, and that normalize line can go away
33

44
//@ failure-status: 101
5-
//@ compile-flags:--test -Z unstable-options --remap-path-prefix={{src-base}}=remapped_path --test-args --test-threads=1
5+
//@ compile-flags:--test --remap-path-prefix={{src-base}}=remapped_path --test-args --test-threads=1
66
//@ rustc-env:RUST_BACKTRACE=0
77
//@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME"
88

tests/rustdoc-ui/remap-path-prefix-macro-138520.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// when using --remap-path-prefix with macro rendering.
33
// <https://github.com/rust-lang/rust/issues/138520>
44

5-
//@ compile-flags:-Z unstable-options --remap-path-prefix={{src-base}}=remapped_path
5+
//@ compile-flags:--remap-path-prefix={{src-base}}=remapped_path
66
//@ rustc-env:RUST_BACKTRACE=0
77
//@ build-pass
88

0 commit comments

Comments
 (0)