@@ -49,8 +49,6 @@ use syntax::diagnostic::span_handler;
49
49
use syntax:: parse:: token:: special_idents;
50
50
use syntax:: print:: pprust;
51
51
use syntax:: { ast_util, visit} ;
52
- use syntax:: opt_vec:: OptVec ;
53
- use syntax:: opt_vec;
54
52
use syntax;
55
53
use writer = std:: ebml:: writer;
56
54
@@ -189,11 +187,10 @@ fn encode_ty_type_param_bounds(ebml_w: writer::Encoder, ecx: @EncodeContext,
189
187
}
190
188
}
191
189
192
- fn encode_type_param_bounds ( ebml_w : writer:: Encoder ,
193
- ecx : @EncodeContext ,
194
- params : & OptVec < TyParam > ) {
190
+ fn encode_type_param_bounds ( ebml_w : writer:: Encoder , ecx : @EncodeContext ,
191
+ params : & [ ty_param ] ) {
195
192
let ty_param_bounds =
196
- @params. map_to_vec ( |param| ecx. tcx . ty_param_bounds . get ( & param. id ) ) ;
193
+ @params. map ( |param| ecx. tcx . ty_param_bounds . get ( & param. id ) ) ;
197
194
encode_ty_type_param_bounds ( ebml_w, ecx, ty_param_bounds) ;
198
195
}
199
196
@@ -268,7 +265,7 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: writer::Encoder,
268
265
id : node_id , variants : & [ variant ] ,
269
266
path : & [ ast_map:: path_elt ] ,
270
267
index : @mut ~[ entry < int > ] ,
271
- generics : & ast :: Generics ) {
268
+ ty_params : & [ ty_param ] ) {
272
269
let mut disr_val = 0 ;
273
270
let mut i = 0 ;
274
271
let vi = ty:: enum_variants ( ecx. tcx ,
@@ -284,7 +281,7 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: writer::Encoder,
284
281
node_id_to_type ( ecx. tcx , variant. node . id ) ) ;
285
282
match variant. node . kind {
286
283
ast:: tuple_variant_kind( ref args)
287
- if args. len ( ) > 0 && generics . ty_params . len ( ) == 0 => {
284
+ if args. len ( ) > 0 && ty_params. len ( ) == 0 => {
288
285
encode_symbol ( ecx, ebml_w, variant. node . id ) ;
289
286
}
290
287
ast:: tuple_variant_kind( _) | ast:: struct_variant_kind( _) |
@@ -295,7 +292,7 @@ fn encode_enum_variant_info(ecx: @EncodeContext, ebml_w: writer::Encoder,
295
292
encode_disr_val ( ecx, ebml_w, vi[ i] . disr_val ) ;
296
293
disr_val = vi[ i] . disr_val ;
297
294
}
298
- encode_type_param_bounds ( ebml_w, ecx, & generics . ty_params ) ;
295
+ encode_type_param_bounds ( ebml_w, ecx, ty_params) ;
299
296
encode_path ( ecx, ebml_w, path,
300
297
ast_map:: path_name ( variant. node . name ) ) ;
301
298
ebml_w. end_tag ( ) ;
@@ -468,18 +465,14 @@ fn encode_info_for_struct(ecx: @EncodeContext, ebml_w: writer::Encoder,
468
465
}
469
466
470
467
// This is for encoding info for ctors and dtors
471
- fn encode_info_for_ctor ( ecx : @EncodeContext ,
472
- ebml_w : writer:: Encoder ,
473
- id : node_id ,
474
- ident : ident ,
475
- path : & [ ast_map:: path_elt ] ,
476
- item : Option < inlined_item > ,
477
- generics : & ast:: Generics ) {
468
+ fn encode_info_for_ctor ( ecx : @EncodeContext , ebml_w : writer:: Encoder ,
469
+ id : node_id , ident : ident , path : & [ ast_map:: path_elt ] ,
470
+ item : Option < inlined_item > , tps : & [ ty_param ] ) {
478
471
ebml_w. start_tag ( tag_items_data_item) ;
479
472
encode_name ( ecx, ebml_w, ident) ;
480
473
encode_def_id ( ebml_w, local_def ( id) ) ;
481
474
encode_family ( ebml_w, purity_fn_family ( ast:: impure_fn) ) ;
482
- encode_type_param_bounds ( ebml_w, ecx, & generics . ty_params ) ;
475
+ encode_type_param_bounds ( ebml_w, ecx, tps ) ;
483
476
let its_ty = node_id_to_type ( ecx. tcx , id) ;
484
477
debug ! ( "fn name = %s ty = %s its node id = %d" ,
485
478
* ecx. tcx. sess. str_of( ident) ,
@@ -525,12 +518,9 @@ fn encode_info_for_method(ecx: @EncodeContext,
525
518
should_inline : bool ,
526
519
parent_id : node_id ,
527
520
m : @method ,
528
- owner_generics : & ast:: Generics ,
529
- method_generics : & ast:: Generics ) {
530
- debug ! ( "encode_info_for_method: %d %s %u %u" , m. id,
531
- * ecx. tcx. sess. str_of( m. ident) ,
532
- owner_generics. ty_params. len( ) ,
533
- method_generics. ty_params. len( ) ) ;
521
+ +all_tps : ~[ ty_param ] ) {
522
+ debug ! ( "encode_info_for_method: %d %s %u" , m. id,
523
+ * ecx. tcx. sess. str_of( m. ident) , all_tps. len( ) ) ;
534
524
ebml_w. start_tag ( tag_items_data_item) ;
535
525
encode_def_id ( ebml_w, local_def ( m. id ) ) ;
536
526
match m. self_ty . node {
@@ -539,13 +529,8 @@ fn encode_info_for_method(ecx: @EncodeContext,
539
529
}
540
530
_ => encode_family ( ebml_w, purity_fn_family ( m. purity ) )
541
531
}
542
-
543
- let mut combined_ty_params = opt_vec:: Empty ;
544
- combined_ty_params. push_all ( & owner_generics. ty_params ) ;
545
- combined_ty_params. push_all ( & method_generics. ty_params ) ;
546
- let len = combined_ty_params. len ( ) ;
547
- encode_type_param_bounds ( ebml_w, ecx, & combined_ty_params) ;
548
-
532
+ let len = all_tps. len ( ) ;
533
+ encode_type_param_bounds ( ebml_w, ecx, all_tps) ;
549
534
encode_type ( ecx, ebml_w, node_id_to_type ( ecx. tcx , m. id ) ) ;
550
535
encode_name ( ecx, ebml_w, m. ident ) ;
551
536
encode_path ( ecx, ebml_w, impl_path, ast_map:: path_name ( m. ident ) ) ;
@@ -619,13 +604,13 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
619
604
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
620
605
ebml_w.end_tag();
621
606
}
622
- item_fn(_, purity, ref generics , _) => {
607
+ item_fn(_, purity, tps , _) => {
623
608
add_to_index();
624
609
ebml_w.start_tag(tag_items_data_item);
625
610
encode_def_id(ebml_w, local_def(item.id));
626
611
encode_family(ebml_w, purity_fn_family(purity));
627
- let tps_len = generics.ty_params .len();
628
- encode_type_param_bounds(ebml_w, ecx, &generics.ty_params );
612
+ let tps_len = tps .len();
613
+ encode_type_param_bounds(ebml_w, ecx, tps );
629
614
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
630
615
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
631
616
encode_attributes(ebml_w, item.attrs);
@@ -649,24 +634,24 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
649
634
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
650
635
ebml_w.end_tag();
651
636
}
652
- item_ty(_, ref generics ) => {
637
+ item_ty(_, tps ) => {
653
638
add_to_index();
654
639
ebml_w.start_tag(tag_items_data_item);
655
640
encode_def_id(ebml_w, local_def(item.id));
656
641
encode_family(ebml_w, 'y');
657
- encode_type_param_bounds(ebml_w, ecx, &generics.ty_params );
642
+ encode_type_param_bounds(ebml_w, ecx, tps );
658
643
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
659
644
encode_name(ecx, ebml_w, item.ident);
660
645
encode_path(ecx, ebml_w, path, ast_map::path_name(item.ident));
661
646
encode_region_param(ecx, ebml_w, item);
662
647
ebml_w.end_tag();
663
648
}
664
- item_enum(ref enum_definition, ref generics ) => {
649
+ item_enum(ref enum_definition, ref tps ) => {
665
650
add_to_index();
666
651
do ebml_w.wr_tag(tag_items_data_item) {
667
652
encode_def_id(ebml_w, local_def(item.id));
668
653
encode_family(ebml_w, 't');
669
- encode_type_param_bounds(ebml_w, ecx, &generics.ty_params );
654
+ encode_type_param_bounds(ebml_w, ecx, *tps );
670
655
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
671
656
encode_name(ecx, ebml_w, item.ident);
672
657
for (*enum_definition).variants.each |v| {
@@ -682,9 +667,9 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
682
667
(*enum_definition).variants,
683
668
path,
684
669
index,
685
- generics );
670
+ *tps );
686
671
}
687
- item_struct(struct_def, ref generics ) => {
672
+ item_struct(struct_def, tps ) => {
688
673
/* First, encode the fields
689
674
These come first because we need to write them to make
690
675
the index, and the index needs to be in the item for the
@@ -701,25 +686,24 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
701
686
*ecx.tcx.sess.str_of(item.ident) +
702
687
~" _dtor"),
703
688
path,
704
- if generics.ty_params .len() > 0u {
689
+ if tps .len() > 0u {
705
690
Some(ii_dtor(copy *dtor,
706
691
item.ident,
707
- copy *generics ,
692
+ copy tps ,
708
693
local_def(item.id))) }
709
694
else {
710
695
None
711
696
},
712
- generics );
697
+ tps );
713
698
}
714
699
715
700
/* Index the class*/
716
701
add_to_index();
717
-
718
702
/* Now, make an item for the class itself */
719
703
ebml_w.start_tag(tag_items_data_item);
720
704
encode_def_id(ebml_w, local_def(item.id));
721
705
encode_family(ebml_w, 'S');
722
- encode_type_param_bounds(ebml_w, ecx, &generics.ty_params );
706
+ encode_type_param_bounds(ebml_w, ecx, tps );
723
707
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
724
708
725
709
// If this is a tuple- or enum-like struct, encode the type of the
@@ -775,13 +759,13 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
775
759
encode_index(ebml_w, bkts, write_int);
776
760
ebml_w.end_tag();
777
761
}
778
- item_impl(ref generics , opt_trait, ty, ref methods) => {
762
+ item_impl(tps , opt_trait, ty, methods) => {
779
763
add_to_index();
780
764
ebml_w.start_tag(tag_items_data_item);
781
765
encode_def_id(ebml_w, local_def(item.id));
782
766
encode_family(ebml_w, 'i');
783
767
encode_region_param(ecx, ebml_w, item);
784
- encode_type_param_bounds(ebml_w, ecx, &generics.ty_params );
768
+ encode_type_param_bounds(ebml_w, ecx, tps );
785
769
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
786
770
encode_name(ecx, ebml_w, item.ident);
787
771
encode_attributes(ebml_w, item.attrs);
@@ -813,18 +797,18 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
813
797
encode_info_for_method(ecx, ebml_w, impl_path,
814
798
should_inline(m.attrs),
815
799
item.id, *m,
816
- generics, &m.generics );
800
+ vec::append(/*bad*/copy tps, m.tps) );
817
801
}
818
802
}
819
- item_trait(ref generics , ref traits, ref ms) => {
803
+ item_trait(ref tps , ref traits, ref ms) => {
820
804
let provided_methods = dvec::DVec();
821
805
822
806
add_to_index();
823
807
ebml_w.start_tag(tag_items_data_item);
824
808
encode_def_id(ebml_w, local_def(item.id));
825
809
encode_family(ebml_w, 'I');
826
810
encode_region_param(ecx, ebml_w, item);
827
- encode_type_param_bounds(ebml_w, ecx, &generics.ty_params );
811
+ encode_type_param_bounds(ebml_w, ecx, *tps );
828
812
encode_type(ecx, ebml_w, node_id_to_type(tcx, item.id));
829
813
encode_name(ecx, ebml_w, item.ident);
830
814
encode_attributes(ebml_w, item.attrs);
@@ -836,7 +820,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
836
820
encode_def_id(ebml_w, local_def((*ty_m).id));
837
821
encode_name(ecx, ebml_w, mty.ident);
838
822
encode_type_param_bounds(ebml_w, ecx,
839
- & ty_m.generics.ty_params );
823
+ (* ty_m).tps );
840
824
encode_type(ecx, ebml_w,
841
825
ty::mk_bare_fn(tcx, copy mty.fty));
842
826
encode_family(ebml_w, purity_fn_family(mty.fty.purity));
@@ -850,8 +834,7 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
850
834
ebml_w.start_tag(tag_item_trait_method);
851
835
encode_def_id(ebml_w, local_def(m.id));
852
836
encode_name(ecx, ebml_w, mty.ident);
853
- encode_type_param_bounds(ebml_w, ecx,
854
- &m.generics.ty_params);
837
+ encode_type_param_bounds(ebml_w, ecx, m.tps);
855
838
encode_type(ecx, ebml_w,
856
839
ty::mk_bare_fn(tcx, copy mty.fty));
857
840
encode_family(ebml_w, purity_fn_family(mty.fty.purity));
@@ -897,14 +880,8 @@ fn encode_info_for_item(ecx: @EncodeContext, ebml_w: writer::Encoder,
897
880
// Finally, output all the provided methods as items.
898
881
for provided_methods.each |m| {
899
882
index.push(entry { val: m.id, pos: ebml_w.writer.tell() });
900
-
901
- // We do not concatenate the generics of the owning impl and that
902
- // of provided methods. I am not sure why this is. -ndm
903
- let owner_generics = ast_util::empty_generics();
904
-
905
883
encode_info_for_method(ecx, ebml_w, /*bad*/copy path,
906
- true, item.id, *m,
907
- &owner_generics, &m.generics);
884
+ true, item.id, *m, /*bad*/copy m.tps);
908
885
}
909
886
}
910
887
item_mac(*) => fail!(~" item macros unimplemented")
@@ -921,11 +898,11 @@ fn encode_info_for_foreign_item(ecx: @EncodeContext,
921
898
index.push(entry { val: nitem.id, pos: ebml_w.writer.tell() });
922
899
923
900
ebml_w.start_tag(tag_items_data_item);
924
- match nitem.node {
925
- foreign_item_fn(_, purity, ref generics ) => {
901
+ match /*bad*/copy nitem.node {
902
+ foreign_item_fn(_, purity, tps ) => {
926
903
encode_def_id(ebml_w, local_def(nitem.id));
927
904
encode_family(ebml_w, purity_fn_family(purity));
928
- encode_type_param_bounds(ebml_w, ecx, &generics.ty_params );
905
+ encode_type_param_bounds(ebml_w, ecx, tps );
929
906
encode_type(ecx, ebml_w, node_id_to_type(ecx.tcx, nitem.id));
930
907
if abi == foreign_abi_rust_intrinsic {
931
908
(ecx.encode_inlined_item)(ecx, ebml_w, path, ii_foreign(nitem));
0 commit comments