@@ -129,7 +129,7 @@ pub fn record_extern_fqn(cx: &core::DocContext,
129129 match cx. maybe_typed {
130130 core:: Typed ( ref tcx) => {
131131 let fqn = csearch:: get_item_path ( tcx, did) ;
132- let fqn = fqn. move_iter ( ) . map ( |i| i. to_str ( ) . to_string ( ) ) . collect ( ) ;
132+ let fqn = fqn. move_iter ( ) . map ( |i| i. to_str ( ) ) . collect ( ) ;
133133 cx. external_paths . borrow_mut ( ) . get_mut_ref ( ) . insert ( did, ( fqn, kind) ) ;
134134 }
135135 core:: NotTyped ( ..) => { }
@@ -138,10 +138,18 @@ pub fn record_extern_fqn(cx: &core::DocContext,
138138
139139pub fn build_external_trait ( tcx : & ty:: ctxt , did : ast:: DefId ) -> clean:: Trait {
140140 let def = ty:: lookup_trait_def ( tcx, did) ;
141- let methods = ty:: trait_methods ( tcx, did) ;
141+ let methods = ty:: trait_methods ( tcx, did) . clean ( ) ;
142+ let provided = ty:: provided_trait_methods ( tcx, did) ;
143+ let mut methods = methods. move_iter ( ) . map ( |meth| {
144+ if provided. iter ( ) . any ( |a| a. def_id == meth. def_id ) {
145+ clean:: Provided ( meth)
146+ } else {
147+ clean:: Required ( meth)
148+ }
149+ } ) ;
142150 clean:: Trait {
143151 generics : def. generics . clean ( ) ,
144- methods : methods. iter ( ) . map ( |i| i . clean ( ) ) . collect ( ) ,
152+ methods : methods. collect ( ) ,
145153 parents : Vec :: new ( ) , // FIXME: this is likely wrong
146154 }
147155}
@@ -207,7 +215,7 @@ fn build_impls(cx: &core::DocContext,
207215 match tcx. inherent_impls . borrow ( ) . find ( & did) {
208216 None => { }
209217 Some ( i) => {
210- impls. extend ( i. borrow ( ) . iter ( ) . map ( |& did| { build_impl ( tcx, did) } ) ) ;
218+ impls. extend ( i. borrow ( ) . iter ( ) . map ( |& did| { build_impl ( cx , tcx, did) } ) ) ;
211219 }
212220 }
213221
@@ -223,38 +231,47 @@ fn build_impls(cx: &core::DocContext,
223231 csearch:: each_top_level_item_of_crate ( & tcx. sess . cstore ,
224232 did. krate ,
225233 |def, _, _| {
226- populate_impls ( tcx, def, & mut impls)
234+ populate_impls ( cx , tcx, def, & mut impls)
227235 } ) ;
228236
229- fn populate_impls ( tcx : & ty:: ctxt ,
237+ fn populate_impls ( cx : & core:: DocContext ,
238+ tcx : & ty:: ctxt ,
230239 def : decoder:: DefLike ,
231- impls : & mut Vec < clean:: Item > ) {
240+ impls : & mut Vec < Option < clean:: Item > > ) {
232241 match def {
233- decoder:: DlImpl ( did) => impls. push ( build_impl ( tcx, did) ) ,
242+ decoder:: DlImpl ( did) => impls. push ( build_impl ( cx , tcx, did) ) ,
234243 decoder:: DlDef ( ast:: DefMod ( did) ) => {
235244 csearch:: each_child_of_item ( & tcx. sess . cstore ,
236245 did,
237246 |def, _, _| {
238- populate_impls ( tcx, def, impls)
247+ populate_impls ( cx , tcx, def, impls)
239248 } )
240249 }
241250 _ => { }
242251 }
243252 }
244253 }
245254
246- impls
255+ impls. move_iter ( ) . filter_map ( |a| a ) . collect ( )
247256}
248257
249- fn build_impl ( tcx : & ty:: ctxt , did : ast:: DefId ) -> clean:: Item {
258+ fn build_impl ( cx : & core:: DocContext ,
259+ tcx : & ty:: ctxt ,
260+ did : ast:: DefId ) -> Option < clean:: Item > {
261+ if !cx. inlined . borrow_mut ( ) . get_mut_ref ( ) . insert ( did) {
262+ return None
263+ }
264+
250265 let associated_trait = csearch:: get_impl_trait ( tcx, did) ;
251266 let attrs = load_attrs ( tcx, did) ;
252267 let ty = ty:: lookup_item_type ( tcx, did) ;
253- let methods = csearch:: get_impl_methods ( & tcx. sess . cstore , did) . iter ( ) . map ( |did| {
254- let mut item = match ty:: method ( tcx, * did) . clean ( ) {
255- clean:: Provided ( item) => item,
256- clean:: Required ( item) => item,
257- } ;
268+ let methods = csearch:: get_impl_methods ( & tcx. sess . cstore ,
269+ did) . iter ( ) . filter_map ( |did| {
270+ let method = ty:: method ( tcx, * did) ;
271+ if method. vis != ast:: Public && associated_trait. is_none ( ) {
272+ return None
273+ }
274+ let mut item = ty:: method ( tcx, * did) . clean ( ) ;
258275 item. inner = match item. inner . clone ( ) {
259276 clean:: TyMethodItem ( clean:: TyMethod {
260277 fn_style, decl, self_, generics
@@ -268,9 +285,9 @@ fn build_impl(tcx: &ty::ctxt, did: ast::DefId) -> clean::Item {
268285 }
269286 _ => fail ! ( "not a tymethod" ) ,
270287 } ;
271- item
288+ Some ( item)
272289 } ) . collect ( ) ;
273- clean:: Item {
290+ Some ( clean:: Item {
274291 inner : clean:: ImplItem ( clean:: Impl {
275292 derived : clean:: detect_derived ( attrs. as_slice ( ) ) ,
276293 trait_ : associated_trait. clean ( ) . map ( |bound| {
@@ -288,7 +305,7 @@ fn build_impl(tcx: &ty::ctxt, did: ast::DefId) -> clean::Item {
288305 attrs : attrs,
289306 visibility : Some ( ast:: Inherited ) ,
290307 def_id : did,
291- }
308+ } )
292309}
293310
294311fn build_module ( cx : & core:: DocContext , tcx : & ty:: ctxt ,
0 commit comments