@@ -49,7 +49,6 @@ use parking_lot::ReentrantMutex;
4949
5050use crate :: core:: { self , DocContext } ;
5151use crate :: doctree;
52- use crate :: visit_ast;
5352use crate :: html:: render:: { cache, ExternalLocation } ;
5453use crate :: html:: item_type:: ItemType ;
5554
@@ -138,10 +137,15 @@ pub struct Crate {
138137 pub masked_crates : FxHashSet < CrateNum > ,
139138}
140139
141- impl < ' a , ' tcx > Clean < Crate > for visit_ast:: RustdocVisitor < ' a , ' tcx > {
140+ impl Clean < Crate > for hir:: Crate {
141+ // note that self here is ignored in favor of `cx.tcx.hir().krate()` since
142+ // that gets around tying self's lifetime to the '_ in cx.
142143 fn clean ( & self , cx : & DocContext < ' _ > ) -> Crate {
143144 use crate :: visit_lib:: LibEmbargoVisitor ;
144145
146+ let v = crate :: visit_ast:: RustdocVisitor :: new ( & cx) ;
147+ let module = v. visit ( cx. tcx . hir ( ) . krate ( ) ) ;
148+
145149 {
146150 let mut r = cx. renderinfo . borrow_mut ( ) ;
147151 r. deref_trait_did = cx. tcx . lang_items ( ) . deref_trait ( ) ;
@@ -159,7 +163,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
159163
160164 // Clean the crate, translating the entire libsyntax AST to one that is
161165 // understood by rustdoc.
162- let mut module = self . module . as_ref ( ) . unwrap ( ) . clean ( cx) ;
166+ let mut module = module. clean ( cx) ;
163167 let mut masked_crates = FxHashSet :: default ( ) ;
164168
165169 match module. inner {
@@ -169,7 +173,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
169173 // `#[doc(masked)]` to the injected `extern crate` because it's unstable.
170174 if it. is_extern_crate ( )
171175 && ( it. attrs . has_doc_flag ( sym:: masked)
172- || self . cx . tcx . is_compiler_builtins ( it. def_id . krate ) )
176+ || cx. tcx . is_compiler_builtins ( it. def_id . krate ) )
173177 {
174178 masked_crates. insert ( it. def_id . krate ) ;
175179 }
@@ -652,9 +656,9 @@ impl Clean<Item> for doctree::Module<'_> {
652656 attrs,
653657 source : whence. clean ( cx) ,
654658 visibility : self . vis . clean ( cx) ,
655- stability : self . stab . clean ( cx) ,
656- deprecation : self . depr . clean ( cx) ,
657- def_id : cx. tcx . hir ( ) . local_def_id_from_node_id ( self . id ) ,
659+ stability : cx . stability ( self . id ) . clean ( cx) ,
660+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
661+ def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
658662 inner : ModuleItem ( Module {
659663 is_crate : self . is_crate ,
660664 items,
@@ -1938,8 +1942,8 @@ impl Clean<Item> for doctree::Function<'_> {
19381942 attrs : self . attrs . clean ( cx) ,
19391943 source : self . whence . clean ( cx) ,
19401944 visibility : self . vis . clean ( cx) ,
1941- stability : self . stab . clean ( cx) ,
1942- deprecation : self . depr . clean ( cx) ,
1945+ stability : cx . stability ( self . id ) . clean ( cx) ,
1946+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
19431947 def_id : did,
19441948 inner : FunctionItem ( Function {
19451949 decl,
@@ -2138,8 +2142,8 @@ impl Clean<Item> for doctree::Trait<'_> {
21382142 source : self . whence . clean ( cx) ,
21392143 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
21402144 visibility : self . vis . clean ( cx) ,
2141- stability : self . stab . clean ( cx) ,
2142- deprecation : self . depr . clean ( cx) ,
2145+ stability : cx . stability ( self . id ) . clean ( cx) ,
2146+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
21432147 inner : TraitItem ( Trait {
21442148 auto : self . is_auto . clean ( cx) ,
21452149 unsafety : self . unsafety ,
@@ -2168,8 +2172,8 @@ impl Clean<Item> for doctree::TraitAlias<'_> {
21682172 source : self . whence . clean ( cx) ,
21692173 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
21702174 visibility : self . vis . clean ( cx) ,
2171- stability : self . stab . clean ( cx) ,
2172- deprecation : self . depr . clean ( cx) ,
2175+ stability : cx . stability ( self . id ) . clean ( cx) ,
2176+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
21732177 inner : TraitAliasItem ( TraitAlias {
21742178 generics : self . generics . clean ( cx) ,
21752179 bounds : self . bounds . clean ( cx) ,
@@ -3242,8 +3246,8 @@ impl Clean<Item> for doctree::Struct<'_> {
32423246 source : self . whence . clean ( cx) ,
32433247 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
32443248 visibility : self . vis . clean ( cx) ,
3245- stability : self . stab . clean ( cx) ,
3246- deprecation : self . depr . clean ( cx) ,
3249+ stability : cx . stability ( self . id ) . clean ( cx) ,
3250+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
32473251 inner : StructItem ( Struct {
32483252 struct_type : self . struct_type ,
32493253 generics : self . generics . clean ( cx) ,
@@ -3262,8 +3266,8 @@ impl Clean<Item> for doctree::Union<'_> {
32623266 source : self . whence . clean ( cx) ,
32633267 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
32643268 visibility : self . vis . clean ( cx) ,
3265- stability : self . stab . clean ( cx) ,
3266- deprecation : self . depr . clean ( cx) ,
3269+ stability : cx . stability ( self . id ) . clean ( cx) ,
3270+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
32673271 inner : UnionItem ( Union {
32683272 struct_type : self . struct_type ,
32693273 generics : self . generics . clean ( cx) ,
@@ -3309,8 +3313,8 @@ impl Clean<Item> for doctree::Enum<'_> {
33093313 source : self . whence . clean ( cx) ,
33103314 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
33113315 visibility : self . vis . clean ( cx) ,
3312- stability : self . stab . clean ( cx) ,
3313- deprecation : self . depr . clean ( cx) ,
3316+ stability : cx . stability ( self . id ) . clean ( cx) ,
3317+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
33143318 inner : EnumItem ( Enum {
33153319 variants : self . variants . iter ( ) . map ( |v| v. clean ( cx) ) . collect ( ) ,
33163320 generics : self . generics . clean ( cx) ,
@@ -3332,8 +3336,8 @@ impl Clean<Item> for doctree::Variant<'_> {
33323336 attrs : self . attrs . clean ( cx) ,
33333337 source : self . whence . clean ( cx) ,
33343338 visibility : None ,
3335- stability : self . stab . clean ( cx) ,
3336- deprecation : self . depr . clean ( cx) ,
3339+ stability : cx . stability ( self . id ) . clean ( cx) ,
3340+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
33373341 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
33383342 inner : VariantItem ( Variant {
33393343 kind : self . def . clean ( cx) ,
@@ -3637,8 +3641,8 @@ impl Clean<Item> for doctree::Typedef<'_> {
36373641 source : self . whence . clean ( cx) ,
36383642 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
36393643 visibility : self . vis . clean ( cx) ,
3640- stability : self . stab . clean ( cx) ,
3641- deprecation : self . depr . clean ( cx) ,
3644+ stability : cx . stability ( self . id ) . clean ( cx) ,
3645+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
36423646 inner : TypedefItem ( Typedef {
36433647 type_ : self . ty . clean ( cx) ,
36443648 generics : self . gen . clean ( cx) ,
@@ -3661,8 +3665,8 @@ impl Clean<Item> for doctree::OpaqueTy<'_> {
36613665 source : self . whence . clean ( cx) ,
36623666 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
36633667 visibility : self . vis . clean ( cx) ,
3664- stability : self . stab . clean ( cx) ,
3665- deprecation : self . depr . clean ( cx) ,
3668+ stability : cx . stability ( self . id ) . clean ( cx) ,
3669+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
36663670 inner : OpaqueTyItem ( OpaqueTy {
36673671 bounds : self . opaque_ty . bounds . clean ( cx) ,
36683672 generics : self . opaque_ty . generics . clean ( cx) ,
@@ -3712,8 +3716,8 @@ impl Clean<Item> for doctree::Static<'_> {
37123716 source : self . whence . clean ( cx) ,
37133717 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
37143718 visibility : self . vis . clean ( cx) ,
3715- stability : self . stab . clean ( cx) ,
3716- deprecation : self . depr . clean ( cx) ,
3719+ stability : cx . stability ( self . id ) . clean ( cx) ,
3720+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
37173721 inner : StaticItem ( Static {
37183722 type_ : self . type_ . clean ( cx) ,
37193723 mutability : self . mutability . clean ( cx) ,
@@ -3737,8 +3741,8 @@ impl Clean<Item> for doctree::Constant<'_> {
37373741 source : self . whence . clean ( cx) ,
37383742 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
37393743 visibility : self . vis . clean ( cx) ,
3740- stability : self . stab . clean ( cx) ,
3741- deprecation : self . depr . clean ( cx) ,
3744+ stability : cx . stability ( self . id ) . clean ( cx) ,
3745+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
37423746 inner : ConstantItem ( Constant {
37433747 type_ : self . type_ . clean ( cx) ,
37443748 expr : print_const_expr ( cx, self . expr ) ,
@@ -3824,8 +3828,8 @@ impl Clean<Vec<Item>> for doctree::Impl<'_> {
38243828 source : self . whence . clean ( cx) ,
38253829 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
38263830 visibility : self . vis . clean ( cx) ,
3827- stability : self . stab . clean ( cx) ,
3828- deprecation : self . depr . clean ( cx) ,
3831+ stability : cx . stability ( self . id ) . clean ( cx) ,
3832+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
38293833 inner : ImplItem ( Impl {
38303834 unsafety : self . unsafety ,
38313835 generics : self . generics . clean ( cx) ,
@@ -4063,8 +4067,8 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
40634067 source : self . whence . clean ( cx) ,
40644068 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
40654069 visibility : self . vis . clean ( cx) ,
4066- stability : self . stab . clean ( cx) ,
4067- deprecation : self . depr . clean ( cx) ,
4070+ stability : cx . stability ( self . id ) . clean ( cx) ,
4071+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
40684072 inner,
40694073 }
40704074 }
@@ -4246,8 +4250,8 @@ impl Clean<Item> for doctree::Macro<'_> {
42464250 attrs : self . attrs . clean ( cx) ,
42474251 source : self . whence . clean ( cx) ,
42484252 visibility : Some ( Public ) ,
4249- stability : self . stab . clean ( cx) ,
4250- deprecation : self . depr . clean ( cx) ,
4253+ stability : cx . stability ( self . hid ) . clean ( cx) ,
4254+ deprecation : cx . deprecation ( self . hid ) . clean ( cx) ,
42514255 def_id : self . def_id ,
42524256 inner : MacroItem ( Macro {
42534257 source : format ! ( "macro_rules! {} {{\n {}}}" ,
@@ -4274,8 +4278,8 @@ impl Clean<Item> for doctree::ProcMacro<'_> {
42744278 attrs : self . attrs . clean ( cx) ,
42754279 source : self . whence . clean ( cx) ,
42764280 visibility : Some ( Public ) ,
4277- stability : self . stab . clean ( cx) ,
4278- deprecation : self . depr . clean ( cx) ,
4281+ stability : cx . stability ( self . id ) . clean ( cx) ,
4282+ deprecation : cx . deprecation ( self . id ) . clean ( cx) ,
42794283 def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
42804284 inner : ProcMacroItem ( ProcMacro {
42814285 kind : self . kind ,
0 commit comments