Skip to content

Commit a97cbcf

Browse files
committed
Revert "Auto merge of rust-lang#82776 - jyn514:extern-url-fallback, r=GuillaumeGomez"
This reverts commit b1928aa, reversing changes made to 99b73e8.
1 parent 72a51c3 commit a97cbcf

File tree

9 files changed

+14
-51
lines changed

9 files changed

+14
-51
lines changed

src/librustdoc/clean/types.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,6 @@ impl ExternalCrate {
168168
crate fn location(
169169
&self,
170170
extern_url: Option<&str>,
171-
extern_url_takes_precedence: bool,
172171
dst: &std::path::Path,
173172
tcx: TyCtxt<'_>,
174173
) -> ExternalLocation {
@@ -190,10 +189,8 @@ impl ExternalCrate {
190189
return Local;
191190
}
192191

193-
if extern_url_takes_precedence {
194-
if let Some(url) = extern_url {
195-
return to_remote(url);
196-
}
192+
if let Some(url) = extern_url {
193+
return to_remote(url);
197194
}
198195

199196
// Failing that, see if there's an attribute specifying where to find this
@@ -205,7 +202,6 @@ impl ExternalCrate {
205202
.filter_map(|a| a.value_str())
206203
.map(to_remote)
207204
.next()
208-
.or(extern_url.map(to_remote)) // NOTE: only matters if `extern_url_takes_precedence` is false
209205
.unwrap_or(Unknown) // Well, at least we tried.
210206
}
211207

src/librustdoc/config.rs

-5
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,6 @@ crate struct RenderOptions {
233233
crate extension_css: Option<PathBuf>,
234234
/// A map of crate names to the URL to use instead of querying the crate's `html_root_url`.
235235
crate extern_html_root_urls: BTreeMap<String, String>,
236-
/// Whether to give precedence to `html_root_url` or `--exten-html-root-url`.
237-
crate extern_html_root_takes_precedence: bool,
238236
/// A map of the default settings (values are as for DOM storage API). Keys should lack the
239237
/// `rustdoc-` prefix.
240238
crate default_settings: FxHashMap<String, String>,
@@ -660,8 +658,6 @@ impl Options {
660658
let show_type_layout = matches.opt_present("show-type-layout");
661659
let nocapture = matches.opt_present("nocapture");
662660
let generate_link_to_definition = matches.opt_present("generate-link-to-definition");
663-
let extern_html_root_takes_precedence =
664-
matches.opt_present("extern-html-root-takes-precedence");
665661

666662
if generate_link_to_definition && (show_coverage || output_format != OutputFormat::Html) {
667663
diag.struct_err(
@@ -717,7 +713,6 @@ impl Options {
717713
themes,
718714
extension_css,
719715
extern_html_root_urls,
720-
extern_html_root_takes_precedence,
721716
default_settings,
722717
resource_suffix,
723718
enable_minification,

src/librustdoc/core.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,9 @@ crate fn run_global_ctxt(
499499

500500
let render_options = ctxt.render_options;
501501
let mut cache = ctxt.cache;
502-
krate = tcx.sess.time("create_format_cache", || cache.populate(krate, tcx, &render_options));
502+
krate = tcx.sess.time("create_format_cache", || {
503+
cache.populate(krate, tcx, &render_options.extern_html_root_urls, &render_options.output)
504+
});
503505

504506
// The main crate doc comments are always collapsed.
505507
krate.collapsed = true;

src/librustdoc/formats/cache.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
use std::collections::BTreeMap;
12
use std::mem;
3+
use std::path::Path;
24

35
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
46
use rustc_hir::def_id::{CrateNum, DefId, CRATE_DEF_INDEX};
@@ -7,7 +9,6 @@ use rustc_middle::ty::TyCtxt;
79
use rustc_span::symbol::sym;
810

911
use crate::clean::{self, GetDefId, ItemId};
10-
use crate::config::RenderOptions;
1112
use crate::fold::DocFolder;
1213
use crate::formats::item_type::ItemType;
1314
use crate::formats::Impl;
@@ -141,21 +142,19 @@ impl Cache {
141142
&mut self,
142143
mut krate: clean::Crate,
143144
tcx: TyCtxt<'_>,
144-
render_options: &RenderOptions,
145+
extern_html_root_urls: &BTreeMap<String, String>,
146+
dst: &Path,
145147
) -> clean::Crate {
146148
// Crawl the crate to build various caches used for the output
147149
debug!(?self.crate_version);
148150
self.traits = krate.external_traits.take();
149-
let RenderOptions { extern_html_root_takes_precedence, output: dst, .. } = render_options;
150151

151152
// Cache where all our extern crates are located
152153
// FIXME: this part is specific to HTML so it'd be nice to remove it from the common code
153154
for &e in &krate.externs {
154155
let name = e.name(tcx);
155-
let extern_url =
156-
render_options.extern_html_root_urls.get(&*name.as_str()).map(|u| &**u);
157-
let location = e.location(extern_url, *extern_html_root_takes_precedence, dst, tcx);
158-
self.extern_locations.insert(e.crate_num, location);
156+
let extern_url = extern_html_root_urls.get(&*name.as_str()).map(|u| &**u);
157+
self.extern_locations.insert(e.crate_num, e.location(extern_url, &dst, tcx));
159158
self.external_paths.insert(e.def_id(), (vec![name.to_string()], ItemType::Module));
160159
}
161160

src/librustdoc/lib.rs

-7
Original file line numberDiff line numberDiff line change
@@ -295,13 +295,6 @@ fn opts() -> Vec<RustcOptGroup> {
295295
"NAME=URL",
296296
)
297297
}),
298-
unstable("extern-html-root-takes-precedence", |o| {
299-
o.optflagmulti(
300-
"",
301-
"extern-html-root-takes-precedence",
302-
"give precedence to `--extern-html-root-url`, not `html_root_url`",
303-
)
304-
}),
305298
stable("plugin-path", |o| o.optmulti("", "plugin-path", "removed", "DIR")),
306299
stable("C", |o| {
307300
o.optmulti("C", "codegen", "pass a codegen option to rustc", "OPT[=VALUE]")

src/test/rustdoc/auxiliary/html_root.rs

-2
This file was deleted.

src/test/rustdoc/auxiliary/no_html_root.rs

-1
This file was deleted.

src/test/rustdoc/extern-html-root-url-precedence.rs

-7
This file was deleted.
+3-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
1-
// compile-flags:-Z unstable-options --extern-html-root-url html_root=https://example.com/override --extern-html-root-url no_html_root=https://example.com/override
2-
// aux-build:html_root.rs
3-
// aux-build:no_html_root.rs
4-
// NOTE: intentionally does not build any auxiliary docs
5-
6-
extern crate html_root;
7-
extern crate no_html_root;
1+
// compile-flags:-Z unstable-options --extern-html-root-url core=https://example.com/core/0.1.0
82

93
// @has extern_html_root_url/index.html
10-
// `html_root_url` should override `--extern-html-root-url`
11-
// @has - '//a/@href' 'https://example.com/html_root/html_root/fn.foo.html'
12-
#[doc(no_inline)]
13-
pub use html_root::foo;
14-
4+
// @has - '//a/@href' 'https://example.com/core/0.1.0/core/iter/index.html'
155
#[doc(no_inline)]
16-
// `--extern-html-root-url` should apply if no `html_root_url` is given
17-
// @has - '//a/@href' 'https://example.com/override/no_html_root/fn.bar.html'
18-
pub use no_html_root::bar;
6+
pub use std::iter;

0 commit comments

Comments
 (0)