@@ -380,23 +380,29 @@ pub(crate) fn build_impl(
380
380
let associated_trait = tcx. impl_trait_ref ( did) ;
381
381
382
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 ( ) ) {
383
+ let is_compiler_internal = |did| {
384
+ if let Some ( stab) = tcx. lookup_stability ( did ) {
385
385
stab. is_unstable ( ) && stab. feature == sym:: rustc_private
386
386
} else {
387
387
false
388
- } ;
388
+ }
389
+ } ;
390
+ let document_compiler_internal = is_compiler_internal ( LOCAL_CRATE . as_def_id ( ) ) ;
391
+ let is_directly_public = |cx : & mut DocContext < ' _ > , did| {
392
+ if !cx. cache . effective_visibilities . is_directly_public ( tcx, did) {
393
+ return false ;
394
+ }
395
+ if !document_compiler_internal && is_compiler_internal ( did) {
396
+ return false ;
397
+ }
398
+ true
399
+ } ;
389
400
390
401
// Only inline impl if the implemented trait is
391
402
// reachable in rustdoc generated documentation
392
403
if !did. is_local ( ) {
393
404
if let Some ( traitref) = associated_trait {
394
- let did = traitref. def_id ;
395
- if !cx. cache . effective_visibilities . is_directly_public ( tcx, did) {
396
- return ;
397
- }
398
-
399
- if !document_compiler_internal && let Some ( stab) = tcx. lookup_stability ( did) && stab. is_unstable ( ) && stab. feature == sym:: rustc_private {
405
+ if !is_directly_public ( cx, traitref. def_id ) {
400
406
return ;
401
407
}
402
408
}
@@ -419,11 +425,7 @@ pub(crate) fn build_impl(
419
425
// reachable in rustdoc generated documentation
420
426
if !did. is_local ( ) {
421
427
if let Some ( did) = for_. def_id ( & cx. cache ) {
422
- if !cx. cache . effective_visibilities . is_directly_public ( tcx, did) {
423
- return ;
424
- }
425
-
426
- if !document_compiler_internal && let Some ( stab) = tcx. lookup_stability ( did) && stab. is_unstable ( ) && stab. feature == sym:: rustc_private {
428
+ if !is_directly_public ( cx, did) {
427
429
return ;
428
430
}
429
431
}
0 commit comments