Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions compiler/rustc_session/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1383,21 +1383,14 @@ 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();
for s in v.split(',') {
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,
Expand Down Expand Up @@ -2137,7 +2130,7 @@ pub fn rustc_optgroups() -> Vec<RustcOptGroup> {
"",
"remap-path-scope",
"Defines which scopes of paths should be remapped by `--remap-path-prefix`",
"<macro,diagnostics,debuginfo,coverage,object,all>",
"<macro,diagnostics,documentation,debuginfo,coverage,object,all>",
),
opt(Unstable, Opt, "j", "jobs", "Limit on the number of used parallel jobs", "<N>"),
opt(
Expand Down Expand Up @@ -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);

Expand Down
13 changes: 13 additions & 0 deletions src/doc/rustdoc/src/command-line-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 0 additions & 13 deletions src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`).
Expand Down
3 changes: 1 addition & 2 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
16 changes: 8 additions & 8 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,14 @@ fn opts() -> Vec<RustcOptGroup> {
"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,
Expand Down Expand Up @@ -561,14 +569,6 @@ fn opts() -> Vec<RustcOptGroup> {
"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,
Expand Down
6 changes: 2 additions & 4 deletions tests/run-make/remap-path-prefix/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/rustc-help/help-v.diff
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
+ --remap-path-prefix <FROM>=<TO>
+ Remap source names in all output (compiler messages
+ and output files)
+ --remap-path-scope <macro,diagnostics,debuginfo,coverage,object,all>
+ --remap-path-scope <macro,diagnostics,documentation,debuginfo,coverage,object,all>
+ Defines which scopes of paths should be remapped by
+ `--remap-path-prefix`
+ @path Read newline separated options from `path`
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/rustc-help/help-v.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Options:
--remap-path-prefix <FROM>=<TO>
Remap source names in all output (compiler messages
and output files)
--remap-path-scope <macro,diagnostics,debuginfo,coverage,object,all>
--remap-path-scope <macro,diagnostics,documentation,debuginfo,coverage,object,all>
Defines which scopes of paths should be remapped by
`--remap-path-prefix`
@path Read newline separated options from `path`
Expand Down
6 changes: 3 additions & 3 deletions tests/run-make/rustdoc/default-output/output-default.stdout
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions tests/rustdoc-ui/remap-path-prefix-doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 4 additions & 4 deletions tests/rustdoc-ui/remap-path-prefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!()
Expand Down
7 changes: 0 additions & 7 deletions tests/rustdoc-ui/remap-path-scope-unstable.rs

This file was deleted.

2 changes: 0 additions & 2 deletions tests/rustdoc-ui/remap-path-scope-unstable.stderr

This file was deleted.

2 changes: 1 addition & 1 deletion tests/ui/errors/auxiliary/file-doc.rs
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/errors/auxiliary/trait-doc.rs
Original file line number Diff line number Diff line change
@@ -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 {}
2 changes: 1 addition & 1 deletion tests/ui/errors/remap-path-prefix-diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/ui/errors/remap-path-prefix-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 0 additions & 7 deletions tests/ui/feature-gates/remap-path-scope-documentation.rs

This file was deleted.

2 changes: 0 additions & 2 deletions tests/ui/feature-gates/remap-path-scope-documentation.stderr

This file was deleted.

Loading