Skip to content

Pass the unremapped path to the rustc invocation for doctests - #163956

Merged
rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
Urgau:rustdoc-doctest-scopes
Oct 9, 2026
Merged

rust-bors[bot] merged 2 commits into
rust-lang:mainfrom
Urgau:rustdoc-doctest-scopes

Conversation

@Urgau

@Urgau Urgau commented Oct 7, 2026

Copy link
Copy Markdown
Member

Turns out that --remap-path-scope is only half working with doctests, this is because rustdoc use a secret environment variable to pass the real filename of the doctest.

However we were only passing a remapped path. That means that doctests source path were getting remapped, but only for one scope: documentation. It didn't respect macro for file! for example.

To fix this, we have to:

  1. pass the local path to the rustc invocation
  2. have rustc treat that path as a real filename and apply remapping per scope to it
    • I had to add a new Input variant, otherwise I can't differentiate normal input - from doctests - source
  3. we have to pass --remap-path-{prefix,scope} to rustc so the path actually gets remap properly

Thanks to @weihanglo for pointing me to the bug.

Relevant for #163895
r? @GuillaumeGomez

@Urgau Urgau added the F-trim-paths Feature: trim-paths label Oct 7, 2026
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 7, 2026
Comment thread compiler/rustc_driver_impl/src/lib.rs Resolved

@GuillaumeGomez GuillaumeGomez left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from my nit, looks good to me, thanks! r=me once the name change is reverted

View changes since this review

@Urgau
Urgau force-pushed the rustdoc-doctest-scopes branch from ff1b312 to 9cf4406 Compare October 8, 2026 20:11
@Urgau

Urgau commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

@bors r=GuillaumeGomez

@rust-bors

rust-bors Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 9cf4406 has been tentatively approved by GuillaumeGomez

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 8, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 9, 2026
…illaumeGomez

Pass the unremapped path to the `rustc` invocation for doctests

Turns out that `--remap-path-scope` is only half working with doctests, this is because `rustdoc` use a secret environment variable to pass the real filename of the doctest.

However we were only passing a remapped path. That means that doctests source path were getting remapped, but only for one scope: `documentation`. It didn't respect `macro` for `file!` for example.

To fix this, we have to:
 1. pass the local path to the `rustc` invocation
 2. have `rustc` treat that path as a real filename and apply remapping per scope to it
    - I had to add a new `Input` variant, otherwise I can't differentiate normal input `-` from doctests `-` source
 4. we have to pass `--remap-path-{prefix,scope}` to `rustc` so the path actually gets remap properly
rust-bors Bot pushed a commit that referenced this pull request Oct 9, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #162652 (Syntactically reject leading parenthesized precise capturing lists in bare trait object types (`(use<…>)+`))
 - #163337 (MIR move elimination [3/6]: PreciseLiveness)
 - #163954 (fix(bootstrap/darwin): fix rpath for distributed LLD)
 - #163956 (Pass the unremapped path to the `rustc` invocation for doctests)
 - #163634 (move overflow lint computation into decorator)
 - #163727 (rigid aliases to non-rigid for fully normalized check)
 - #163745 (replace `fully_monomorphized` with `cx.typing_env()`)
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 9, 2026
…illaumeGomez

Pass the unremapped path to the `rustc` invocation for doctests

Turns out that `--remap-path-scope` is only half working with doctests, this is because `rustdoc` use a secret environment variable to pass the real filename of the doctest.

However we were only passing a remapped path. That means that doctests source path were getting remapped, but only for one scope: `documentation`. It didn't respect `macro` for `file!` for example.

To fix this, we have to:
 1. pass the local path to the `rustc` invocation
 2. have `rustc` treat that path as a real filename and apply remapping per scope to it
    - I had to add a new `Input` variant, otherwise I can't differentiate normal input `-` from doctests `-` source
 4. we have to pass `--remap-path-{prefix,scope}` to `rustc` so the path actually gets remap properly
@JonathanBrouwer

Copy link
Copy Markdown
Member

💔 I suspect this PR failed tests as part of a rollup
@bors r-

After fixing the problem, consider running a try job for the failed job before re-approving.

Link to failure: #164015 (comment)

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 9, 2026
@rust-bors

rust-bors Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#164015), which was unapproved.

View changes since this unapproval

rust-bors Bot pushed a commit that referenced this pull request Oct 9, 2026
…uwer

Rollup of 11 pull requests

