@@ -25,8 +25,8 @@ use std::path::{Path, PathBuf};
25
25
use syntax:: abi:: Abi ;
26
26
use syntax:: ast;
27
27
use syntax:: attr:: { self , ReprAttr } ;
28
- use syntax:: diagnostic :: SpanHandler ;
29
- use syntax:: ext:: base:: SyntaxExtension ;
28
+ use syntax:: errors :: Handler as SpanHandler ;
29
+ use syntax:: ext:: base:: { ExtCtxt , SyntaxExtension } ;
30
30
use syntax:: ext:: expand;
31
31
use syntax:: parse:: token:: { intern, InternedString } ;
32
32
use syntax:: parse:: { self , ParseSess } ;
@@ -618,22 +618,23 @@ impl TestGenerator {
618
618
let exts = vec ! [
619
619
( intern( "macro_rules" ) , SyntaxExtension :: MacroRulesTT ) ,
620
620
] ;
621
- let mut krate = expand:: expand_crate ( & sess, ecfg, Vec :: new ( ) ,
622
- exts, & mut Vec :: new ( ) , krate) ;
621
+ let mut feature_gated_cfgs = Vec :: new ( ) ;
622
+ let ecx = ExtCtxt :: new ( & sess, Vec :: new ( ) , ecfg, & mut feature_gated_cfgs) ;
623
+ let mut krate = expand:: expand_crate ( ecx, Vec :: new ( ) , exts, krate) ;
623
624
624
625
// Strip the crate down to just what's configured for our target
625
626
let target = self . target . clone ( ) . unwrap_or_else ( || {
626
627
env:: var ( "TARGET" ) . unwrap ( )
627
628
} ) ;
628
629
for ( k, v) in default_cfg ( & target) . into_iter ( ) . chain ( self . cfg . clone ( ) ) {
629
630
let s = |s : & str | InternedString :: new_from_name ( intern ( s) ) ;
630
- krate. config . push ( match v {
631
+ krate. 0 . config . push ( match v {
631
632
Some ( v) => attr:: mk_name_value_item_str ( s ( & k) , s ( & v) ) ,
632
633
None => attr:: mk_word_item ( s ( & k) ) ,
633
634
} ) ;
634
635
}
635
636
let krate = syntax:: config:: strip_unconfigured_items ( & sess. span_diagnostic ,
636
- krate,
637
+ krate. 0 ,
637
638
& mut Vec :: new ( ) ) ;
638
639
639
640
// Probe the crate to find all structs (used to convert type names to
@@ -864,8 +865,8 @@ impl<'a> Generator<'a> {
864
865
"# , ty = ty) ) ;
865
866
for field in s. fields ( ) {
866
867
let name = match field. node . kind {
867
- ast:: NamedField ( name, ast:: Public ) => name,
868
- ast:: NamedField ( _, ast:: Inherited ) => continue ,
868
+ ast:: NamedField ( name, ast:: Visibility :: Public ) => name,
869
+ ast:: NamedField ( _, ast:: Visibility :: Inherited ) => continue ,
869
870
ast:: UnnamedField ( ..) => panic ! ( "no tuple structs in FFI" ) ,
870
871
} ;
871
872
let name = name. to_string ( ) ;
@@ -1086,11 +1087,11 @@ impl<'a> Generator<'a> {
1086
1087
1087
1088
fn ty2name ( & self , ty : & ast:: Ty , rust : bool ) -> String {
1088
1089
match ty. node {
1089
- ast:: TyPath ( _, ref path) => {
1090
+ ast:: TyKind :: Path ( _, ref path) => {
1090
1091
let last = path. segments . last ( ) . unwrap ( ) ;
1091
1092
if last. identifier . to_string ( ) == "Option" {
1092
1093
match last. parameters {
1093
- ast:: AngleBracketedParameters ( ref p) => {
1094
+ ast:: PathParameters :: AngleBracketed ( ref p) => {
1094
1095
self . ty2name ( & p. types [ 0 ] , rust)
1095
1096
}
1096
1097
_ => panic ! ( ) ,
@@ -1101,20 +1102,20 @@ impl<'a> Generator<'a> {
1101
1102
self . rust2c ( & last. identifier . to_string ( ) )
1102
1103
}
1103
1104
}
1104
- ast:: TyPtr ( ref t) => {
1105
+ ast:: TyKind :: Ptr ( ref t) => {
1105
1106
if rust {
1106
1107
format ! ( "*{} {}" , match t. mutbl {
1107
- ast:: MutImmutable => "const" ,
1108
- ast:: MutMutable => "mut" ,
1108
+ ast:: Mutability :: Immutable => "const" ,
1109
+ ast:: Mutability :: Mutable => "mut" ,
1109
1110
} , self . ty2name( & t. ty, rust) )
1110
1111
} else {
1111
1112
let modifier = match t. mutbl {
1112
- ast:: MutImmutable => "const " ,
1113
- ast:: MutMutable => "" ,
1113
+ ast:: Mutability :: Immutable => "const " ,
1114
+ ast:: Mutability :: Mutable => "" ,
1114
1115
} ;
1115
1116
match t. ty . node {
1116
- ast:: TyBareFn ( ..) => self . ty2name ( & t. ty , rust) ,
1117
- ast:: TyPtr ( ..) => {
1117
+ ast:: TyKind :: BareFn ( ..) => self . ty2name ( & t. ty , rust) ,
1118
+ ast:: TyKind :: Ptr ( ..) => {
1118
1119
format ! ( "{} {}*" , self . ty2name( & t. ty, rust) ,
1119
1120
modifier)
1120
1121
}
@@ -1124,15 +1125,15 @@ impl<'a> Generator<'a> {
1124
1125
}
1125
1126
}
1126
1127
}
1127
- ast:: TyBareFn ( ref t) => {
1128
+ ast:: TyKind :: BareFn ( ref t) => {
1128
1129
if rust {
1129
1130
let args = t. decl . inputs . iter ( ) . map ( |a| {
1130
1131
self . ty2name ( & a. ty , rust)
1131
1132
} ) . collect :: < Vec < _ > > ( ) . connect ( ", " ) ;
1132
1133
let ret = match t. decl . output {
1133
- ast:: NoReturn ( ..) => "!" . to_string ( ) ,
1134
- ast:: DefaultReturn ( ..) => "()" . to_string ( ) ,
1135
- ast:: Return ( ref t) => self . ty2name ( t, rust) ,
1134
+ ast:: FunctionRetTy :: None ( ..) => "!" . to_string ( ) ,
1135
+ ast:: FunctionRetTy :: Default ( ..) => "()" . to_string ( ) ,
1136
+ ast:: FunctionRetTy :: Ty ( ref t) => self . ty2name ( t, rust) ,
1136
1137
} ;
1137
1138
format ! ( "extern fn({}) -> {}" , args, ret)
1138
1139
} else {
@@ -1145,7 +1146,7 @@ impl<'a> Generator<'a> {
1145
1146
format ! ( "{}(*)({})" , ret, args. connect( ", " ) )
1146
1147
}
1147
1148
}
1148
- ast:: TyFixedLengthVec ( ref t, ref e) => {
1149
+ ast:: TyKind :: FixedLengthVec ( ref t, ref e) => {
1149
1150
assert ! ( rust) ;
1150
1151
format ! ( "[{}; {}]" , self . ty2name( t, rust) , self . expr2str( e) )
1151
1152
}
@@ -1155,18 +1156,18 @@ impl<'a> Generator<'a> {
1155
1156
1156
1157
fn csig_returning_ptr ( & self , ty : & ast:: Ty , sig : & str ) -> String {
1157
1158
match ty. node {
1158
- ast:: TyPath ( _, ref path) if path. segments . last ( ) . unwrap ( )
1159
+ ast:: TyKind :: Path ( _, ref path) if path. segments . last ( ) . unwrap ( )
1159
1160
. identifier . to_string ( ) == "Option"
1160
1161
=> {
1161
1162
let last = path. segments . last ( ) . unwrap ( ) ;
1162
1163
match last. parameters {
1163
- ast:: AngleBracketedParameters ( ref p) => {
1164
+ ast:: PathParameters :: AngleBracketed ( ref p) => {
1164
1165
self . csig_returning_ptr ( & p. types [ 0 ] , sig)
1165
1166
}
1166
1167
_ => panic ! ( ) ,
1167
1168
}
1168
1169
}
1169
- ast:: TyBareFn ( ref t) => {
1170
+ ast:: TyKind :: BareFn ( ref t) => {
1170
1171
assert ! ( t. lifetimes. len( ) == 0 ) ;
1171
1172
let ( ret, mut args, variadic) = self . decl2rust ( & t. decl ) ;
1172
1173
if variadic {
@@ -1176,7 +1177,7 @@ impl<'a> Generator<'a> {
1176
1177
}
1177
1178
format ! ( "{}(**{})({})" , ret, sig, args. connect( ", " ) )
1178
1179
}
1179
- ast:: TyFixedLengthVec ( ref t, ref e) => {
1180
+ ast:: TyKind :: FixedLengthVec ( ref t, ref e) => {
1180
1181
format ! ( "{}(*{})[{}]" , self . ty2name( t, false ) , sig,
1181
1182
self . expr2str( e) )
1182
1183
}
@@ -1186,16 +1187,16 @@ impl<'a> Generator<'a> {
1186
1187
1187
1188
fn expr2str ( & self , e : & ast:: Expr ) -> String {
1188
1189
match e. node {
1189
- ast:: ExprLit ( ref l) => {
1190
+ ast:: ExprKind :: Lit ( ref l) => {
1190
1191
match l. node {
1191
- ast:: LitInt ( a, _) => a. to_string ( ) ,
1192
+ ast:: LitKind :: Int ( a, _) => a. to_string ( ) ,
1192
1193
_ => panic ! ( "unknown literal: {:?}" , l) ,
1193
1194
}
1194
1195
}
1195
- ast:: ExprPath ( _, ref path) => {
1196
+ ast:: ExprKind :: Path ( _, ref path) => {
1196
1197
path. segments . last ( ) . unwrap ( ) . identifier . to_string ( )
1197
1198
}
1198
- ast:: ExprCast ( ref e, _) => self . expr2str ( e) ,
1199
+ ast:: ExprKind :: Cast ( ref e, _) => self . expr2str ( e) ,
1199
1200
_ => panic ! ( "unknown expr: {:?}" , e) ,
1200
1201
}
1201
1202
}
@@ -1205,9 +1206,9 @@ impl<'a> Generator<'a> {
1205
1206
self . ty2name ( & arg. ty , false )
1206
1207
} ) . collect :: < Vec < _ > > ( ) ;
1207
1208
let ret = match decl. output {
1208
- ast:: NoReturn ( ..) |
1209
- ast:: DefaultReturn ( ..) => "void" . to_string ( ) ,
1210
- ast:: Return ( ref t) => self . ty2name ( t, false ) ,
1209
+ ast:: FunctionRetTy :: None ( ..) |
1210
+ ast:: FunctionRetTy :: Default ( ..) => "void" . to_string ( ) ,
1211
+ ast:: FunctionRetTy :: Ty ( ref t) => self . ty2name ( t, false ) ,
1211
1212
} ;
1212
1213
( ret, args, decl. variadic )
1213
1214
}
@@ -1228,14 +1229,14 @@ impl<'a> Generator<'a> {
1228
1229
impl < ' a , ' v > Visitor < ' v > for Generator < ' a > {
1229
1230
fn visit_item ( & mut self , i : & ' v ast:: Item ) {
1230
1231
let prev_abi = self . abi ;
1231
- let public = i. vis == ast:: Public ;
1232
+ let public = i. vis == ast:: Visibility :: Public ;
1232
1233
match i. node {
1233
- ast:: ItemTy ( _, ref generics) if public => {
1234
+ ast:: ItemKind :: Ty ( _, ref generics) if public => {
1234
1235
self . assert_no_generics ( i. ident , generics) ;
1235
1236
self . test_type ( & i. ident . to_string ( ) ) ;
1236
1237
}
1237
1238
1238
- ast:: ItemStruct ( ref s, ref generics) if public => {
1239
+ ast:: ItemKind :: Struct ( ref s, ref generics) if public => {
1239
1240
self . assert_no_generics ( i. ident , generics) ;
1240
1241
let is_c = i. attrs . iter ( ) . any ( |a| {
1241
1242
attr:: find_repr_attrs ( self . sh , a) . iter ( ) . any ( |a| {
@@ -1248,12 +1249,12 @@ impl<'a, 'v> Visitor<'v> for Generator<'a> {
1248
1249
self . test_struct ( & i. ident . to_string ( ) , s) ;
1249
1250
}
1250
1251
1251
- ast:: ItemConst ( ref ty, _) if public => {
1252
+ ast:: ItemKind :: Const ( ref ty, _) if public => {
1252
1253
let ty = self . ty2name ( ty, true ) ;
1253
1254
self . test_const ( & i. ident . to_string ( ) , & ty) ;
1254
1255
}
1255
1256
1256
- ast:: ItemForeignMod ( ref fm) if public => {
1257
+ ast:: ItemKind :: ForeignMod ( ref fm) if public => {
1257
1258
self . abi = fm. abi ;
1258
1259
}
1259
1260
@@ -1269,7 +1270,7 @@ impl<'a, 'v> Visitor<'v> for Generator<'a> {
1269
1270
1270
1271
fn visit_foreign_item ( & mut self , i : & ' v ast:: ForeignItem ) {
1271
1272
match i. node {
1272
- ast:: ForeignItemFn ( ref decl, ref generics) => {
1273
+ ast:: ForeignItemKind :: Fn ( ref decl, ref generics) => {
1273
1274
self . assert_no_generics ( i. ident , generics) ;
1274
1275
let ( ret, args, variadic) = self . decl2rust ( decl) ;
1275
1276
let cname = attr:: first_attr_value_str_by_name ( & i. attrs , "link_name" )
@@ -1278,7 +1279,7 @@ impl<'a, 'v> Visitor<'v> for Generator<'a> {
1278
1279
self . test_extern_fn ( & i. ident . to_string ( ) , cname, & args, & ret,
1279
1280
variadic, abi) ;
1280
1281
}
1281
- ast:: ForeignItemStatic ( _, _) => {
1282
+ ast:: ForeignItemKind :: Static ( _, _) => {
1282
1283
}
1283
1284
}
1284
1285
visit:: walk_foreign_item ( self , i)
@@ -1290,10 +1291,10 @@ impl<'a, 'v> Visitor<'v> for Generator<'a> {
1290
1291
impl < ' v > Visitor < ' v > for StructFinder {
1291
1292
fn visit_item ( & mut self , i : & ' v ast:: Item ) {
1292
1293
match i. node {
1293
- ast:: ItemStruct ( ..) => {
1294
+ ast:: ItemKind :: Struct ( ..) => {
1294
1295
self . structs . insert ( i. ident . to_string ( ) ) ;
1295
1296
}
1296
- ast:: ItemEnum ( ..) => {
1297
+ ast:: ItemKind :: Enum ( ..) => {
1297
1298
self . structs . insert ( i. ident . to_string ( ) ) ;
1298
1299
}
1299
1300
0 commit comments