@@ -129,7 +129,7 @@ pub fn record_extern_fqn(cx: &core::DocContext,
129
129
match cx. maybe_typed {
130
130
core:: Typed ( ref tcx) => {
131
131
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 ( ) ;
133
133
cx. external_paths . borrow_mut ( ) . get_mut_ref ( ) . insert ( did, ( fqn, kind) ) ;
134
134
}
135
135
core:: NotTyped ( ..) => { }
@@ -138,10 +138,18 @@ pub fn record_extern_fqn(cx: &core::DocContext,
138
138
139
139
pub fn build_external_trait ( tcx : & ty:: ctxt , did : ast:: DefId ) -> clean:: Trait {
140
140
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
+ } ) ;
142
150
clean:: Trait {
143
151
generics : def. generics . clean ( ) ,
144
- methods : methods. iter ( ) . map ( |i| i . clean ( ) ) . collect ( ) ,
152
+ methods : methods. collect ( ) ,
145
153
parents : Vec :: new ( ) , // FIXME: this is likely wrong
146
154
}
147
155
}
@@ -207,7 +215,7 @@ fn build_impls(cx: &core::DocContext,
207
215
match tcx. inherent_impls . borrow ( ) . find ( & did) {
208
216
None => { }
209
217
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) } ) ) ;
211
219
}
212
220
}
213
221
@@ -223,38 +231,47 @@ fn build_impls(cx: &core::DocContext,
223
231
csearch:: each_top_level_item_of_crate ( & tcx. sess . cstore ,
224
232
did. krate ,
225
233
|def, _, _| {
226
- populate_impls ( tcx, def, & mut impls)
234
+ populate_impls ( cx , tcx, def, & mut impls)
227
235
} ) ;
228
236
229
- fn populate_impls ( tcx : & ty:: ctxt ,
237
+ fn populate_impls ( cx : & core:: DocContext ,
238
+ tcx : & ty:: ctxt ,
230
239
def : decoder:: DefLike ,
231
- impls : & mut Vec < clean:: Item > ) {
240
+ impls : & mut Vec < Option < clean:: Item > > ) {
232
241
match def {
233
- decoder:: DlImpl ( did) => impls. push ( build_impl ( tcx, did) ) ,
242
+ decoder:: DlImpl ( did) => impls. push ( build_impl ( cx , tcx, did) ) ,
234
243
decoder:: DlDef ( ast:: DefMod ( did) ) => {
235
244
csearch:: each_child_of_item ( & tcx. sess . cstore ,
236
245
did,
237
246
|def, _, _| {
238
- populate_impls ( tcx, def, impls)
247
+ populate_impls ( cx , tcx, def, impls)
239
248
} )
240
249
}
241
250
_ => { }
242
251
}
243
252
}
244
253
}
245
254
246
- impls
255
+ impls. move_iter ( ) . filter_map ( |a| a ) . collect ( )
247
256
}
248
257
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
+
250
265
let associated_trait = csearch:: get_impl_trait ( tcx, did) ;
251
266
let attrs = load_attrs ( tcx, did) ;
252
267
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 ( ) ;
258
275
item. inner = match item. inner . clone ( ) {
259
276
clean:: TyMethodItem ( clean:: TyMethod {
260
277
fn_style, decl, self_, generics
@@ -268,9 +285,9 @@ fn build_impl(tcx: &ty::ctxt, did: ast::DefId) -> clean::Item {
268
285
}
269
286
_ => fail ! ( "not a tymethod" ) ,
270
287
} ;
271
- item
288
+ Some ( item)
272
289
} ) . collect ( ) ;
273
- clean:: Item {
290
+ Some ( clean:: Item {
274
291
inner : clean:: ImplItem ( clean:: Impl {
275
292
derived : clean:: detect_derived ( attrs. as_slice ( ) ) ,
276
293
trait_ : associated_trait. clean ( ) . map ( |bound| {
@@ -288,7 +305,7 @@ fn build_impl(tcx: &ty::ctxt, did: ast::DefId) -> clean::Item {
288
305
attrs : attrs,
289
306
visibility : Some ( ast:: Inherited ) ,
290
307
def_id : did,
291
- }
308
+ } )
292
309
}
293
310
294
311
fn build_module ( cx : & core:: DocContext , tcx : & ty:: ctxt ,
0 commit comments