@@ -49,7 +49,6 @@ use parking_lot::ReentrantMutex;
49
49
50
50
use crate :: core:: { self , DocContext } ;
51
51
use crate :: doctree;
52
- use crate :: visit_ast;
53
52
use crate :: html:: render:: { cache, ExternalLocation } ;
54
53
use crate :: html:: item_type:: ItemType ;
55
54
@@ -138,10 +137,15 @@ pub struct Crate {
138
137
pub masked_crates : FxHashSet < CrateNum > ,
139
138
}
140
139
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.
142
143
fn clean ( & self , cx : & DocContext < ' _ > ) -> Crate {
143
144
use crate :: visit_lib:: LibEmbargoVisitor ;
144
145
146
+ let v = crate :: visit_ast:: RustdocVisitor :: new ( & cx) ;
147
+ let module = v. visit ( cx. tcx . hir ( ) . krate ( ) ) ;
148
+
145
149
{
146
150
let mut r = cx. renderinfo . borrow_mut ( ) ;
147
151
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> {
159
163
160
164
// Clean the crate, translating the entire libsyntax AST to one that is
161
165
// understood by rustdoc.
162
- let mut module = self . module . as_ref ( ) . unwrap ( ) . clean ( cx) ;
166
+ let mut module = module. clean ( cx) ;
163
167
let mut masked_crates = FxHashSet :: default ( ) ;
164
168
165
169
match module. inner {
@@ -169,7 +173,7 @@ impl<'a, 'tcx> Clean<Crate> for visit_ast::RustdocVisitor<'a, 'tcx> {
169
173
// `#[doc(masked)]` to the injected `extern crate` because it's unstable.
170
174
if it. is_extern_crate ( )
171
175
&& ( 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 ) )
173
177
{
174
178
masked_crates. insert ( it. def_id . krate ) ;
175
179
}
@@ -652,9 +656,9 @@ impl Clean<Item> for doctree::Module<'_> {
652
656
attrs,
653
657
source : whence. clean ( cx) ,
654
658
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 ) ,
658
662
inner : ModuleItem ( Module {
659
663
is_crate : self . is_crate ,
660
664
items,
@@ -1938,8 +1942,8 @@ impl Clean<Item> for doctree::Function<'_> {
1938
1942
attrs : self . attrs . clean ( cx) ,
1939
1943
source : self . whence . clean ( cx) ,
1940
1944
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) ,
1943
1947
def_id : did,
1944
1948
inner : FunctionItem ( Function {
1945
1949
decl,
@@ -2138,8 +2142,8 @@ impl Clean<Item> for doctree::Trait<'_> {
2138
2142
source : self . whence . clean ( cx) ,
2139
2143
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
2140
2144
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) ,
2143
2147
inner : TraitItem ( Trait {
2144
2148
auto : self . is_auto . clean ( cx) ,
2145
2149
unsafety : self . unsafety ,
@@ -2168,8 +2172,8 @@ impl Clean<Item> for doctree::TraitAlias<'_> {
2168
2172
source : self . whence . clean ( cx) ,
2169
2173
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
2170
2174
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) ,
2173
2177
inner : TraitAliasItem ( TraitAlias {
2174
2178
generics : self . generics . clean ( cx) ,
2175
2179
bounds : self . bounds . clean ( cx) ,
@@ -3242,8 +3246,8 @@ impl Clean<Item> for doctree::Struct<'_> {
3242
3246
source : self . whence . clean ( cx) ,
3243
3247
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
3244
3248
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) ,
3247
3251
inner : StructItem ( Struct {
3248
3252
struct_type : self . struct_type ,
3249
3253
generics : self . generics . clean ( cx) ,
@@ -3262,8 +3266,8 @@ impl Clean<Item> for doctree::Union<'_> {
3262
3266
source : self . whence . clean ( cx) ,
3263
3267
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
3264
3268
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) ,
3267
3271
inner : UnionItem ( Union {
3268
3272
struct_type : self . struct_type ,
3269
3273
generics : self . generics . clean ( cx) ,
@@ -3309,8 +3313,8 @@ impl Clean<Item> for doctree::Enum<'_> {
3309
3313
source : self . whence . clean ( cx) ,
3310
3314
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
3311
3315
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) ,
3314
3318
inner : EnumItem ( Enum {
3315
3319
variants : self . variants . iter ( ) . map ( |v| v. clean ( cx) ) . collect ( ) ,
3316
3320
generics : self . generics . clean ( cx) ,
@@ -3332,8 +3336,8 @@ impl Clean<Item> for doctree::Variant<'_> {
3332
3336
attrs : self . attrs . clean ( cx) ,
3333
3337
source : self . whence . clean ( cx) ,
3334
3338
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) ,
3337
3341
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
3338
3342
inner : VariantItem ( Variant {
3339
3343
kind : self . def . clean ( cx) ,
@@ -3637,8 +3641,8 @@ impl Clean<Item> for doctree::Typedef<'_> {
3637
3641
source : self . whence . clean ( cx) ,
3638
3642
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
3639
3643
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) ,
3642
3646
inner : TypedefItem ( Typedef {
3643
3647
type_ : self . ty . clean ( cx) ,
3644
3648
generics : self . gen . clean ( cx) ,
@@ -3661,8 +3665,8 @@ impl Clean<Item> for doctree::OpaqueTy<'_> {
3661
3665
source : self . whence . clean ( cx) ,
3662
3666
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
3663
3667
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) ,
3666
3670
inner : OpaqueTyItem ( OpaqueTy {
3667
3671
bounds : self . opaque_ty . bounds . clean ( cx) ,
3668
3672
generics : self . opaque_ty . generics . clean ( cx) ,
@@ -3712,8 +3716,8 @@ impl Clean<Item> for doctree::Static<'_> {
3712
3716
source : self . whence . clean ( cx) ,
3713
3717
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
3714
3718
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) ,
3717
3721
inner : StaticItem ( Static {
3718
3722
type_ : self . type_ . clean ( cx) ,
3719
3723
mutability : self . mutability . clean ( cx) ,
@@ -3737,8 +3741,8 @@ impl Clean<Item> for doctree::Constant<'_> {
3737
3741
source : self . whence . clean ( cx) ,
3738
3742
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
3739
3743
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) ,
3742
3746
inner : ConstantItem ( Constant {
3743
3747
type_ : self . type_ . clean ( cx) ,
3744
3748
expr : print_const_expr ( cx, self . expr ) ,
@@ -3824,8 +3828,8 @@ impl Clean<Vec<Item>> for doctree::Impl<'_> {
3824
3828
source : self . whence . clean ( cx) ,
3825
3829
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
3826
3830
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) ,
3829
3833
inner : ImplItem ( Impl {
3830
3834
unsafety : self . unsafety ,
3831
3835
generics : self . generics . clean ( cx) ,
@@ -4063,8 +4067,8 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
4063
4067
source : self . whence . clean ( cx) ,
4064
4068
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
4065
4069
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) ,
4068
4072
inner,
4069
4073
}
4070
4074
}
@@ -4246,8 +4250,8 @@ impl Clean<Item> for doctree::Macro<'_> {
4246
4250
attrs : self . attrs . clean ( cx) ,
4247
4251
source : self . whence . clean ( cx) ,
4248
4252
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) ,
4251
4255
def_id : self . def_id ,
4252
4256
inner : MacroItem ( Macro {
4253
4257
source : format ! ( "macro_rules! {} {{\n {}}}" ,
@@ -4274,8 +4278,8 @@ impl Clean<Item> for doctree::ProcMacro<'_> {
4274
4278
attrs : self . attrs . clean ( cx) ,
4275
4279
source : self . whence . clean ( cx) ,
4276
4280
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) ,
4279
4283
def_id : cx. tcx . hir ( ) . local_def_id ( self . id ) ,
4280
4284
inner : ProcMacroItem ( ProcMacro {
4281
4285
kind : self . kind ,
0 commit comments