Add the remapping path documentation scope for rustdoc usage
This commit is contained in:
parent
ee6dd56425
commit
91e3e2a37f
6 changed files with 46 additions and 3 deletions
|
|
@ -1322,6 +1322,7 @@ impl OutputFilenames {
|
|||
pub(crate) 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();
|
||||
|
|
@ -1329,11 +1330,18 @@ pub(crate) 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
|
||||
},
|
||||
"debuginfo" => RemapPathScopeComponents::DEBUGINFO,
|
||||
"coverage" => RemapPathScopeComponents::COVERAGE,
|
||||
"object" => RemapPathScopeComponents::OBJECT,
|
||||
"all" => RemapPathScopeComponents::all(),
|
||||
_ => early_dcx.early_fatal("argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `coverage`, `object`, `all`"),
|
||||
_ => early_dcx.early_fatal("argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `documentation`, `debuginfo`, `coverage`, `object`, `all`"),
|
||||
}
|
||||
}
|
||||
slot
|
||||
|
|
@ -2677,7 +2685,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
|
|||
let externs = parse_externs(early_dcx, matches, &unstable_opts);
|
||||
|
||||
let remap_path_prefix = parse_remap_path_prefix(early_dcx, matches, &unstable_opts);
|
||||
let remap_path_scope = parse_remap_path_scope(early_dcx, matches);
|
||||
let remap_path_scope = parse_remap_path_scope(early_dcx, matches, &unstable_opts);
|
||||
|
||||
let pretty = parse_pretty(early_dcx, &unstable_opts);
|
||||
|
||||
|
|
|
|||
|
|
@ -233,6 +233,8 @@ bitflags::bitflags! {
|
|||
const DEBUGINFO = 1 << 3;
|
||||
/// Apply remappings to coverage information
|
||||
const COVERAGE = 1 << 4;
|
||||
/// Apply remappings to documentation information
|
||||
const DOCUMENTATION = 1 << 5;
|
||||
|
||||
/// An alias for `macro`, `debuginfo` and `coverage`. This ensures all paths in compiled
|
||||
/// executables, libraries and objects are remapped but not elsewhere.
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ The valid scopes are:
|
|||
- `debuginfo` - apply remappings to debug information
|
||||
- `coverage` - apply remappings to coverage information
|
||||
- `object` - apply remappings to all paths in compiled executables or libraries, but not elsewhere. Currently an alias for `macro,coverage,debuginfo`.
|
||||
- `all` (default) - an alias for all of the above, also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`.
|
||||
- `all` (default) - an alias for all of the above (and unstable scopes), also equivalent to supplying only `--remap-path-prefix` without `--remap-path-scope`.
|
||||
|
||||
The scopes accepted by `--remap-path-scope` are not exhaustive - new scopes may be added in future releases for eventual stabilisation.
|
||||
This implies that the `all` scope can correspond to different scopes between releases.
|
||||
|
|
|
|||
|
|
@ -12,7 +12,9 @@ fn main() {
|
|||
let mut out_simple = rustc();
|
||||
let mut out_object = rustc();
|
||||
let mut out_macro = rustc();
|
||||
let mut out_doc = rustc();
|
||||
let mut out_diagobj = rustc();
|
||||
let mut out_diagdocobj = rustc();
|
||||
out_simple
|
||||
.remap_path_prefix("auxiliary", "/the/aux")
|
||||
.crate_type("lib")
|
||||
|
|
@ -28,11 +30,21 @@ fn main() {
|
|||
.crate_type("lib")
|
||||
.emit("metadata")
|
||||
.input("auxiliary/lib.rs");
|
||||
out_doc
|
||||
.remap_path_prefix("auxiliary", "/the/aux")
|
||||
.crate_type("lib")
|
||||
.emit("metadata")
|
||||
.input("auxiliary/lib.rs");
|
||||
out_diagobj
|
||||
.remap_path_prefix("auxiliary", "/the/aux")
|
||||
.crate_type("lib")
|
||||
.emit("metadata")
|
||||
.input("auxiliary/lib.rs");
|
||||
out_diagdocobj
|
||||
.remap_path_prefix("auxiliary", "/the/aux")
|
||||
.crate_type("lib")
|
||||
.emit("metadata")
|
||||
.input("auxiliary/lib.rs");
|
||||
|
||||
out_simple.run();
|
||||
rmeta_contains("/the/aux/lib.rs");
|
||||
|
|
@ -40,11 +52,17 @@ 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_diagobj.arg("--remap-path-scope=diagnostics,object");
|
||||
out_diagdocobj
|
||||
.arg("--remap-path-scope=diagnostics,documentation,object")
|
||||
.arg("-Zunstable-options");
|
||||
if is_darwin() {
|
||||
out_object.arg("-Csplit-debuginfo=off");
|
||||
out_macro.arg("-Csplit-debuginfo=off");
|
||||
out_doc.arg("-Csplit-debuginfo=off");
|
||||
out_diagobj.arg("-Csplit-debuginfo=off");
|
||||
out_diagdocobj.arg("-Csplit-debuginfo=off");
|
||||
}
|
||||
|
||||
out_object.run();
|
||||
|
|
@ -53,8 +71,14 @@ fn main() {
|
|||
out_macro.run();
|
||||
rmeta_contains("/the/aux/lib.rs");
|
||||
rmeta_contains("auxiliary");
|
||||
out_doc.run();
|
||||
rmeta_contains("/the/aux/lib.rs");
|
||||
rmeta_contains("auxiliary");
|
||||
out_diagobj.run();
|
||||
rmeta_contains("/the/aux/lib.rs");
|
||||
rmeta_contains("auxiliary");
|
||||
out_diagdocobj.run();
|
||||
rmeta_contains("/the/aux/lib.rs");
|
||||
rmeta_not_contains("auxiliary");
|
||||
}
|
||||
|
||||
|
|
|
|||
7
tests/ui/feature-gates/remap-path-scope-documentation.rs
Normal file
7
tests/ui/feature-gates/remap-path-scope-documentation.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// 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() {}
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
error: remapping `documentation` path scope requested but `-Zunstable-options` not specified
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue