@@ -13,6 +13,7 @@ use rustc_hir::def_id::DefId;
13
13
use rustc_hir:: Mutability ;
14
14
use rustc_metadata:: creader:: { CStore , LoadedMacro } ;
15
15
use rustc_middle:: ty:: { self , TyCtxt } ;
16
+ use rustc_span:: def_id:: LOCAL_CRATE ;
16
17
use rustc_span:: hygiene:: MacroKind ;
17
18
use rustc_span:: symbol:: { kw, sym, Symbol } ;
18
19
@@ -378,6 +379,14 @@ pub(crate) fn build_impl(
378
379
let tcx = cx. tcx ;
379
380
let associated_trait = tcx. impl_trait_ref ( did) ;
380
381
382
+ // Do not inline compiler-internal items unless we're a compiler-internal crate.
383
+ let document_compiler_internal =
384
+ if let Some ( stab) = tcx. lookup_stability ( LOCAL_CRATE . as_def_id ( ) ) {
385
+ stab. is_unstable ( ) && stab. feature == sym:: rustc_private
386
+ } else {
387
+ false
388
+ } ;
389
+
381
390
// Only inline impl if the implemented trait is
382
391
// reachable in rustdoc generated documentation
383
392
if !did. is_local ( ) {
@@ -387,10 +396,8 @@ pub(crate) fn build_impl(
387
396
return ;
388
397
}
389
398
390
- if let Some ( stab) = tcx. lookup_stability ( did) {
391
- if stab. is_unstable ( ) && stab. feature == sym:: rustc_private {
392
- return ;
393
- }
399
+ if !document_compiler_internal && let Some ( stab) = tcx. lookup_stability ( did) && stab. is_unstable ( ) && stab. feature == sym:: rustc_private {
400
+ return ;
394
401
}
395
402
}
396
403
}
@@ -416,10 +423,8 @@ pub(crate) fn build_impl(
416
423
return ;
417
424
}
418
425
419
- if let Some ( stab) = tcx. lookup_stability ( did) {
420
- if stab. is_unstable ( ) && stab. feature == sym:: rustc_private {
421
- return ;
422
- }
426
+ if !document_compiler_internal && let Some ( stab) = tcx. lookup_stability ( did) && stab. is_unstable ( ) && stab. feature == sym:: rustc_private {
427
+ return ;
423
428
}
424
429
}
425
430
}
0 commit comments