Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly parse '--extern-private' with name and path #59335

Merged
merged 13 commits into from
Apr 14, 2019
10 changes: 8 additions & 2 deletions src/librustdoc/config.rs
Original file line number Diff line number Diff line change
@@ -578,7 +578,7 @@ fn parse_extern_html_roots(
/// error message.
// FIXME(eddyb) This shouldn't be duplicated with `rustc::session`.
fn parse_externs(matches: &getopts::Matches) -> Result<Externs, String> {
let mut externs: BTreeMap<_, BTreeSet<_>> = BTreeMap::new();
let mut externs: BTreeMap<_, ExternEntry> = BTreeMap::new();
for arg in &matches.opt_strs("extern") {
let mut parts = arg.splitn(2, '=');
let name = parts.next().ok_or("--extern value must not be empty".to_string())?;
@@ -589,7 +589,13 @@ fn parse_externs(matches: &getopts::Matches) -> Result<Externs, String> {
}
let name = name.to_string();
// For Rustdoc purposes, we can treat all externs as public
externs.entry(name).or_default().insert(ExternEntry { location, public: true });
externs.entry(name)
.and_modify(|e| { e.locations.insert(location.clone()); } )
.or_insert_with(|| {
let mut locations = BTreeSet::new();
locations.insert(location);
ExternEntry { locations, is_private_dep: false }
});
}
Ok(Externs::new(externs))
}