diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index fdfc2aacc79a8..f9d6565c08a48 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -1383,7 +1383,6 @@ impl OutputFilenames { pub fn parse_remap_path_scope( early_dcx: &EarlyDiagCtxt, matches: &getopts::Matches, - unstable_opts: &UnstableOptions, ) -> RemapPathScopeComponents { if let Some(v) = matches.opt_str("remap-path-scope") { let mut slot = RemapPathScopeComponents::empty(); @@ -1391,13 +1390,7 @@ pub fn parse_remap_path_scope( slot |= match s { "macro" => RemapPathScopeComponents::MACRO, "diagnostics" => RemapPathScopeComponents::DIAGNOSTICS, - "documentation" => { - if !unstable_opts.unstable_options { - early_dcx.early_fatal("remapping `documentation` path scope requested but `-Zunstable-options` not specified"); - } - - RemapPathScopeComponents::DOCUMENTATION - }, + "documentation" => RemapPathScopeComponents::DOCUMENTATION, "debuginfo" => RemapPathScopeComponents::DEBUGINFO, "coverage" => RemapPathScopeComponents::COVERAGE, "object" => RemapPathScopeComponents::OBJECT, @@ -2137,7 +2130,7 @@ pub fn rustc_optgroups() -> Vec { "", "remap-path-scope", "Defines which scopes of paths should be remapped by `--remap-path-prefix`", - "", + "", ), opt(Unstable, Opt, "j", "jobs", "Limit on the number of used parallel jobs", ""), opt( @@ -2969,7 +2962,7 @@ pub fn build_session_options( let externs = parse_externs(early_dcx, matches, &unstable_opts); let remap_path_prefix = parse_remap_path_prefix(early_dcx, matches); - let remap_path_scope = parse_remap_path_scope(early_dcx, matches, &unstable_opts); + let remap_path_scope = parse_remap_path_scope(early_dcx, matches); let pretty = parse_pretty(early_dcx, &unstable_opts); diff --git a/src/doc/rustdoc/src/command-line-arguments.md b/src/doc/rustdoc/src/command-line-arguments.md index 74bb5efcabd85..e02ad01dfe9bc 100644 --- a/src/doc/rustdoc/src/command-line-arguments.md +++ b/src/doc/rustdoc/src/command-line-arguments.md @@ -195,6 +195,19 @@ It permits remapping (as a best effort) source path prefixes in all output, incl 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`. +## `--remap-path-scope`: Scopes to which the source remapping should be done + +This flag is the equivalent flag from `rustc` `--remap-path-scope`. + +Defines which scopes of paths should be remapped by --remap-path-prefix. + +### `documentation` scope + +`rustdoc` (and by extension `rustc`) have a special `documentation` remapping scope, it +permits remapping source paths that ends up in the generated documentation. + +It can specified with `--remap-path-scope=documentation`. + ## `--test`: run code examples as tests Using this flag looks like this: diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index ab317ba1048a4..143d47407096a 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -801,19 +801,6 @@ pass `--doctest-build-arg ARG` for each argument `ARG`. This flag enables the generation of toggles to expand macros in the HTML source code pages. -## `--remap-path-scope`: Scopes to which the source remapping should be done - -This flag is the equivalent flag from `rustc` `--remap-path-scope`. - -Defines which scopes of paths should be remapped by --remap-path-prefix. - -### `documentation` scope - -`rustdoc` (and by extension `rustc`) have a special `documentation` remapping scope, it -permits remapping source paths that ends up in the generated documentation. - -It can specified with `--remap-path-scope=documentation`. - ## `#[doc(cfg)]` and `#[doc(auto_cfg)]` This feature aims at providing rustdoc users the possibility to add visual markers to the rendered documentation to know under which conditions an item is available (currently possible through the following unstable feature: `doc_cfg`). diff --git a/src/librustdoc/config.rs b/src/librustdoc/config.rs index 170352dabf656..e1e49b59711f5 100644 --- a/src/librustdoc/config.rs +++ b/src/librustdoc/config.rs @@ -421,8 +421,7 @@ impl Options { early_dcx.early_fatal(err); } }; - let remap_path_scope = - rustc_session::config::parse_remap_path_scope(early_dcx, matches, &unstable_opts); + let remap_path_scope = rustc_session::config::parse_remap_path_scope(early_dcx, matches); let dcx = new_dcx(error_format, None, diagnostic_width, &unstable_opts); let dcx = dcx.handle(); diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index 85bae04fcb2e8..8d744b00120eb 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -461,6 +461,14 @@ fn opts() -> Vec { "Remap source names in compiler messages", "FROM=TO", ), + opt( + Stable, + Opt, + "", + "remap-path-scope", + "Defines which scopes of paths should be remapped by `--remap-path-prefix`", + "[macro,diagnostics,documentation,debuginfo,coverage,object,all]", + ), opt(Unstable, Opt, "", "index-page", "Markdown file to be used as index page", "PATH"), opt( Unstable, @@ -561,14 +569,6 @@ fn opts() -> Vec { "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.", "yes|no|auto", ), - opt( - Unstable, - Opt, - "", - "remap-path-scope", - "Defines which scopes of paths should be remapped by `--remap-path-prefix`", - "[macro,diagnostics,debuginfo,coverage,object,all]", - ), opt( Unstable, FlagMulti, diff --git a/tests/run-make/remap-path-prefix/rmake.rs b/tests/run-make/remap-path-prefix/rmake.rs index 3b866476e9501..2e87c620f94a7 100644 --- a/tests/run-make/remap-path-prefix/rmake.rs +++ b/tests/run-make/remap-path-prefix/rmake.rs @@ -52,11 +52,9 @@ fn main() { out_object.arg("--remap-path-scope=object"); out_macro.arg("--remap-path-scope=macro"); - out_doc.arg("--remap-path-scope=documentation").arg("-Zunstable-options"); + out_doc.arg("--remap-path-scope=documentation"); out_diagobj.arg("--remap-path-scope=diagnostics,object"); - out_diagdocobj - .arg("--remap-path-scope=diagnostics,documentation,object") - .arg("-Zunstable-options"); + out_diagdocobj.arg("--remap-path-scope=diagnostics,documentation,object"); if is_darwin() { out_object.arg("-Csplit-debuginfo=off"); out_macro.arg("-Csplit-debuginfo=off"); diff --git a/tests/run-make/rustc-help/help-v.diff b/tests/run-make/rustc-help/help-v.diff index 94ed6a0ed027c..4c12a7429e8d7 100644 --- a/tests/run-make/rustc-help/help-v.diff +++ b/tests/run-make/rustc-help/help-v.diff @@ -20,7 +20,7 @@ + --remap-path-prefix = + Remap source names in all output (compiler messages + and output files) -+ --remap-path-scope ++ --remap-path-scope + Defines which scopes of paths should be remapped by + `--remap-path-prefix` + @path Read newline separated options from `path` diff --git a/tests/run-make/rustc-help/help-v.stdout b/tests/run-make/rustc-help/help-v.stdout index 3a6b1d270b405..557bb8a8764ce 100644 --- a/tests/run-make/rustc-help/help-v.stdout +++ b/tests/run-make/rustc-help/help-v.stdout @@ -83,7 +83,7 @@ Options: --remap-path-prefix = Remap source names in all output (compiler messages and output files) - --remap-path-scope + --remap-path-scope Defines which scopes of paths should be remapped by `--remap-path-prefix` @path Read newline separated options from `path` diff --git a/tests/run-make/rustdoc/default-output/output-default.stdout b/tests/run-make/rustdoc/default-output/output-default.stdout index 3093a01ec79f7..9ceebefe389da 100644 --- a/tests/run-make/rustdoc/default-output/output-default.stdout +++ b/tests/run-make/rustdoc/default-output/output-default.stdout @@ -127,6 +127,9 @@ Options: `forbid` level. --remap-path-prefix FROM=TO Remap source names in compiler messages + --remap-path-scope [macro,diagnostics,documentation,debuginfo,coverage,object,all] + Defines which scopes of paths should be remapped by + `--remap-path-prefix` --index-page PATH Markdown file to be used as index page --enable-index-page @@ -162,9 +165,6 @@ Options: 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. - --remap-path-scope [macro,diagnostics,debuginfo,coverage,object,all] - Defines which scopes of paths should be remapped by - `--remap-path-prefix` --show-type-layout Include the memory layout of types in the docs --no-capture Don't capture stdout and stderr of tests diff --git a/tests/rustdoc-ui/remap-path-prefix-doctest.rs b/tests/rustdoc-ui/remap-path-prefix-doctest.rs index dcfc2ddf62e4f..6db19f01c7c12 100644 --- a/tests/rustdoc-ui/remap-path-prefix-doctest.rs +++ b/tests/rustdoc-ui/remap-path-prefix-doctest.rs @@ -11,10 +11,10 @@ //@ compile-flags:--test --test-args --test-threads=1 //@ compile-flags:--remap-path-prefix={{src-base}}=remapped_path -//@[with-diag-scope] compile-flags: -Zunstable-options --remap-path-scope=diagnostics -//@[with-macro-scope] compile-flags: -Zunstable-options --remap-path-scope=macro -//@[with-object-scope] compile-flags: -Zunstable-options --remap-path-scope=debuginfo -//@[with-doc-scope] compile-flags: -Zunstable-options --remap-path-scope=documentation +//@[with-diag-scope] compile-flags: --remap-path-scope=diagnostics +//@[with-macro-scope] compile-flags: --remap-path-scope=macro +//@[with-object-scope] compile-flags: --remap-path-scope=debuginfo +//@[with-doc-scope] compile-flags: --remap-path-scope=documentation /// ``` /// fn invalid( diff --git a/tests/rustdoc-ui/remap-path-prefix.rs b/tests/rustdoc-ui/remap-path-prefix.rs index 8c6e2bde95717..be90e46cdf9c0 100644 --- a/tests/rustdoc-ui/remap-path-prefix.rs +++ b/tests/rustdoc-ui/remap-path-prefix.rs @@ -13,10 +13,10 @@ //@[with-doc-scope] compile-flags: --remap-path-prefix={{src-base}}=remapped //@[without-scopes] compile-flags: --remap-path-prefix={{src-base}}=remapped -//@[with-diag-scope] compile-flags: -Zunstable-options --remap-path-scope=diagnostics -//@[with-macro-scope] compile-flags: -Zunstable-options --remap-path-scope=macro -//@[with-debuginfo-scope] compile-flags: -Zunstable-options --remap-path-scope=debuginfo -//@[with-doc-scope] compile-flags: -Zunstable-options --remap-path-scope=documentation +//@[with-diag-scope] compile-flags: --remap-path-scope=diagnostics +//@[with-macro-scope] compile-flags: --remap-path-scope=macro +//@[with-debuginfo-scope] compile-flags: --remap-path-scope=debuginfo +//@[with-doc-scope] compile-flags: --remap-path-scope=documentation compile_error!(concat!("file!() = ", file!())); //[with-macro-scope]~^ ERROR file!() diff --git a/tests/rustdoc-ui/remap-path-scope-unstable.rs b/tests/rustdoc-ui/remap-path-scope-unstable.rs deleted file mode 100644 index 34b8040c87c1b..0000000000000 --- a/tests/rustdoc-ui/remap-path-scope-unstable.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Regression test to make sure `--remap-path-scope` is unstable in rustdoc - -//@ compile-flags:--remap-path-scope macro - -//~? RAW the `-Z unstable-options` flag must also be passed to enable the flag `remap-path-scope` - -fn main() {} diff --git a/tests/rustdoc-ui/remap-path-scope-unstable.stderr b/tests/rustdoc-ui/remap-path-scope-unstable.stderr deleted file mode 100644 index 04c51836206aa..0000000000000 --- a/tests/rustdoc-ui/remap-path-scope-unstable.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: the `-Z unstable-options` flag must also be passed to enable the flag `remap-path-scope` - diff --git a/tests/ui/errors/auxiliary/file-doc.rs b/tests/ui/errors/auxiliary/file-doc.rs index 4e9733bd5a1c0..8a3b2a35625a1 100644 --- a/tests/ui/errors/auxiliary/file-doc.rs +++ b/tests/ui/errors/auxiliary/file-doc.rs @@ -1,5 +1,5 @@ //@ compile-flags: --remap-path-prefix={{src-base}}=remapped -//@ compile-flags: --remap-path-scope=documentation -Zunstable-options +//@ compile-flags: --remap-path-scope=documentation #[macro_export] macro_rules! my_file { diff --git a/tests/ui/errors/auxiliary/trait-doc.rs b/tests/ui/errors/auxiliary/trait-doc.rs index 451437de5f119..402a191860c8a 100644 --- a/tests/ui/errors/auxiliary/trait-doc.rs +++ b/tests/ui/errors/auxiliary/trait-doc.rs @@ -1,4 +1,4 @@ //@ compile-flags: --remap-path-prefix={{src-base}}=remapped -//@ compile-flags: --remap-path-scope=documentation -Zunstable-options +//@ compile-flags: --remap-path-scope=documentation pub trait Trait: std::fmt::Display {} diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.rs b/tests/ui/errors/remap-path-prefix-diagnostics.rs index 8976106ab3472..e6cb61f0f6a09 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.rs +++ b/tests/ui/errors/remap-path-prefix-diagnostics.rs @@ -16,7 +16,7 @@ //@[with-diag-in-deps] compile-flags: --remap-path-scope=diagnostics //@[with-macro-in-deps] compile-flags: --remap-path-scope=macro //@[with-debuginfo-in-deps] compile-flags: --remap-path-scope=debuginfo -//@[with-doc-in-deps] compile-flags: --remap-path-scope=documentation -Zunstable-options +//@[with-doc-in-deps] compile-flags: --remap-path-scope=documentation //@[not-diag-in-deps] compile-flags: --remap-path-scope=diagnostics //@[with-diag-in-deps] aux-build:trait-diag.rs diff --git a/tests/ui/errors/remap-path-prefix-macro.rs b/tests/ui/errors/remap-path-prefix-macro.rs index 89e2379b575c4..49c15e70d33be 100644 --- a/tests/ui/errors/remap-path-prefix-macro.rs +++ b/tests/ui/errors/remap-path-prefix-macro.rs @@ -19,7 +19,7 @@ //@[with-diag-in-deps] compile-flags: --remap-path-scope=diagnostics //@[with-macro-in-deps] compile-flags: --remap-path-scope=macro //@[with-debuginfo-in-deps] compile-flags: --remap-path-scope=debuginfo -//@[with-doc-in-deps] compile-flags: --remap-path-scope=documentation -Zunstable-options +//@[with-doc-in-deps] compile-flags: --remap-path-scope=documentation //@[not-macro-in-deps] compile-flags: --remap-path-scope=macro //@[with-diag-in-deps] aux-build:file-diag.rs diff --git a/tests/ui/feature-gates/remap-path-scope-documentation.rs b/tests/ui/feature-gates/remap-path-scope-documentation.rs deleted file mode 100644 index 55610c0376285..0000000000000 --- a/tests/ui/feature-gates/remap-path-scope-documentation.rs +++ /dev/null @@ -1,7 +0,0 @@ -// Test that documentation scope is unstable - -//@ compile-flags: --remap-path-scope=documentation - -//~? ERROR remapping `documentation` path scope requested but `-Zunstable-options` not specified - -fn main() {} diff --git a/tests/ui/feature-gates/remap-path-scope-documentation.stderr b/tests/ui/feature-gates/remap-path-scope-documentation.stderr deleted file mode 100644 index 03316ad86a549..0000000000000 --- a/tests/ui/feature-gates/remap-path-scope-documentation.stderr +++ /dev/null @@ -1,2 +0,0 @@ -error: remapping `documentation` path scope requested but `-Zunstable-options` not specified -