Rollup of 3 pull requests#156808
Open
JonathanBrouwer wants to merge 9 commits into
Open
Conversation
…literal was expected
…-prefix, r=GuillaumeGomez Stabilize `--remap-path-prefix` in rustdoc # Stabilization report of `--remap-path-prefix` in rustdoc ## 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` in `rustdoc`. There are no tracking issue. Stabilization was discussed at the last meeting, [#t-rustdoc/meetings > 2026-04-13 @ 💬](https://rust-lang.zulipchat.com/#narrow/channel/393423-t-rustdoc.2Fmeetings/topic/2026-04-13/near/585264347). ### What is stabilized The rustdoc `--remap-path-prefix` flag is being stabilized by this PR. (It's equivalent to rustc flag) It permits remapping (as a best effort) source path prefixes in all output, including diagnostics, debug information, macro expansions, generated documentation, etc. It takes a value of the form `FROM=TO` where a path prefix equal to `FROM` is rewritten to the value `TO`. #### Example ```sh rustdoc src/lib.rs --remap-path-prefix="$PWD=/foo" ``` ### What isn't stabilized Neither `--remap-path-scope` (~~soon to be added as unstable in `rustdoc`~~ rust-lang#155451) or the already unstable in `rustc` `documentation` scope are being stabilized or added here. ## Design ### Implementation history - rust-lang#107099 ### Unresolved questions There are no unresolved questions. ### Post-implementation changes The implementation has evolved with `rustc`, but no changes to the flag it-self have been made. ### Nightly extensions The `documentation` scope, which currently can only be set from `rustc`, as we need to add an equivalent to the `--remap-path-scope` flag, ~~which is planned~~ (EDIT: rust-lang#155451), but not required, the current `--remap-path-prefix` defaults to the `all` scope, like `rustc`. ### Doors closed We are committing to having to having a flag that permits remapping paths. The compiler team already made the same commitment. ## Feedback ### Call for testing No call for testing has been done. ### Nightly use Unable to determine. A [GitHub search](https://github.com/search?q=%20%2F--remap-path-prefix%2F&type=code) only seems to only reveals the `rustc` usage (over 6k though). Rust-for-Linux is using the [flag](https://github.com/torvalds/linux/blob/e80d033851b3bc94c3d254ac66660ddd0a49d72c/Makefile#L1151-L1153). ## Implementation ### Major parts - rust-lang#107099 - rust-lang#149709 - rust-lang#150172 - rust-lang#151589 ### Coverage - [`tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.rs`](https://github.com/rust-lang/rust/blob/12f35ad39ed3e39df4d953c46d4f6cc6c82adc96/tests/rustdoc-ui/remap-path-prefix-failed-doctest-output.rs) - [`tests/rustdoc-ui/remap-path-prefix-invalid-doctest.rs`](https://github.com/rust-lang/rust/blob/12f35ad39ed3e39df4d953c46d4f6cc6c82adc96/tests/rustdoc-ui/remap-path-prefix-invalid-doctest.rs) - [`tests/rustdoc-ui/remap-path-prefix-macro.rs`](https://github.com/rust-lang/rust/blob/12f35ad39ed3e39df4d953c46d4f6cc6c82adc96/tests/rustdoc-ui/remap-path-prefix-macro.rs) - [`tests/rustdoc-ui/remap-path-prefix-passed-doctest-output.rs`](https://github.com/rust-lang/rust/blob/12f35ad39ed3e39df4d953c46d4f6cc6c82adc96/tests/rustdoc-ui/remap-path-prefix-passed-doctest-output.rs) - [`tests/rustdoc-ui/lints/remap-path-prefix-lint.rs`](https://github.com/rust-lang/rust/blob/12f35ad39ed3e39df4d953c46d4f6cc6c82adc96/tests/rustdoc-ui/lints/remap-path-prefix-lint.rs) - [`tests/rustdoc-html/import-remapped-paths.rs`](https://github.com/rust-lang/rust/blob/12f35ad39ed3e39df4d953c46d4f6cc6c82adc96/tests/rustdoc-html/import-remapped-paths.rs) - [`tests/rustdoc-html/macro/external-macro-src.rs`](https://github.com/rust-lang/rust/blob/12f35ad39ed3e39df4d953c46d4f6cc6c82adc96/tests/rustdoc-html/macro/external-macro-src.rs) ### Outstanding bugs There are no outstanding bugs regarding `--remap-path-prefix` 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-prefix`. ## Acknowledgments - @edward-shen - @Urgau
…=joboet Use strongly typed wrapped indices in `VecDeque` This is far from perfect, but it would have prevented rust-lang#151769. r? @joboet
…hanBrouwer Suggest adding quotation marks to identifiers in attributes When the user provides an identifier when a literal was expected in an attribute value, suggest adding quotation marks to the identifier to make it a string literal. For instance: ``` error: attribute value must be a literal --> $DIR/crate-type-non-crate.rs:9:16 | LL | #[crate_type = lib] | ^^^ help: try adding quotation marks: `"lib"` ```
Contributor
Author
|
@bors r+ rollup=never p=5 |
Contributor
This comment has been minimized.
This comment has been minimized.
Collaborator
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Contributor
|
💔 Test for 633ba3a failed: CI. Failed job:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Successful merges:
--remap-path-prefixin rustdoc #155307 (Stabilize--remap-path-prefixin rustdoc)VecDeque#152112 (Use strongly typed wrapped indices inVecDeque)r? @ghost
Create a similar rollup