Successful merges:

 - #162652 (Syntactically reject leading parenthesized precise capturing lists in bare trait object types (`(use<…>)+`))
 - #163337 (MIR move elimination [3/6]: PreciseLiveness)
 - #163954 (fix(bootstrap/darwin): fix rpath for distributed LLD)
 - #163956 (Pass the unremapped path to the `rustc` invocation for doctests)
 - #163634 (move overflow lint computation into decorator)
 - #163666 (Updates the expect message library/core/src/time.rs)
 - #163727 (rigid aliases to non-rigid for fully normalized check)
 - #163745 (replace `fully_monomorphized` with `cx.typing_env()`)
 - #164000 (When mentioning that closure doesn't implement trait, point at closure)
 - #164007 ([rustdoc] Prefer local paths over remote ones when foreign item is locally reexported)
 - #164017 (cg_llvm: Avoid some explicit casts to `*const c_char`)
@Urgau
Urgau force-pushed the rustdoc-doctest-scopes branch from 9cf4406 to 85b2304 Compare October 9, 2026 16:11
@Urgau

Urgau commented Oct 9, 2026

Copy link
Copy Markdown
Member Author

CI sometimes runs in /tmp, duh! Removed the faulty assertion.

@bors r=GuillaumeGomez

@rust-bors

rust-bors Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 85b2304 has been tentatively approved by GuillaumeGomez

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 9, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 9, 2026
…illaumeGomez

Pass the unremapped path to the `rustc` invocation for doctests

Turns out that `--remap-path-scope` is only half working with doctests, this is because `rustdoc` use a secret environment variable to pass the real filename of the doctest.

However we were only passing a remapped path. That means that doctests source path were getting remapped, but only for one scope: `documentation`. It didn't respect `macro` for `file!` for example.

To fix this, we have to:
 1. pass the local path to the `rustc` invocation
 2. have `rustc` treat that path as a real filename and apply remapping per scope to it
    - I had to add a new `Input` variant, otherwise I can't differentiate normal input `-` from doctests `-` source
 4. we have to pass `--remap-path-{prefix,scope}` to `rustc` so the path actually gets remap properly
rust-bors Bot pushed a commit that referenced this pull request Oct 9, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - #161998 ( Support type-relative assoc item paths in generic param defaults & const param types)
 - #162106 (Helpful suggestions for incorrect address-of mutability (2))
 - #162652 (Syntactically reject leading parenthesized precise capturing lists in bare trait object types (`(use<…>)+`))
 - #163337 (MIR move elimination [3/6]: PreciseLiveness)
 - #163938 (-Zassumptions-on-binders: rewrite alias outlives constraints more goodly)
 - #163939 (Better debug impls for some assumptions on binders types)
 - #163954 (fix(bootstrap/darwin): fix rpath for distributed LLD)
 - #163956 (Pass the unremapped path to the `rustc` invocation for doctests)
 - #164042 (Allow testing cg-gcc on any target)
 - #162443 (Do not retain `Normalization` goal errors in nested goals for `BestObligationVisitor:: non_trivial_candidates `)
 - #162908 (Fix - const parameters rejected when identical)
 - #163193 (cfi: mangle `f128` as `e` rather than `g` on platforms without `_Float128`)
 - #163634 (move overflow lint computation into decorator)
 - #163666 (Updates the expect message library/core/src/time.rs)
 - #163727 (rigid aliases to non-rigid for fully normalized check)
 - #163745 (replace `fully_monomorphized` with `cx.typing_env()`)
 - #163912 (Fix debug assert failure in `note_obligation_cause_code_inner`)
 - #163950 (don't treat inherited opaques as defining)
 - #163972 (const-eval: ICE when we hit a non-const fn)
 - #164000 (When mentioning that closure doesn't implement trait, point at closure)
 - #164007 ([rustdoc] Prefer local paths over remote ones when foreign item is locally reexported)
 - #164008 (properly ignore the current goal's usages)
 - #164017 (cg_llvm: Avoid some explicit casts to `*const c_char`)
 - #164025 (Less `CanonicalVarValues`)
@rust-bors
rust-bors Bot merged commit a2170e9 into rust-lang:main Oct 9, 2026
14 checks passed
@rustbot rustbot added this to the 1.101.0 milestone Oct 9, 2026
rust-bors Bot pushed a commit that referenced this pull request Oct 9, 2026
Rollup merge of #163956 - Urgau:rustdoc-doctest-scopes, r=GuillaumeGomez

Pass the unremapped path to the `rustc` invocation for doctests

Turns out that `--remap-path-scope` is only half working with doctests, this is because `rustdoc` use a secret environment variable to pass the real filename of the doctest.

However we were only passing a remapped path. That means that doctests source path were getting remapped, but only for one scope: `documentation`. It didn't respect `macro` for `file!` for example.

To fix this, we have to:
 1. pass the local path to the `rustc` invocation
 2. have `rustc` treat that path as a real filename and apply remapping per scope to it
    - I had to add a new `Input` variant, otherwise I can't differentiate normal input `-` from doctests `-` source
 4. we have to pass `--remap-path-{prefix,scope}` to `rustc` so the path actually gets remap properly
