File tree 4 files changed +28
-18
lines changed
4 files changed +28
-18
lines changed Original file line number Diff line number Diff line change @@ -2643,15 +2643,12 @@ fn clean_extern_crate<'tcx>(
2643
2643
}
2644
2644
}
2645
2645
2646
- // FIXME: using `from_def_id_and_kind` breaks `rustdoc/masked` for some reason
2647
- vec ! [ Item {
2648
- name: Some ( name) ,
2649
- attrs: Box :: new( Attributes :: from_ast( attrs) ) ,
2650
- item_id: crate_def_id. into( ) ,
2651
- kind: Box :: new( ExternCrateItem { src: orig_name } ) ,
2652
- cfg: attrs. cfg( cx. tcx, & cx. cache. hidden_cfg) ,
2653
- inline_stmt_id: Some ( krate_owner_def_id) ,
2654
- } ]
2646
+ vec ! [ Item :: from_def_id_and_parts(
2647
+ krate_owner_def_id,
2648
+ Some ( name) ,
2649
+ ExternCrateItem { src: orig_name } ,
2650
+ cx,
2651
+ ) ]
2655
2652
}
2656
2653
2657
2654
fn clean_use_statement < ' tcx > (
Original file line number Diff line number Diff line change @@ -38,11 +38,15 @@ pub(crate) fn krate(cx: &mut DocContext<'_>) -> Crate {
38
38
for it in & module. items {
39
39
// `compiler_builtins` should be masked too, but we can't apply
40
40
// `#[doc(masked)]` to the injected `extern crate` because it's unstable.
41
- if it. is_extern_crate ( )
42
- && ( it. attrs . has_doc_flag ( sym:: masked)
43
- || cx. tcx . is_compiler_builtins ( it. item_id . krate ( ) ) )
44
- {
41
+ if cx. tcx . is_compiler_builtins ( it. item_id . krate ( ) ) {
45
42
cx. cache . masked_crates . insert ( it. item_id . krate ( ) ) ;
43
+ } else if it. is_extern_crate ( )
44
+ && it. attrs . has_doc_flag ( sym:: masked)
45
+ && let Some ( def_id) = it. item_id . as_def_id ( )
46
+ && let Some ( local_def_id) = def_id. as_local ( )
47
+ && let Some ( cnum) = cx. tcx . extern_mod_stmt_cnum ( local_def_id)
48
+ {
49
+ cx. cache . masked_crates . insert ( cnum) ;
46
50
}
47
51
}
48
52
}
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ use rustc_data_structures::captures::Captures;
18
18
use rustc_data_structures:: fx:: FxHashSet ;
19
19
use rustc_hir as hir;
20
20
use rustc_hir:: def:: DefKind ;
21
- use rustc_hir:: def_id:: DefId ;
21
+ use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
22
22
use rustc_metadata:: creader:: { CStore , LoadedMacro } ;
23
23
use rustc_middle:: ty;
24
24
use rustc_middle:: ty:: TyCtxt ;
@@ -662,6 +662,14 @@ pub(crate) fn href_with_root_path(
662
662
// documented on their parent's page
663
663
tcx. parent ( did)
664
664
}
665
+ DefKind :: ExternCrate => {
666
+ // Link to the crate itself, not the `extern crate` item.
667
+ if let Some ( local_did) = did. as_local ( ) {
668
+ tcx. extern_mod_stmt_cnum ( local_did) . unwrap_or ( LOCAL_CRATE ) . as_def_id ( )
669
+ } else {
670
+ did
671
+ }
672
+ }
665
673
_ => did,
666
674
} ;
667
675
let cache = cx. cache ( ) ;
Original file line number Diff line number Diff line change 4
4
// ignore-cross-compile
5
5
6
6
// @has issue_33178/index.html
7
- // @has - //a/@title empty
8
- // @has - //a/@href ../empty/index.html
7
+ // @has - '//a[@title="mod empty"][@href="../empty/index.html"]' empty
9
8
pub extern crate empty;
10
9
11
- // @has - //a/@title variant_struct
12
- // @has - //a/@href ../variant_struct/index.html
10
+ // @has - '//a[@title="mod variant_struct"][@href="../variant_struct/index.html"]' variant_struct
13
11
pub extern crate variant_struct as foo;
12
+
13
+ // @has - '//a[@title="mod issue_33178"][@href="index.html"]' self
14
+ pub extern crate self as bar;
You can’t perform that action at this time.
0 commit comments