rustdoc: Support --extern-private but treat as --extern

This makes `rustdoc` support `--extern-private` but treats it
the same as `--extern` which is useful for making the CLI more
similar to `rustc` to ease test suite integration.

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2019-11-08 07:29:08 +00:00
parent 3f0e16473d
commit 2c33568a77
No known key found for this signature in database
GPG key ID: C30DF439F2987D74
2 changed files with 7 additions and 1 deletions

View file

@ -608,10 +608,12 @@ fn parse_extern_html_roots(
/// Extracts `--extern CRATE=PATH` arguments from `matches` and
/// returns a map mapping crate names to their paths or else an
/// error message.
/// Also handles `--extern-private` which for the purposes of rustdoc
/// we can treat as `--extern`
// FIXME(eddyb) This shouldn't be duplicated with `rustc::session`.
fn parse_externs(matches: &getopts::Matches) -> Result<Externs, String> {
let mut externs: BTreeMap<_, ExternEntry> = BTreeMap::new();
for arg in &matches.opt_strs("extern") {
for arg in matches.opt_strs("extern").iter().chain(matches.opt_strs("extern-private").iter()) {
let mut parts = arg.splitn(2, '=');
let name = parts.next().ok_or("--extern value must not be empty".to_string())?;
let location = parts.next().map(|s| s.to_string());

View file

@ -142,6 +142,10 @@ fn opts() -> Vec<RustcOptGroup> {
stable("extern", |o| {
o.optmulti("", "extern", "pass an --extern to rustc", "NAME=PATH")
}),
stable("extern-private", |o| {
o.optmulti("", "extern-private",
"pass an --extern to rustc (compatibility only)", "NAME=PATH")
}),
unstable("extern-html-root-url", |o| {
o.optmulti("", "extern-html-root-url",
"base URL to use for dependencies", "NAME=URL")