File tree 4 files changed +44
-1
lines changed 4 files changed +44
-1
lines changed Original file line number Diff line number Diff line change @@ -1020,6 +1020,7 @@ impl CheckAttrVisitor<'_> {
1020
1020
| sym:: html_root_url
1021
1021
| sym:: html_no_source
1022
1022
| sym:: test
1023
+ | sym:: extern_html_root_url
1023
1024
if !self . check_attr_crate_level ( attr, meta, hir_id) =>
1024
1025
{
1025
1026
is_valid = false ;
@@ -1052,6 +1053,7 @@ impl CheckAttrVisitor<'_> {
1052
1053
sym:: alias
1053
1054
| sym:: cfg
1054
1055
| sym:: cfg_hide
1056
+ | sym:: extern_html_root_url
1055
1057
| sym:: hidden
1056
1058
| sym:: html_favicon_url
1057
1059
| sym:: html_logo_url
Original file line number Diff line number Diff line change @@ -653,6 +653,7 @@ symbols! {
653
653
extern_absolute_paths,
654
654
extern_crate_item_prelude,
655
655
extern_crate_self,
656
+ extern_html_root_url,
656
657
extern_in_paths,
657
658
extern_prelude,
658
659
extern_types,
Original file line number Diff line number Diff line change @@ -230,7 +230,8 @@ pub(crate) struct RenderOptions {
230
230
pub ( crate ) extension_css : Option < PathBuf > ,
231
231
/// A map of crate names to the URL to use instead of querying the crate's `html_root_url`.
232
232
pub ( crate ) extern_html_root_urls : BTreeMap < String , String > ,
233
- /// Whether to give precedence to `html_root_url` or `--exten-html-root-url`.
233
+ /// Whether to give precedence to `html_root_url` or `--extern-html-root-url`.
234
+ /// By default it is `html_root_url`.
234
235
pub ( crate ) extern_html_root_takes_precedence : bool ,
235
236
/// A map of the default settings (values are as for DOM storage API). Keys should lack the
236
237
/// `rustdoc-` prefix.
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ use rustc_span::symbol::sym;
21
21
use rustc_span:: { source_map, Span , Symbol } ;
22
22
23
23
use std:: cell:: RefCell ;
24
+ use std:: collections:: btree_map:: Entry ;
24
25
use std:: lazy:: SyncLazy ;
25
26
use std:: mem;
26
27
use std:: rc:: Rc ;
@@ -456,6 +457,44 @@ pub(crate) fn run_global_ctxt(
456
457
if attr. is_word ( ) && name == sym:: document_private_items {
457
458
ctxt. render_options . document_private = true ;
458
459
}
460
+
461
+ if name == sym:: extern_html_root_url {
462
+ if let Some ( attr) = attr. meta_item_list ( ) {
463
+ for sub_attr in attr {
464
+ let name = sub_attr. name_or_empty ( ) . as_str ( ) . to_owned ( ) ;
465
+ match sub_attr. value_str ( ) {
466
+ Some ( value) => {
467
+ let value = value. as_str ( ) . to_owned ( ) ;
468
+ if value. is_empty ( ) {
469
+ tcx. sess . span_err ( sub_attr. span ( ) , "URL cannot be empty" ) ;
470
+ continue ;
471
+ }
472
+ match ctxt. render_options . extern_html_root_urls . entry ( name) {
473
+ Entry :: Occupied ( _) => {
474
+ // do nothing since command line `--extern_html_root_url`
475
+ // takes precedence.
476
+ }
477
+ Entry :: Vacant ( v) => {
478
+ v. insert ( value) ;
479
+ }
480
+ }
481
+ }
482
+ None => {
483
+ tcx. sess . span_err (
484
+ sub_attr. span ( ) ,
485
+ "extern_html_root_url() only accepts `crate_name = \" url\" `" ,
486
+ ) ;
487
+ }
488
+ }
489
+ }
490
+ } else {
491
+ diag. span_err (
492
+ attr. span ( ) ,
493
+ "extern_html_root_url only accepts this form: \
494
+ `extern_html_root_url(crate = \" url\" )`",
495
+ ) ;
496
+ }
497
+ }
459
498
}
460
499
461
500
info ! ( "Executing passes" ) ;
You can’t perform that action at this time.
0 commit comments