bjorn3 pushed a commit to rust-lang/rustc_codegen_cranelift that referenced this pull request Oct 12, 2026
…uwer

Rollup of 24 pull requests

Successful merges:

 - rust-lang/rust#161998 ( Support type-relative assoc item paths in generic param defaults & const param types)
 - rust-lang/rust#162106 (Helpful suggestions for incorrect address-of mutability (2))
 - rust-lang/rust#162652 (Syntactically reject leading parenthesized precise capturing lists in bare trait object types (`(use<…>)+`))
 - rust-lang/rust#163337 (MIR move elimination [3/6]: PreciseLiveness)
 - rust-lang/rust#163938 (-Zassumptions-on-binders: rewrite alias outlives constraints more goodly)
 - rust-lang/rust#163939 (Better debug impls for some assumptions on binders types)
 - rust-lang/rust#163954 (fix(bootstrap/darwin): fix rpath for distributed LLD)
 - rust-lang/rust#163956 (Pass the unremapped path to the `rustc` invocation for doctests)
 - rust-lang/rust#164042 (Allow testing cg-gcc on any target)
 - rust-lang/rust#162443 (Do not retain `Normalization` goal errors in nested goals for `BestObligationVisitor:: non_trivial_candidates `)
 - rust-lang/rust#162908 (Fix - const parameters rejected when identical)
 - rust-lang/rust#163193 (cfi: mangle `f128` as `e` rather than `g` on platforms without `_Float128`)
 - rust-lang/rust#163634 (move overflow lint computation into decorator)
 - rust-lang/rust#163666 (Updates the expect message library/core/src/time.rs)
 - rust-lang/rust#163727 (rigid aliases to non-rigid for fully normalized check)
 - rust-lang/rust#163745 (replace `fully_monomorphized` with `cx.typing_env()`)
 - rust-lang/rust#163912 (Fix debug assert failure in `note_obligation_cause_code_inner`)
 - rust-lang/rust#163950 (don't treat inherited opaques as defining)
 - rust-lang/rust#163972 (const-eval: ICE when we hit a non-const fn)
 - rust-lang/rust#164000 (When mentioning that closure doesn't implement trait, point at closure)
 - rust-lang/rust#164007 ([rustdoc] Prefer local paths over remote ones when foreign item is locally reexported)
 - rust-lang/rust#164008 (properly ignore the current goal's usages)
 - rust-lang/rust#164017 (cg_llvm: Avoid some explicit casts to `*const c_char`)
 - rust-lang/rust#164025 (Less `CanonicalVarValues`)
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
…uillaumeGomez

Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope



# Stabilization report of  `--remap-path-scope` in rustdoc and the `documentation` scope

## Summary

`rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc.

This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files.

This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`.

Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488. 

Tracking issue: #155451.

It's the last major part of the trim-paths feature.

### What is stabilized

The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope).

It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`.

#### Example

```sh
rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation
```

#### The `documentation`

In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](#163896)).

## Implementation

### Major parts

- #155357
- #151589
- #163956
- #164278
- #164279

### Coverage

- [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs)
- [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs)
- [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs)
- [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs)

### Outstanding bugs

There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`.

There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have. 

### Outstanding FIXMEs

There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc).

Fixes #163896
Fixes #155451
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 27, 2026
…ustdoc, r=GuillaumeGomez

Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope

# Stabilization report of  `--remap-path-scope` in rustdoc and the `documentation` scope

## Summary

`rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc.

This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files.

This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`.

Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488.

Tracking issue: rust-lang#155451.

It's the last major part of the trim-paths feature.

### What is stabilized

The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope).

It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`.

#### Example

```sh
rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation
```

#### The `documentation`

In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](rust-lang#163896)).

## Implementation

### Major parts

- rust-lang#155357
- rust-lang#151589
- rust-lang#163956
- rust-lang#164278
- rust-lang#164279

### Coverage

- [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs)
- [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs)
- [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs)
- [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs)

### Outstanding bugs

There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`.

There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have.

### Outstanding FIXMEs

There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc).

Fixes rust-lang#163896
Fixes rust-lang#155451
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
…uillaumeGomez

Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope



# Stabilization report of  `--remap-path-scope` in rustdoc and the `documentation` scope

## Summary

`rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc.

This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files.

This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`.

Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488. 

Tracking issue: #155451.

It's the last major part of the trim-paths feature.

### What is stabilized

The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope).

It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`.

#### Example

```sh
rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation
```

#### The `documentation`

In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](#163896)).

## Implementation

### Major parts

- #155357
- #151589
- #163956
- #164278
- #164279

### Coverage

- [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs)
- [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs)
- [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs)
- [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs)

### Outstanding bugs

There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`.

