@@ -136,94 +136,88 @@ pub struct Crate {
136
136
pub collapsed : bool ,
137
137
}
138
138
139
- impl Clean < Crate > for hir:: Crate {
140
- // note that self here is ignored in favor of `cx.tcx.hir().krate()` since
141
- // that gets around tying self's lifetime to the '_ in cx.
142
- fn clean ( & self , cx : & DocContext < ' _ > ) -> Crate {
143
- use crate :: visit_lib:: LibEmbargoVisitor ;
144
-
145
- let v = crate :: visit_ast:: RustdocVisitor :: new ( & cx) ;
146
- let module = v. visit ( cx. tcx . hir ( ) . krate ( ) ) ;
147
-
148
- {
149
- let mut r = cx. renderinfo . borrow_mut ( ) ;
150
- r. deref_trait_did = cx. tcx . lang_items ( ) . deref_trait ( ) ;
151
- r. deref_mut_trait_did = cx. tcx . lang_items ( ) . deref_mut_trait ( ) ;
152
- r. owned_box_did = cx. tcx . lang_items ( ) . owned_box ( ) ;
153
- }
154
-
155
- let mut externs = Vec :: new ( ) ;
156
- for & cnum in cx. tcx . crates ( ) . iter ( ) {
157
- externs. push ( ( cnum, cnum. clean ( cx) ) ) ;
158
- // Analyze doc-reachability for extern items
159
- LibEmbargoVisitor :: new ( cx) . visit_lib ( cnum) ;
160
- }
161
- externs. sort_by ( |& ( a, _) , & ( b, _) | a. cmp ( & b) ) ;
162
-
163
- // Clean the crate, translating the entire libsyntax AST to one that is
164
- // understood by rustdoc.
165
- let mut module = module. clean ( cx) ;
166
- let mut masked_crates = FxHashSet :: default ( ) ;
167
-
168
- match module. inner {
169
- ModuleItem ( ref module) => {
170
- for it in & module. items {
171
- // `compiler_builtins` should be masked too, but we can't apply
172
- // `#[doc(masked)]` to the injected `extern crate` because it's unstable.
173
- if it. is_extern_crate ( )
174
- && ( it. attrs . has_doc_flag ( sym:: masked)
175
- || cx. tcx . is_compiler_builtins ( it. def_id . krate ) )
176
- {
177
- masked_crates. insert ( it. def_id . krate ) ;
178
- }
139
+ pub fn krate ( mut cx : & mut DocContext < ' _ > ) -> Crate {
140
+ use crate :: visit_lib:: LibEmbargoVisitor ;
141
+
142
+ let krate = cx. tcx . hir ( ) . krate ( ) ;
143
+ let module = crate :: visit_ast:: RustdocVisitor :: new ( & mut cx) . visit ( krate) ;
144
+
145
+ let mut r = cx. renderinfo . get_mut ( ) ;
146
+ r. deref_trait_did = cx. tcx . lang_items ( ) . deref_trait ( ) ;
147
+ r. deref_mut_trait_did = cx. tcx . lang_items ( ) . deref_mut_trait ( ) ;
148
+ r. owned_box_did = cx. tcx . lang_items ( ) . owned_box ( ) ;
149
+
150
+ let mut externs = Vec :: new ( ) ;
151
+ for & cnum in cx. tcx . crates ( ) . iter ( ) {
152
+ externs. push ( ( cnum, cnum. clean ( cx) ) ) ;
153
+ // Analyze doc-reachability for extern items
154
+ LibEmbargoVisitor :: new ( & mut cx) . visit_lib ( cnum) ;
155
+ }
156
+ externs. sort_by ( |& ( a, _) , & ( b, _) | a. cmp ( & b) ) ;
157
+
158
+ // Clean the crate, translating the entire libsyntax AST to one that is
159
+ // understood by rustdoc.
160
+ let mut module = module. clean ( cx) ;
161
+ let mut masked_crates = FxHashSet :: default ( ) ;
162
+
163
+ match module. inner {
164
+ ModuleItem ( ref module) => {
165
+ for it in & module. items {
166
+ // `compiler_builtins` should be masked too, but we can't apply
167
+ // `#[doc(masked)]` to the injected `extern crate` because it's unstable.
168
+ if it. is_extern_crate ( )
169
+ && ( it. attrs . has_doc_flag ( sym:: masked)
170
+ || cx. tcx . is_compiler_builtins ( it. def_id . krate ) )
171
+ {
172
+ masked_crates. insert ( it. def_id . krate ) ;
179
173
}
180
174
}
181
- _ => unreachable ! ( ) ,
182
175
}
176
+ _ => unreachable ! ( ) ,
177
+ }
183
178
184
- let ExternalCrate { name, src, primitives, keywords, .. } = LOCAL_CRATE . clean ( cx) ;
185
- {
186
- let m = match module. inner {
187
- ModuleItem ( ref mut m) => m,
188
- _ => unreachable ! ( ) ,
189
- } ;
190
- m. items . extend ( primitives. iter ( ) . map ( |& ( def_id, prim, ref attrs) | {
191
- Item {
192
- source : Span :: empty ( ) ,
193
- name : Some ( prim. to_url_str ( ) . to_string ( ) ) ,
194
- attrs : attrs. clone ( ) ,
195
- visibility : Some ( Public ) ,
196
- stability : get_stability ( cx, def_id) ,
197
- deprecation : get_deprecation ( cx, def_id) ,
198
- def_id,
199
- inner : PrimitiveItem ( prim) ,
200
- }
201
- } ) ) ;
202
- m. items . extend ( keywords. into_iter ( ) . map ( |( def_id, kw, attrs) | {
203
- Item {
204
- source : Span :: empty ( ) ,
205
- name : Some ( kw. clone ( ) ) ,
206
- attrs : attrs,
207
- visibility : Some ( Public ) ,
208
- stability : get_stability ( cx, def_id) ,
209
- deprecation : get_deprecation ( cx, def_id) ,
210
- def_id,
211
- inner : KeywordItem ( kw) ,
212
- }
213
- } ) ) ;
214
- }
179
+ let ExternalCrate { name, src, primitives, keywords, .. } = LOCAL_CRATE . clean ( cx) ;
180
+ {
181
+ let m = match module. inner {
182
+ ModuleItem ( ref mut m) => m,
183
+ _ => unreachable ! ( ) ,
184
+ } ;
185
+ m. items . extend ( primitives. iter ( ) . map ( |& ( def_id, prim, ref attrs) | {
186
+ Item {
187
+ source : Span :: empty ( ) ,
188
+ name : Some ( prim. to_url_str ( ) . to_string ( ) ) ,
189
+ attrs : attrs. clone ( ) ,
190
+ visibility : Some ( Public ) ,
191
+ stability : get_stability ( cx, def_id) ,
192
+ deprecation : get_deprecation ( cx, def_id) ,
193
+ def_id,
194
+ inner : PrimitiveItem ( prim) ,
195
+ }
196
+ } ) ) ;
197
+ m. items . extend ( keywords. into_iter ( ) . map ( |( def_id, kw, attrs) | {
198
+ Item {
199
+ source : Span :: empty ( ) ,
200
+ name : Some ( kw. clone ( ) ) ,
201
+ attrs : attrs,
202
+ visibility : Some ( Public ) ,
203
+ stability : get_stability ( cx, def_id) ,
204
+ deprecation : get_deprecation ( cx, def_id) ,
205
+ def_id,
206
+ inner : KeywordItem ( kw) ,
207
+ }
208
+ } ) ) ;
209
+ }
215
210
216
- Crate {
217
- name,
218
- version : None ,
219
- src,
220
- module : Some ( module) ,
221
- externs,
222
- primitives,
223
- external_traits : cx. external_traits . clone ( ) ,
224
- masked_crates,
225
- collapsed : false ,
226
- }
211
+ Crate {
212
+ name,
213
+ version : None ,
214
+ src,
215
+ module : Some ( module) ,
216
+ externs,
217
+ primitives,
218
+ external_traits : cx. external_traits . clone ( ) ,
219
+ masked_crates,
220
+ collapsed : false ,
227
221
}
228
222
}
229
223
@@ -572,23 +566,6 @@ pub enum ItemEnum {
572
566
}
573
567
574
568
impl ItemEnum {
575
- pub fn generics ( & self ) -> Option < & Generics > {
576
- Some ( match * self {
577
- ItemEnum :: StructItem ( ref s) => & s. generics ,
578
- ItemEnum :: EnumItem ( ref e) => & e. generics ,
579
- ItemEnum :: FunctionItem ( ref f) => & f. generics ,
580
- ItemEnum :: TypedefItem ( ref t, _) => & t. generics ,
581
- ItemEnum :: OpaqueTyItem ( ref t, _) => & t. generics ,
582
- ItemEnum :: TraitItem ( ref t) => & t. generics ,
583
- ItemEnum :: ImplItem ( ref i) => & i. generics ,
584
- ItemEnum :: TyMethodItem ( ref i) => & i. generics ,
585
- ItemEnum :: MethodItem ( ref i) => & i. generics ,
586
- ItemEnum :: ForeignFunctionItem ( ref f) => & f. generics ,
587
- ItemEnum :: TraitAliasItem ( ref ta) => & ta. generics ,
588
- _ => return None ,
589
- } )
590
- }
591
-
592
569
pub fn is_associated ( & self ) -> bool {
593
570
match * self {
594
571
ItemEnum :: TypedefItem ( _, _) |
@@ -1541,8 +1518,6 @@ impl Clean<GenericParamDef> for ty::GenericParamDef {
1541
1518
( self . name . to_string ( ) , GenericParamDefKind :: Lifetime )
1542
1519
}
1543
1520
ty:: GenericParamDefKind :: Type { has_default, synthetic, .. } => {
1544
- cx. renderinfo . borrow_mut ( ) . external_param_names
1545
- . insert ( self . def_id , self . name . clean ( cx) ) ;
1546
1521
let default = if has_default {
1547
1522
Some ( cx. tcx . type_of ( self . def_id ) . clean ( cx) )
1548
1523
} else {
0 commit comments