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

Fix extern prelude failure in rustdoc #50617

Merged
merged 1 commit into from
Jun 12, 2018
Merged
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
7 changes: 7 additions & 0 deletions src/librustc/session/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,13 @@ impl Input {
Input::Str { .. } => "rust_out".to_string(),
}
}

pub fn get_input(&mut self) -> Option<&mut String> {
match *self {
Input::File(_) => None,
Input::Str { ref mut input, .. } => Some(input),
}
}
}

#[derive(Clone)]
Expand Down
7 changes: 6 additions & 1 deletion src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1437,6 +1437,9 @@ pub struct Resolver<'a> {
current_type_ascription: Vec<Span>,

injected_crate: Option<Module<'a>>,

/// Only supposed to be used by rustdoc, otherwise should be false.
pub ignore_extern_prelude_feature: bool,
}

/// Nothing really interesting here, it just provides memory for the rest of the crate.
Expand Down Expand Up @@ -1718,6 +1721,7 @@ impl<'a> Resolver<'a> {
unused_macros: FxHashSet(),
current_type_ascription: Vec::new(),
injected_crate: None,
ignore_extern_prelude_feature: false,
}
}

Expand Down Expand Up @@ -1891,7 +1895,8 @@ impl<'a> Resolver<'a> {
if !module.no_implicit_prelude {
// `record_used` means that we don't try to load crates during speculative resolution
if record_used && ns == TypeNS && self.extern_prelude.contains(&ident.name) {
if !self.session.features_untracked().extern_prelude {
if !self.session.features_untracked().extern_prelude &&
!self.ignore_extern_prelude_feature {
feature_err(&self.session.parse_sess, "extern_prelude",
ident.span, GateIssue::Language,
"access to extern crates through prelude is experimental").emit();
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1103,7 +1103,7 @@ fn resolve(cx: &DocContext, path_str: &str, is_val: bool) -> Result<(Def, Option
// early return and try looking for the trait
let value = match result.def {
Def::Method(_) | Def::AssociatedConst(_) => true,
Def::AssociatedTy(_) => false,
Def::AssociatedTy(_) => false,
Def::Variant(_) => return handle_variant(cx, result.def),
// not a trait item, just return what we found
_ => return Ok((result.def, None))
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,10 +250,12 @@ pub fn run_core(search_paths: SearchPaths,
|_| Ok(()));
let driver::InnerExpansionResult {
mut hir_forest,
resolver,
mut resolver,
..
} = abort_on_err(result, &sess);

resolver.ignore_extern_prelude_feature = true;

// We need to hold on to the complete resolver, so we clone everything
// for the analysis passes to use. Suboptimal, but necessary in the
// current architecture.
Expand Down