@@ -26,7 +26,7 @@ use rustc::middle::const_eval;
26
26
27
27
use core:: DocContext ;
28
28
use doctree;
29
- use clean;
29
+ use clean:: { self , Attributes } ;
30
30
31
31
use super :: { Clean , ToSource } ;
32
32
@@ -138,13 +138,10 @@ pub fn load_attrs(cx: &DocContext, tcx: &TyCtxt,
138
138
/// These names are used later on by HTML rendering to generate things like
139
139
/// source links back to the original item.
140
140
pub fn record_extern_fqn ( cx : & DocContext , did : DefId , kind : clean:: TypeKind ) {
141
- match cx. tcx_opt ( ) {
142
- Some ( tcx) => {
143
- let fqn = tcx. sess . cstore . extern_item_path ( did) ;
144
- let fqn = fqn. into_iter ( ) . map ( |i| i. to_string ( ) ) . collect ( ) ;
145
- cx. external_paths . borrow_mut ( ) . as_mut ( ) . unwrap ( ) . insert ( did, ( fqn, kind) ) ;
146
- }
147
- None => { }
141
+ if let Some ( tcx) = cx. tcx_opt ( ) {
142
+ let fqn = tcx. sess . cstore . extern_item_path ( did) ;
143
+ let fqn = fqn. into_iter ( ) . map ( |i| i. to_string ( ) ) . collect ( ) ;
144
+ cx. external_paths . borrow_mut ( ) . as_mut ( ) . unwrap ( ) . insert ( did, ( fqn, kind) ) ;
148
145
}
149
146
}
150
147
@@ -230,12 +227,9 @@ pub fn build_impls(cx: &DocContext, tcx: &TyCtxt,
230
227
tcx. populate_inherent_implementations_for_type_if_necessary ( did) ;
231
228
let mut impls = Vec :: new ( ) ;
232
229
233
- match tcx. inherent_impls . borrow ( ) . get ( & did) {
234
- None => { }
235
- Some ( i) => {
236
- for & did in i. iter ( ) {
237
- build_impl ( cx, tcx, did, & mut impls) ;
238
- }
230
+ if let Some ( i) = tcx. inherent_impls . borrow ( ) . get ( & did) {
231
+ for & did in i. iter ( ) {
232
+ build_impl ( cx, tcx, did, & mut impls) ;
239
233
}
240
234
}
241
235
@@ -259,7 +253,7 @@ pub fn build_impls(cx: &DocContext, tcx: &TyCtxt,
259
253
cstore:: DlImpl ( did) => build_impl ( cx, tcx, did, impls) ,
260
254
cstore:: DlDef ( Def :: Mod ( did) ) => {
261
255
// Don't recurse if this is a #[doc(hidden)] module
262
- if load_attrs ( cx, tcx, did) . iter ( ) . any ( |a| is_doc_hidden ( a ) ) {
256
+ if load_attrs ( cx, tcx, did) . list_def ( "doc" ) . has_word ( "hidden" ) {
263
257
return ;
264
258
}
265
259
@@ -288,7 +282,7 @@ pub fn build_impl(cx: &DocContext,
288
282
if let Some ( ref t) = associated_trait {
289
283
// If this is an impl for a #[doc(hidden)] trait, be sure to not inline
290
284
let trait_attrs = load_attrs ( cx, tcx, t. def_id ) ;
291
- if trait_attrs. iter ( ) . any ( |a| is_doc_hidden ( a ) ) {
285
+ if trait_attrs. list_def ( "doc" ) . has_word ( "hidden" ) {
292
286
return
293
287
}
294
288
}
@@ -428,20 +422,6 @@ pub fn build_impl(cx: &DocContext,
428
422
} ) ;
429
423
}
430
424
431
- fn is_doc_hidden ( a : & clean:: Attribute ) -> bool {
432
- match * a {
433
- clean:: List ( ref name, ref inner) if * name == "doc" => {
434
- inner. iter ( ) . any ( |a| {
435
- match * a {
436
- clean:: Word ( ref s) => * s == "hidden" ,
437
- _ => false ,
438
- }
439
- } )
440
- }
441
- _ => false
442
- }
443
- }
444
-
445
425
fn build_module ( cx : & DocContext , tcx : & TyCtxt ,
446
426
did : DefId ) -> clean:: Module {
447
427
let mut items = Vec :: new ( ) ;
@@ -464,9 +444,8 @@ fn build_module(cx: &DocContext, tcx: &TyCtxt,
464
444
}
465
445
cstore:: DlDef ( def) if item. vis == hir:: Public => {
466
446
if !visited. insert ( def) { continue }
467
- match try_inline_def ( cx, tcx, def) {
468
- Some ( i) => items. extend ( i) ,
469
- None => { }
447
+ if let Some ( i) = try_inline_def ( cx, tcx, def) {
448
+ items. extend ( i)
470
449
}
471
450
}
472
451
cstore:: DlDef ( ..) => { }
0 commit comments