@@ -278,6 +278,17 @@ fn build_impl(cx: &core::DocContext,
278
278
}
279
279
280
280
let associated_trait = csearch:: get_impl_trait ( tcx, did) ;
281
+ // If this is an impl for a #[doc(hidden)] trait, be sure to not inline it.
282
+ match associated_trait {
283
+ Some ( ref t) => {
284
+ let trait_attrs = load_attrs ( tcx, t. def_id ) ;
285
+ if trait_attrs. iter ( ) . any ( |a| is_doc_hidden ( a) ) {
286
+ return None
287
+ }
288
+ }
289
+ None => { }
290
+ }
291
+
281
292
let attrs = load_attrs ( tcx, did) ;
282
293
let ty = ty:: lookup_item_type ( tcx, did) ;
283
294
let methods = csearch:: get_impl_methods ( & tcx. sess . cstore ,
@@ -302,7 +313,7 @@ fn build_impl(cx: &core::DocContext,
302
313
} ;
303
314
Some ( item)
304
315
} ) . collect ( ) ;
305
- Some ( clean:: Item {
316
+ return Some ( clean:: Item {
306
317
inner : clean:: ImplItem ( clean:: Impl {
307
318
derived : clean:: detect_derived ( attrs. as_slice ( ) ) ,
308
319
trait_ : associated_trait. clean ( ) . map ( |bound| {
@@ -321,7 +332,21 @@ fn build_impl(cx: &core::DocContext,
321
332
visibility : Some ( ast:: Inherited ) ,
322
333
stability : stability:: lookup ( tcx, did) . clean ( ) ,
323
334
def_id : did,
324
- } )
335
+ } ) ;
336
+
337
+ fn is_doc_hidden ( a : & clean:: Attribute ) -> bool {
338
+ match * a {
339
+ clean:: List ( ref name, ref inner) if name. as_slice ( ) == "doc" => {
340
+ inner. iter ( ) . any ( |a| {
341
+ match * a {
342
+ clean:: Word ( ref s) => s. as_slice ( ) == "hidden" ,
343
+ _ => false ,
344
+ }
345
+ } )
346
+ }
347
+ _ => false
348
+ }
349
+ }
325
350
}
326
351
327
352
fn build_module ( cx : & core:: DocContext , tcx : & ty:: ctxt ,
0 commit comments