@@ -374,50 +374,90 @@ fn encode_path(ecx: @EncodeContext,
374
374
fn encode_reexported_static_method ( ecx : @EncodeContext ,
375
375
ebml_w : & mut writer:: Encoder ,
376
376
exp : & middle:: resolve:: Export2 ,
377
- m : @ty:: Method ) {
378
- debug ! ( "(encode static trait method) reexport '%s::%s'" ,
379
- * exp. name, * ecx. tcx. sess. str_of( m. ident) ) ;
377
+ method_def_id : def_id ,
378
+ method_ident : ident ) {
379
+ debug ! ( "(encode reexported static method) %s::%s" ,
380
+ * exp. name, * ecx. tcx. sess. str_of( method_ident) ) ;
380
381
ebml_w. start_tag ( tag_items_data_item_reexport) ;
381
382
ebml_w. start_tag ( tag_items_data_item_reexport_def_id) ;
382
- ebml_w. wr_str ( def_to_str ( m . def_id ) ) ;
383
+ ebml_w. wr_str ( def_to_str ( method_def_id ) ) ;
383
384
ebml_w. end_tag ( ) ;
384
385
ebml_w. start_tag ( tag_items_data_item_reexport_name) ;
385
- ebml_w. wr_str ( * exp. name + "::" + * ecx. tcx . sess . str_of ( m . ident ) ) ;
386
+ ebml_w. wr_str ( * exp. name + "::" + * ecx. tcx . sess . str_of ( method_ident ) ) ;
386
387
ebml_w. end_tag ( ) ;
387
388
ebml_w. end_tag ( ) ;
388
389
}
389
390
391
+ fn encode_reexported_static_base_methods ( ecx : @EncodeContext ,
392
+ ebml_w : & mut writer:: Encoder ,
393
+ exp : & middle:: resolve:: Export2 )
394
+ -> bool {
395
+ match ecx. tcx . base_impls . find ( & exp. def_id ) {
396
+ Some ( implementations) => {
397
+ for implementations. each |& base_impl| {
398
+ for base_impl. methods. each |& m| {
399
+ if m. explicit_self == ast:: sty_static {
400
+ encode_reexported_static_method ( ecx, ebml_w, exp,
401
+ m. did , m. ident ) ;
402
+ }
403
+ }
404
+ }
405
+
406
+ true
407
+ }
408
+ None => { false }
409
+ }
410
+ }
411
+
412
+ fn encode_reexported_static_trait_methods ( ecx : @EncodeContext ,
413
+ ebml_w : & mut writer:: Encoder ,
414
+ exp : & middle:: resolve:: Export2 )
415
+ -> bool {
416
+ match ecx. tcx . trait_methods_cache . find ( & exp. def_id ) {
417
+ Some ( methods) => {
418
+ for methods. each |& m| {
419
+ if m. explicit_self == ast:: sty_static {
420
+ encode_reexported_static_method ( ecx, ebml_w, exp,
421
+ m. def_id , m. ident ) ;
422
+ }
423
+ }
424
+
425
+ true
426
+ }
427
+ None => { false }
428
+ }
429
+ }
430
+
390
431
fn encode_reexported_static_methods ( ecx : @EncodeContext ,
391
432
ebml_w : & mut writer:: Encoder ,
392
433
mod_path : & [ ast_map:: path_elt ] ,
393
434
exp : & middle:: resolve:: Export2 ) {
394
- match ecx. tcx . trait_methods_cache . find ( & exp. def_id ) {
395
- Some ( methods) => {
396
- match ecx. tcx . items . find ( & exp. def_id . node ) {
397
- Some ( & ast_map:: node_item( item, path) ) => {
398
- let original_name = ecx. tcx . sess . str_of ( item. ident ) ;
399
-
400
- //
401
- // We don't need to reexport static methods on traits
402
- // declared in the same module as our `pub use ...` since
403
- // that's done when we encode the trait item.
404
- //
405
- // The only exception is when the reexport *changes* the
406
- // name e.g. `pub use Foo = self::Bar` -- we have
407
- // encoded metadata for static methods relative to Bar,
408
- // but not yet for Foo.
409
- //
410
- if mod_path != * path || * exp. name != * original_name {
411
- for methods. each |& m| {
412
- if m. explicit_self == ast:: sty_static {
413
- encode_reexported_static_method ( ecx,
414
- ebml_w,
415
- exp, m) ;
416
- }
417
- }
435
+ match ecx. tcx . items . find ( & exp. def_id . node ) {
436
+ Some ( & ast_map:: node_item( item, path) ) => {
437
+ let original_name = ecx. tcx . sess . str_of ( item. ident ) ;
438
+
439
+ //
440
+ // We don't need to reexport static methods on items
441
+ // declared in the same module as our `pub use ...` since
442
+ // that's done when we encode the item itself.
443
+ //
444
+ // The only exception is when the reexport *changes* the
445
+ // name e.g. `pub use Foo = self::Bar` -- we have
446
+ // encoded metadata for static methods relative to Bar,
447
+ // but not yet for Foo.
448
+ //
449
+ if mod_path != * path || * exp. name != * original_name {
450
+ if !encode_reexported_static_base_methods ( ecx, ebml_w, exp) {
451
+ if encode_reexported_static_trait_methods ( ecx, ebml_w, exp) {
452
+ debug ! ( fmt!( "(encode reexported static methods) %s \
453
+ [trait]",
454
+ * original_name) ) ;
418
455
}
419
456
}
420
- _ => { }
457
+ else {
458
+ debug ! ( fmt!( "(encode reexported static methods) %s [base]" ,
459
+ * original_name) ) ;
460
+ }
421
461
}
422
462
}
423
463
_ => { }
0 commit comments