There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have. 

### Outstanding FIXMEs

There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc).

Fixes #163896
Fixes #155451
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 27, 2026
…ustdoc, r=GuillaumeGomez

Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope

# Stabilization report of  `--remap-path-scope` in rustdoc and the `documentation` scope

## Summary

`rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc.

This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files.

This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`.

Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488.

Tracking issue: rust-lang#155451.

It's the last major part of the trim-paths feature.

### What is stabilized

The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope).

It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`.

#### Example

```sh
rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation
```

#### The `documentation`

In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](rust-lang#163896)).

## Implementation

### Major parts

- rust-lang#155357
- rust-lang#151589
- rust-lang#163956
- rust-lang#164278
- rust-lang#164279

### Coverage

- [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs)
- [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs)
- [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs)
- [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs)

### Outstanding bugs

There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`.

There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have.

### Outstanding FIXMEs

There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc).

Fixes rust-lang#163896
Fixes rust-lang#155451
rust-bors Bot pushed a commit that referenced this pull request Nov 27, 2026
Rollup merge of #163895 - Urgau:stabilize-remap-path-scope-rustdoc, r=GuillaumeGomez

Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope

# Stabilization report of  `--remap-path-scope` in rustdoc and the `documentation` scope

## Summary

`rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc.

This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files.

This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`.

Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488.

Tracking issue: #155451.

It's the last major part of the trim-paths feature.

### What is stabilized

The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope).

It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`.

#### Example

```sh
rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation
```

#### The `documentation`

In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](#163896)).

## Implementation

### Major parts

- #155357
- #151589
- #163956
- #164278
- #164279

### Coverage

- [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs)
- [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs)
- [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs)
- [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs)

### Outstanding bugs

There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`.

There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have.

### Outstanding FIXMEs

There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc).

Fixes #163896
Fixes #155451
mehmettoplu-rs pushed a commit to mehmettoplu-rs/miri that referenced this pull request Nov 28, 2026
…=GuillaumeGomez

Stabilize `--remap-path-scope` in rustdoc and the `documentation` scope

# Stabilization report of  `--remap-path-scope` in rustdoc and the `documentation` scope

## Summary

`rustc` supports remapping source paths prefixes as a best effort in all compiler generated output, including compiler diagnostics, debugging information, macro expansions, documentation, doctests, etc.

This is useful for normalizing build products, for example, by removing the current directory out of the paths emitted into object files.

This stabilization stabilize the same flag used by `rustc` to control which generted output has remapped paths in `rustdoc`.

Cargo is starting to use the `rustc` flag with rust-lang/cargo#17488.

Tracking issue: rust-lang/rust#155451.

It's the last major part of the trim-paths feature.

### What is stabilized

The rustdoc `--remap-path-scope` flag is being stabilized by this PR. It's equivalent to [the rustc flag](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope).

It permits defines which scopes should be remapped by `-–remap-path-prefix`: `macro,diagnostics,documentation,debuginfo,coverage,object,all`.

#### Example

```sh
rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" --remap-path-prefix=documentation
```

#### The `documentation`

In addition to the [other scopes](https://doc.rust-lang.org/rustc/remap-source-paths.html#--remap-path-scope) (`diagnostics`, `debuginfo`, ...). `rustdoc` uses the `documentation` scope, it's a new scope to be shared with `rustc` (T-compiler [FCP here](rust-lang/rust#163896)).

## Implementation

### Major parts

- rust-lang/rust#155357
- rust-lang/rust#151589
- rust-lang/rust#163956
- rust-lang/rust#164278
- rust-lang/rust#164279

### Coverage

- [`tests/rustdoc-ui/remap-path-prefix.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix.rs)
- [`tests/rustdoc-ui/remap-path-prefix-doctest.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/rustdoc-ui/remap-path-prefix-doctest.rs)
- [`tests/ui/errors/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-macro.rs)
- [`tests/ui/errors/remap-path-prefix-diagnostics.rs`](https://github.com/rust-lang/rust/blob/b57eb9a5fd94f30697f51fc88fbe898e67c7aae6/tests/ui/errors/remap-path-prefix-diagnostics.rs)

### Outstanding bugs

There are no outstanding bugs regarding `--remap-path-scope` in `rustdoc`.

There are [caveats and limitation](https://doc.rust-lang.org/nightly/rustc/remap-source-paths.html#caveats-and-limitations) in `rustc`, but they mostly concern generated object files, which we don't really have.

### Outstanding FIXMEs

There are no FIXME regarding `--remap-path-scope` (in rustc or rustdoc).

Fixes rust-lang/rust#163896
Fixes rust-lang/rust#155451
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

F-trim-paths Feature: trim-paths S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants