9
9
//! that are created by the expansion of a macro.
10
10
11
11
use ast:: * ;
12
- use ast;
13
12
use syntax_pos:: Span ;
14
13
use source_map:: { Spanned , respan} ;
15
14
use parse:: token:: { self , Token } ;
@@ -785,31 +784,26 @@ pub fn noop_fold_where_predicate<T: Folder>(
785
784
fld : & mut T )
786
785
-> WherePredicate {
787
786
match pred {
788
- ast :: WherePredicate :: BoundPredicate ( ast :: WhereBoundPredicate { bound_generic_params,
789
- bounded_ty,
790
- bounds,
791
- span} ) => {
792
- ast :: WherePredicate :: BoundPredicate ( ast :: WhereBoundPredicate {
787
+ WherePredicate :: BoundPredicate ( WhereBoundPredicate { bound_generic_params,
788
+ bounded_ty,
789
+ bounds,
790
+ span } ) => {
791
+ WherePredicate :: BoundPredicate ( WhereBoundPredicate {
793
792
bound_generic_params : fld. fold_generic_params ( bound_generic_params) ,
794
793
bounded_ty : fld. fold_ty ( bounded_ty) ,
795
794
bounds : bounds. move_map ( |x| fld. fold_param_bound ( x) ) ,
796
795
span : fld. new_span ( span)
797
796
} )
798
797
}
799
- ast:: WherePredicate :: RegionPredicate ( ast:: WhereRegionPredicate { lifetime,
800
- bounds,
801
- span} ) => {
802
- ast:: WherePredicate :: RegionPredicate ( ast:: WhereRegionPredicate {
798
+ WherePredicate :: RegionPredicate ( WhereRegionPredicate { lifetime, bounds, span } ) => {
799
+ WherePredicate :: RegionPredicate ( WhereRegionPredicate {
803
800
span : fld. new_span ( span) ,
804
801
lifetime : noop_fold_lifetime ( lifetime, fld) ,
805
802
bounds : bounds. move_map ( |bound| noop_fold_param_bound ( bound, fld) )
806
803
} )
807
804
}
808
- ast:: WherePredicate :: EqPredicate ( ast:: WhereEqPredicate { id,
809
- lhs_ty,
810
- rhs_ty,
811
- span} ) => {
812
- ast:: WherePredicate :: EqPredicate ( ast:: WhereEqPredicate {
805
+ WherePredicate :: EqPredicate ( WhereEqPredicate { id, lhs_ty, rhs_ty, span } ) => {
806
+ WherePredicate :: EqPredicate ( WhereEqPredicate {
813
807
id : fld. new_id ( id) ,
814
808
lhs_ty : fld. fold_ty ( lhs_ty) ,
815
809
rhs_ty : fld. fold_ty ( rhs_ty) ,
@@ -821,15 +815,13 @@ pub fn noop_fold_where_predicate<T: Folder>(
821
815
822
816
pub fn noop_fold_variant_data < T : Folder > ( vdata : VariantData , fld : & mut T ) -> VariantData {
823
817
match vdata {
824
- ast:: VariantData :: Struct ( fields, id) => {
825
- ast:: VariantData :: Struct ( fields. move_map ( |f| fld. fold_struct_field ( f) ) ,
826
- fld. new_id ( id) )
818
+ VariantData :: Struct ( fields, id) => {
819
+ VariantData :: Struct ( fields. move_map ( |f| fld. fold_struct_field ( f) ) , fld. new_id ( id) )
827
820
}
828
- ast:: VariantData :: Tuple ( fields, id) => {
829
- ast:: VariantData :: Tuple ( fields. move_map ( |f| fld. fold_struct_field ( f) ) ,
830
- fld. new_id ( id) )
821
+ VariantData :: Tuple ( fields, id) => {
822
+ VariantData :: Tuple ( fields. move_map ( |f| fld. fold_struct_field ( f) ) , fld. new_id ( id) )
831
823
}
832
- ast :: VariantData :: Unit ( id) => ast :: VariantData :: Unit ( fld. new_id ( id) )
824
+ VariantData :: Unit ( id) => VariantData :: Unit ( fld. new_id ( id) )
833
825
}
834
826
}
835
827
@@ -839,14 +831,14 @@ pub fn noop_fold_trait_ref<T: Folder>(p: TraitRef, fld: &mut T) -> TraitRef {
839
831
path,
840
832
ref_id : _,
841
833
} = p;
842
- ast :: TraitRef {
834
+ TraitRef {
843
835
path : fld. fold_path ( path) ,
844
836
ref_id : id,
845
837
}
846
838
}
847
839
848
840
pub fn noop_fold_poly_trait_ref < T : Folder > ( p : PolyTraitRef , fld : & mut T ) -> PolyTraitRef {
849
- ast :: PolyTraitRef {
841
+ PolyTraitRef {
850
842
bound_generic_params : fld. fold_generic_params ( p. bound_generic_params ) ,
851
843
trait_ref : fld. fold_trait_ref ( p. trait_ref ) ,
852
844
span : fld. new_span ( p. span ) ,
@@ -932,7 +924,7 @@ pub fn noop_fold_item_kind<T: Folder>(i: ItemKind, folder: &mut T) -> ItemKind {
932
924
ItemKind :: Enum ( enum_definition, generics) => {
933
925
let generics = folder. fold_generics ( generics) ;
934
926
let variants = enum_definition. variants . move_map ( |x| folder. fold_variant ( x) ) ;
935
- ItemKind :: Enum ( ast :: EnumDef { variants } , generics)
927
+ ItemKind :: Enum ( EnumDef { variants } , generics)
936
928
}
937
929
ItemKind :: Struct ( struct_def, generics) => {
938
930
let generics = folder. fold_generics ( generics) ;
@@ -991,7 +983,7 @@ pub fn noop_fold_trait_item<T: Folder>(i: TraitItem, folder: &mut T) -> SmallVec
991
983
TraitItemKind :: Type ( folder. fold_bounds( bounds) ,
992
984
default . map( |x| folder. fold_ty( x) ) )
993
985
}
994
- ast :: TraitItemKind :: Macro ( mac) => {
986
+ TraitItemKind :: Macro ( mac) => {
995
987
TraitItemKind :: Macro ( folder. fold_mac( mac) )
996
988
}
997
989
} ,
@@ -1009,18 +1001,18 @@ pub fn noop_fold_impl_item<T: Folder>(i: ImplItem, folder: &mut T)-> SmallVec<[I
1009
1001
generics: folder. fold_generics( i. generics) ,
1010
1002
defaultness: i. defaultness,
1011
1003
node: match i. node {
1012
- ast :: ImplItemKind :: Const ( ty, expr) => {
1013
- ast :: ImplItemKind :: Const ( folder. fold_ty( ty) , folder. fold_expr( expr) )
1004
+ ImplItemKind :: Const ( ty, expr) => {
1005
+ ImplItemKind :: Const ( folder. fold_ty( ty) , folder. fold_expr( expr) )
1014
1006
}
1015
- ast :: ImplItemKind :: Method ( sig, body) => {
1016
- ast :: ImplItemKind :: Method ( noop_fold_method_sig( sig, folder) ,
1007
+ ImplItemKind :: Method ( sig, body) => {
1008
+ ImplItemKind :: Method ( noop_fold_method_sig( sig, folder) ,
1017
1009
folder. fold_block( body) )
1018
1010
}
1019
- ast :: ImplItemKind :: Type ( ty) => ast :: ImplItemKind :: Type ( folder. fold_ty( ty) ) ,
1020
- ast :: ImplItemKind :: Existential ( bounds) => {
1021
- ast :: ImplItemKind :: Existential ( folder. fold_bounds( bounds) )
1011
+ ImplItemKind :: Type ( ty) => ImplItemKind :: Type ( folder. fold_ty( ty) ) ,
1012
+ ImplItemKind :: Existential ( bounds) => {
1013
+ ImplItemKind :: Existential ( folder. fold_bounds( bounds) )
1022
1014
} ,
1023
- ast :: ImplItemKind :: Macro ( mac) => ast :: ImplItemKind :: Macro ( folder. fold_mac( mac) )
1015
+ ImplItemKind :: Macro ( mac) => ImplItemKind :: Macro ( folder. fold_mac( mac) )
1024
1016
} ,
1025
1017
span: folder. new_span( i. span) ,
1026
1018
tokens: i. tokens,
@@ -1042,28 +1034,28 @@ pub fn noop_fold_mod<T: Folder>(Mod {inner, items, inline}: Mod, folder: &mut T)
1042
1034
1043
1035
pub fn noop_fold_crate < T : Folder > ( Crate { module, attrs, span} : Crate ,
1044
1036
folder : & mut T ) -> Crate {
1045
- let mut items = folder. fold_item ( P ( ast :: Item {
1037
+ let mut items = folder. fold_item ( P ( Item {
1046
1038
ident : keywords:: Invalid . ident ( ) ,
1047
1039
attrs,
1048
- id : ast :: DUMMY_NODE_ID ,
1049
- vis : respan ( span. shrink_to_lo ( ) , ast :: VisibilityKind :: Public ) ,
1040
+ id : DUMMY_NODE_ID ,
1041
+ vis : respan ( span. shrink_to_lo ( ) , VisibilityKind :: Public ) ,
1050
1042
span,
1051
- node : ast :: ItemKind :: Mod ( module) ,
1043
+ node : ItemKind :: Mod ( module) ,
1052
1044
tokens : None ,
1053
1045
} ) ) . into_iter ( ) ;
1054
1046
1055
1047
let ( module, attrs, span) = match items. next ( ) {
1056
1048
Some ( item) => {
1057
1049
assert ! ( items. next( ) . is_none( ) ,
1058
1050
"a crate cannot expand to more than one item" ) ;
1059
- item. and_then ( |ast :: Item { attrs, span, node, .. } | {
1051
+ item. and_then ( |Item { attrs, span, node, .. } | {
1060
1052
match node {
1061
- ast :: ItemKind :: Mod ( m) => ( m, attrs, span) ,
1053
+ ItemKind :: Mod ( m) => ( m, attrs, span) ,
1062
1054
_ => panic ! ( "fold converted a module to not a module" ) ,
1063
1055
}
1064
1056
} )
1065
1057
}
1066
- None => ( ast :: Mod {
1058
+ None => ( Mod {
1067
1059
inner : span,
1068
1060
items : vec ! [ ] ,
1069
1061
inline : true ,
@@ -1155,7 +1147,7 @@ pub fn noop_fold_pat<T: Folder>(p: P<Pat>, folder: &mut T) -> P<Pat> {
1155
1147
let pth = folder. fold_path ( pth) ;
1156
1148
let fs = fields. move_map ( |f| {
1157
1149
Spanned { span : folder. new_span ( f. span ) ,
1158
- node : ast :: FieldPat {
1150
+ node : FieldPat {
1159
1151
ident : folder. fold_ident ( f. node . ident ) ,
1160
1152
pat : folder. fold_pat ( f. node . pat ) ,
1161
1153
is_shorthand : f. node . is_shorthand ,
0 commit comments