@@ -39,18 +39,16 @@ use syntax::ast::{ForeignItem, ForeignItemFn, ForeignItemStatic};
39
39
use syntax:: ast:: { Item , ItemConst , ItemEnum , ItemExternCrate , ItemFn } ;
40
40
use syntax:: ast:: { ItemForeignMod , ItemImpl , ItemMac , ItemMod , ItemStatic } ;
41
41
use syntax:: ast:: { ItemStruct , ItemTrait , ItemTy , ItemUse } ;
42
- use syntax:: ast:: { MethodImplItem , Name , NamedField , NodeId } ;
42
+ use syntax:: ast:: { Name , NamedField , NodeId } ;
43
43
use syntax:: ast:: { PathListIdent , PathListMod , Public } ;
44
44
use syntax:: ast:: StmtDecl ;
45
45
use syntax:: ast:: StructVariantKind ;
46
46
use syntax:: ast:: TupleVariantKind ;
47
- use syntax:: ast:: TyObjectSum ;
48
- use syntax:: ast:: { TypeImplItem , UnnamedField } ;
47
+ use syntax:: ast:: UnnamedField ;
49
48
use syntax:: ast:: { Variant , ViewPathGlob , ViewPathList , ViewPathSimple } ;
50
49
use syntax:: ast:: { Visibility } ;
51
- use syntax:: ast:: TyPath ;
52
50
use syntax:: ast;
53
- use syntax:: ast_util:: { self , PostExpansionMethod , local_def} ;
51
+ use syntax:: ast_util:: { self , local_def} ;
54
52
use syntax:: attr:: AttrMetaMethods ;
55
53
use syntax:: parse:: token:: { self , special_idents} ;
56
54
use syntax:: codemap:: { Span , DUMMY_SP } ;
@@ -177,12 +175,8 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
177
175
Some ( TypeNS )
178
176
}
179
177
ForbidDuplicateTypesAndModules => {
180
- match child. def_for_namespace ( TypeNS ) {
181
- None => { }
182
- Some ( _) if child. get_module_if_available ( )
183
- . map ( |m| m. kind . get ( ) ) ==
184
- Some ( ImplModuleKind ) => { }
185
- Some ( _) => duplicate_type = TypeError
178
+ if child. defined_in_namespace ( TypeNS ) {
179
+ duplicate_type = TypeError ;
186
180
}
187
181
Some ( TypeNS )
188
182
}
@@ -461,9 +455,6 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
461
455
name_bindings. define_type ( DefTy ( local_def ( item. id ) , true ) , sp, modifiers) ;
462
456
463
457
let parent_link = self . get_parent_link ( parent, name) ;
464
- // We want to make sure the module type is EnumModuleKind
465
- // even if there's already an ImplModuleKind module defined,
466
- // since that's how we prevent duplicate enum definitions
467
458
name_bindings. set_module_kind ( parent_link,
468
459
Some ( local_def ( item. id ) ) ,
469
460
EnumModuleKind ,
@@ -513,132 +504,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
513
504
parent. clone ( )
514
505
}
515
506
516
- ItemImpl ( _, _, _, None , ref ty, ref impl_items) => {
517
- // If this implements an anonymous trait, then add all the
518
- // methods within to a new module, if the type was defined
519
- // within this module.
520
-
521
- let mod_name = match ty. node {
522
- TyPath ( ref path) if path. segments . len ( ) == 1 => {
523
- // FIXME(18446) we should distinguish between the name of
524
- // a trait and the name of an impl of that trait.
525
- Some ( path. segments . last ( ) . unwrap ( ) . identifier . name )
526
- }
527
- TyObjectSum ( ref lhs_ty, _) => {
528
- match lhs_ty. node {
529
- TyPath ( ref path) if path. segments . len ( ) == 1 => {
530
- Some ( path. segments . last ( ) . unwrap ( ) . identifier . name )
531
- }
532
- _ => {
533
- None
534
- }
535
- }
536
- }
537
- _ => {
538
- None
539
- }
540
- } ;
541
-
542
- let mod_name = match mod_name {
543
- Some ( mod_name) => mod_name,
544
- None => {
545
- self . resolve_error ( ty. span ,
546
- "inherent implementations may \
547
- only be implemented in the same \
548
- module as the type they are \
549
- implemented for") ;
550
- return parent. clone ( ) ;
551
- }
552
- } ;
553
- // Create the module and add all methods.
554
- let child_opt = parent. children . borrow ( ) . get ( & mod_name)
555
- . and_then ( |m| m. get_module_if_available ( ) ) ;
556
- let new_parent = match child_opt {
557
- // It already exists
558
- Some ( ref child) if ( child. kind . get ( ) == ImplModuleKind ||
559
- child. kind . get ( ) == TraitModuleKind ) => {
560
- child. clone ( )
561
- }
562
- Some ( ref child) if child. kind . get ( ) == EnumModuleKind ||
563
- child. kind . get ( ) == TypeModuleKind => {
564
- child. clone ( )
565
- }
566
- // Create the module
567
- _ => {
568
- let name_bindings =
569
- self . add_child ( mod_name, parent, ForbidDuplicateModules , sp) ;
570
-
571
- let parent_link = self . get_parent_link ( parent, name) ;
572
- let def_id = local_def ( item. id ) ;
573
- let ns = TypeNS ;
574
- let is_public =
575
- !name_bindings. defined_in_namespace ( ns) ||
576
- name_bindings. defined_in_public_namespace ( ns) ;
577
-
578
- name_bindings. define_module ( parent_link,
579
- Some ( def_id) ,
580
- ImplModuleKind ,
581
- false ,
582
- is_public,
583
- sp) ;
584
-
585
- name_bindings. get_module ( )
586
- }
587
- } ;
588
-
589
- // For each implementation item...
590
- for impl_item in impl_items {
591
- match * impl_item {
592
- MethodImplItem ( ref method) => {
593
- // Add the method to the module.
594
- let name = method. pe_ident ( ) . name ;
595
- let method_name_bindings =
596
- self . add_child ( name,
597
- & new_parent,
598
- ForbidDuplicateValues ,
599
- method. span ) ;
600
- let def = DefMethod ( local_def ( method. id ) ,
601
- FromImpl ( local_def ( item. id ) ) ) ;
602
-
603
- // NB: not IMPORTABLE
604
- let modifiers = if method. pe_vis ( ) == ast:: Public {
605
- PUBLIC
606
- } else {
607
- DefModifiers :: empty ( )
608
- } ;
609
- method_name_bindings. define_value (
610
- def,
611
- method. span ,
612
- modifiers) ;
613
- }
614
- TypeImplItem ( ref typedef) => {
615
- // Add the typedef to the module.
616
- let name = typedef. ident . name ;
617
- let typedef_name_bindings =
618
- self . add_child (
619
- name,
620
- & new_parent,
621
- ForbidDuplicateTypesAndModules ,
622
- typedef. span ) ;
623
- let def = DefAssociatedTy ( local_def ( item. id ) ,
624
- local_def ( typedef. id ) ) ;
625
- // NB: not IMPORTABLE
626
- let modifiers = if typedef. vis == ast:: Public {
627
- PUBLIC
628
- } else {
629
- DefModifiers :: empty ( )
630
- } ;
631
- typedef_name_bindings. define_type (
632
- def,
633
- typedef. span ,
634
- modifiers) ;
635
- }
636
- }
637
- }
638
- parent. clone ( )
639
- }
640
-
641
- ItemImpl ( _, _, _, Some ( _) , _, _) => parent. clone ( ) ,
507
+ ItemImpl ( ..) => parent. clone ( ) ,
642
508
643
509
ItemTrait ( _, _, _, ref items) => {
644
510
let name_bindings =
@@ -804,8 +670,7 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
804
670
805
671
let kind = match def {
806
672
DefTy ( _, true ) => EnumModuleKind ,
807
- DefTy ( _, false ) => TypeModuleKind ,
808
- DefStruct ( ..) => ImplModuleKind ,
673
+ DefTy ( _, false ) | DefStruct ( ..) => TypeModuleKind ,
809
674
_ => NormalModuleKind
810
675
} ;
811
676
@@ -979,92 +844,9 @@ impl<'a, 'b:'a, 'tcx:'b> GraphBuilder<'a, 'b, 'tcx> {
979
844
}
980
845
}
981
846
}
982
- DlImpl ( def) => {
983
- match csearch:: get_type_name_if_impl ( & self . session . cstore , def) {
984
- None => { }
985
- Some ( final_name) => {
986
- let methods_opt =
987
- csearch:: get_methods_if_impl ( & self . session . cstore , def) ;
988
- match methods_opt {
989
- Some ( ref methods) if
990
- methods. len ( ) >= 1 => {
991
- debug ! ( "(building reduced graph for \
992
- external crate) processing \
993
- static methods for type name {}",
994
- token:: get_name( final_name) ) ;
995
-
996
- let child_name_bindings =
997
- self . add_child (
998
- final_name,
999
- root,
1000
- OverwriteDuplicates ,
1001
- DUMMY_SP ) ;
1002
-
1003
- // Process the static methods. First,
1004
- // create the module.
1005
- let type_module;
1006
- let type_def = child_name_bindings. type_def . borrow ( ) . clone ( ) ;
1007
- match type_def {
1008
- Some ( TypeNsDef {
1009
- module_def : Some ( module_def) ,
1010
- ..
1011
- } ) => {
1012
- // We already have a module. This
1013
- // is OK.
1014
- type_module = module_def;
1015
-
1016
- // Mark it as an impl module if
1017
- // necessary.
1018
- type_module. kind . set ( ImplModuleKind ) ;
1019
- }
1020
- Some ( _) | None => {
1021
- let parent_link =
1022
- self . get_parent_link ( root, final_name) ;
1023
- child_name_bindings. define_module (
1024
- parent_link,
1025
- Some ( def) ,
1026
- ImplModuleKind ,
1027
- true ,
1028
- true ,
1029
- DUMMY_SP ) ;
1030
- type_module =
1031
- child_name_bindings.
1032
- get_module ( ) ;
1033
- }
1034
- }
1035
-
1036
- // Add each static method to the module.
1037
- let new_parent = type_module;
1038
- for method_info in methods {
1039
- let name = method_info. name ;
1040
- debug ! ( "(building reduced graph for \
1041
- external crate) creating \
1042
- static method '{}'",
1043
- token:: get_name( name) ) ;
1044
-
1045
- let method_name_bindings =
1046
- self . add_child ( name,
1047
- & new_parent,
1048
- OverwriteDuplicates ,
1049
- DUMMY_SP ) ;
1050
- let def = DefFn ( method_info. def_id , false ) ;
1051
-
1052
- // NB: not IMPORTABLE
1053
- let modifiers = if method_info. vis == ast:: Public {
1054
- PUBLIC
1055
- } else {
1056
- DefModifiers :: empty ( )
1057
- } ;
1058
- method_name_bindings. define_value (
1059
- def, DUMMY_SP , modifiers) ;
1060
- }
1061
- }
1062
-
1063
- // Otherwise, do nothing.
1064
- Some ( _) | None => { }
1065
- }
1066
- }
1067
- }
847
+ DlImpl ( _) => {
848
+ debug ! ( "(building reduced graph for external crate) \
849
+ ignoring impl") ;
1068
850
}
1069
851
DlField => {
1070
852
debug ! ( "(building reduced graph for external crate) \
0 commit comments