@@ -13,6 +13,7 @@ use rustc_hir::def_id::DefId;
1313use rustc_hir:: Mutability ;
1414use rustc_metadata:: creader:: { CStore , LoadedMacro } ;
1515use rustc_middle:: ty:: { self , TyCtxt } ;
16+ use rustc_span:: def_id:: LOCAL_CRATE ;
1617use rustc_span:: hygiene:: MacroKind ;
1718use rustc_span:: symbol:: { kw, sym, Symbol } ;
1819
@@ -378,6 +379,14 @@ pub(crate) fn build_impl(
378379 let tcx = cx. tcx ;
379380 let associated_trait = tcx. impl_trait_ref ( did) ;
380381
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+
381390 // Only inline impl if the implemented trait is
382391 // reachable in rustdoc generated documentation
383392 if !did. is_local ( ) {
@@ -387,10 +396,8 @@ pub(crate) fn build_impl(
387396 return ;
388397 }
389398
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 ;
394401 }
395402 }
396403 }
@@ -416,10 +423,8 @@ pub(crate) fn build_impl(
416423 return ;
417424 }
418425
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 ;
423428 }
424429 }
425430 }
0 commit comments