Skip to content

Commit 27db90a

Browse files
Fix extern prelude failure in rustdoc
1 parent 9fae153 commit 27db90a

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

src/librustc/session/config.rs

+7
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,13 @@ impl Input {
494494
Input::Str { .. } => "rust_out".to_string(),
495495
}
496496
}
497+
498+
pub fn get_input(&mut self) -> Option<&mut String> {
499+
match *self {
500+
Input::File(_) => None,
501+
Input::Str { ref mut input, .. } => Some(input),
502+
}
503+
}
497504
}
498505

499506
#[derive(Clone)]

src/librustc_resolve/lib.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,9 @@ pub struct Resolver<'a> {
15291529
current_type_ascription: Vec<Span>,
15301530

15311531
injected_crate: Option<Module<'a>>,
1532+
1533+
/// Only supposed to be used by rustdoc, otherwise should be false.
1534+
pub ignore_extern_prelude_feature: bool,
15321535
}
15331536

15341537
/// Nothing really interesting here, it just provides memory for the rest of the crate.
@@ -1792,6 +1795,7 @@ impl<'a> Resolver<'a> {
17921795
unused_macros: FxHashSet(),
17931796
current_type_ascription: Vec::new(),
17941797
injected_crate: None,
1798+
ignore_extern_prelude_feature: false,
17951799
}
17961800
}
17971801

@@ -1972,7 +1976,8 @@ impl<'a> Resolver<'a> {
19721976
if !module.no_implicit_prelude {
19731977
// `record_used` means that we don't try to load crates during speculative resolution
19741978
if record_used && ns == TypeNS && self.extern_prelude.contains(&ident.name) {
1975-
if !self.session.features_untracked().extern_prelude {
1979+
if !self.session.features_untracked().extern_prelude &&
1980+
!self.ignore_extern_prelude_feature {
19761981
feature_err(&self.session.parse_sess, "extern_prelude",
19771982
ident.span, GateIssue::Language,
19781983
"access to extern crates through prelude is experimental").emit();

src/librustdoc/clean/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1034,7 +1034,7 @@ fn resolve(cx: &DocContext, path_str: &str, is_val: bool) -> Result<(Def, Option
10341034
// early return and try looking for the trait
10351035
let value = match result.def {
10361036
Def::Method(_) | Def::AssociatedConst(_) => true,
1037-
Def::AssociatedTy(_) => false,
1037+
Def::AssociatedTy(_) => false,
10381038
Def::Variant(_) => return handle_variant(cx, result.def),
10391039
// not a trait item, just return what we found
10401040
_ => return Ok((result.def, None))

src/librustdoc/core.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -227,10 +227,12 @@ pub fn run_core(search_paths: SearchPaths,
227227
|_| Ok(()));
228228
let driver::InnerExpansionResult {
229229
mut hir_forest,
230-
resolver,
230+
mut resolver,
231231
..
232232
} = abort_on_err(result, &sess);
233233

234+
resolver.ignore_extern_prelude_feature = true;
235+
234236
// We need to hold on to the complete resolver, so we clone everything
235237
// for the analysis passes to use. Suboptimal, but necessary in the
236238
// current architecture.

0 commit comments

Comments
 (0)