@@ -25,8 +25,8 @@ use std::path::{Path, PathBuf};
2525use syntax:: abi:: Abi ;
2626use syntax:: ast;
2727use 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 } ;
3030use syntax:: ext:: expand;
3131use syntax:: parse:: token:: { intern, InternedString } ;
3232use syntax:: parse:: { self , ParseSess } ;
@@ -618,22 +618,23 @@ impl TestGenerator {
618618 let exts = vec ! [
619619 ( intern( "macro_rules" ) , SyntaxExtension :: MacroRulesTT ) ,
620620 ] ;
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) ;
623624
624625 // Strip the crate down to just what's configured for our target
625626 let target = self . target . clone ( ) . unwrap_or_else ( || {
626627 env:: var ( "TARGET" ) . unwrap ( )
627628 } ) ;
628629 for ( k, v) in default_cfg ( & target) . into_iter ( ) . chain ( self . cfg . clone ( ) ) {
629630 let s = |s : & str | InternedString :: new_from_name ( intern ( s) ) ;
630- krate. config . push ( match v {
631+ krate. 0 . config . push ( match v {
631632 Some ( v) => attr:: mk_name_value_item_str ( s ( & k) , s ( & v) ) ,
632633 None => attr:: mk_word_item ( s ( & k) ) ,
633634 } ) ;
634635 }
635636 let krate = syntax:: config:: strip_unconfigured_items ( & sess. span_diagnostic ,
636- krate,
637+ krate. 0 ,
637638 & mut Vec :: new ( ) ) ;
638639
639640 // Probe the crate to find all structs (used to convert type names to
@@ -864,8 +865,8 @@ impl<'a> Generator<'a> {
864865 "# , ty = ty) ) ;
865866 for field in s. fields ( ) {
866867 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 ,
869870 ast:: UnnamedField ( ..) => panic ! ( "no tuple structs in FFI" ) ,
870871 } ;
871872 let name = name. to_string ( ) ;
@@ -1086,11 +1087,11 @@ impl<'a> Generator<'a> {
10861087
10871088 fn ty2name ( & self , ty : & ast:: Ty , rust : bool ) -> String {
10881089 match ty. node {
1089- ast:: TyPath ( _, ref path) => {
1090+ ast:: TyKind :: Path ( _, ref path) => {
10901091 let last = path. segments . last ( ) . unwrap ( ) ;
10911092 if last. identifier . to_string ( ) == "Option" {
10921093 match last. parameters {
1093- ast:: AngleBracketedParameters ( ref p) => {
1094+ ast:: PathParameters :: AngleBracketed ( ref p) => {
10941095 self . ty2name ( & p. types [ 0 ] , rust)
10951096 }
10961097 _ => panic ! ( ) ,
@@ -1101,20 +1102,20 @@ impl<'a> Generator<'a> {
11011102 self . rust2c ( & last. identifier . to_string ( ) )
11021103 }
11031104 }
1104- ast:: TyPtr ( ref t) => {
1105+ ast:: TyKind :: Ptr ( ref t) => {
11051106 if rust {
11061107 format ! ( "*{} {}" , match t. mutbl {
1107- ast:: MutImmutable => "const" ,
1108- ast:: MutMutable => "mut" ,
1108+ ast:: Mutability :: Immutable => "const" ,
1109+ ast:: Mutability :: Mutable => "mut" ,
11091110 } , self . ty2name( & t. ty, rust) )
11101111 } else {
11111112 let modifier = match t. mutbl {
1112- ast:: MutImmutable => "const " ,
1113- ast:: MutMutable => "" ,
1113+ ast:: Mutability :: Immutable => "const " ,
1114+ ast:: Mutability :: Mutable => "" ,
11141115 } ;
11151116 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 ( ..) => {
11181119 format ! ( "{} {}*" , self . ty2name( & t. ty, rust) ,
11191120 modifier)
11201121 }
@@ -1124,15 +1125,15 @@ impl<'a> Generator<'a> {
11241125 }
11251126 }
11261127 }
1127- ast:: TyBareFn ( ref t) => {
1128+ ast:: TyKind :: BareFn ( ref t) => {
11281129 if rust {
11291130 let args = t. decl . inputs . iter ( ) . map ( |a| {
11301131 self . ty2name ( & a. ty , rust)
11311132 } ) . collect :: < Vec < _ > > ( ) . connect ( ", " ) ;
11321133 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) ,
11361137 } ;
11371138 format ! ( "extern fn({}) -> {}" , args, ret)
11381139 } else {
@@ -1145,7 +1146,7 @@ impl<'a> Generator<'a> {
11451146 format ! ( "{}(*)({})" , ret, args. connect( ", " ) )
11461147 }
11471148 }
1148- ast:: TyFixedLengthVec ( ref t, ref e) => {
1149+ ast:: TyKind :: FixedLengthVec ( ref t, ref e) => {
11491150 assert ! ( rust) ;
11501151 format ! ( "[{}; {}]" , self . ty2name( t, rust) , self . expr2str( e) )
11511152 }
@@ -1155,18 +1156,18 @@ impl<'a> Generator<'a> {
11551156
11561157 fn csig_returning_ptr ( & self , ty : & ast:: Ty , sig : & str ) -> String {
11571158 match ty. node {
1158- ast:: TyPath ( _, ref path) if path. segments . last ( ) . unwrap ( )
1159+ ast:: TyKind :: Path ( _, ref path) if path. segments . last ( ) . unwrap ( )
11591160 . identifier . to_string ( ) == "Option"
11601161 => {
11611162 let last = path. segments . last ( ) . unwrap ( ) ;
11621163 match last. parameters {
1163- ast:: AngleBracketedParameters ( ref p) => {
1164+ ast:: PathParameters :: AngleBracketed ( ref p) => {
11641165 self . csig_returning_ptr ( & p. types [ 0 ] , sig)
11651166 }
11661167 _ => panic ! ( ) ,
11671168 }
11681169 }
1169- ast:: TyBareFn ( ref t) => {
1170+ ast:: TyKind :: BareFn ( ref t) => {
11701171 assert ! ( t. lifetimes. len( ) == 0 ) ;
11711172 let ( ret, mut args, variadic) = self . decl2rust ( & t. decl ) ;
11721173 if variadic {
@@ -1176,7 +1177,7 @@ impl<'a> Generator<'a> {
11761177 }
11771178 format ! ( "{}(**{})({})" , ret, sig, args. connect( ", " ) )
11781179 }
1179- ast:: TyFixedLengthVec ( ref t, ref e) => {
1180+ ast:: TyKind :: FixedLengthVec ( ref t, ref e) => {
11801181 format ! ( "{}(*{})[{}]" , self . ty2name( t, false ) , sig,
11811182 self . expr2str( e) )
11821183 }
@@ -1186,16 +1187,16 @@ impl<'a> Generator<'a> {
11861187
11871188 fn expr2str ( & self , e : & ast:: Expr ) -> String {
11881189 match e. node {
1189- ast:: ExprLit ( ref l) => {
1190+ ast:: ExprKind :: Lit ( ref l) => {
11901191 match l. node {
1191- ast:: LitInt ( a, _) => a. to_string ( ) ,
1192+ ast:: LitKind :: Int ( a, _) => a. to_string ( ) ,
11921193 _ => panic ! ( "unknown literal: {:?}" , l) ,
11931194 }
11941195 }
1195- ast:: ExprPath ( _, ref path) => {
1196+ ast:: ExprKind :: Path ( _, ref path) => {
11961197 path. segments . last ( ) . unwrap ( ) . identifier . to_string ( )
11971198 }
1198- ast:: ExprCast ( ref e, _) => self . expr2str ( e) ,
1199+ ast:: ExprKind :: Cast ( ref e, _) => self . expr2str ( e) ,
11991200 _ => panic ! ( "unknown expr: {:?}" , e) ,
12001201 }
12011202 }
@@ -1205,9 +1206,9 @@ impl<'a> Generator<'a> {
12051206 self . ty2name ( & arg. ty , false )
12061207 } ) . collect :: < Vec < _ > > ( ) ;
12071208 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 ) ,
12111212 } ;
12121213 ( ret, args, decl. variadic )
12131214 }
@@ -1228,14 +1229,14 @@ impl<'a> Generator<'a> {
12281229impl < ' a , ' v > Visitor < ' v > for Generator < ' a > {
12291230 fn visit_item ( & mut self , i : & ' v ast:: Item ) {
12301231 let prev_abi = self . abi ;
1231- let public = i. vis == ast:: Public ;
1232+ let public = i. vis == ast:: Visibility :: Public ;
12321233 match i. node {
1233- ast:: ItemTy ( _, ref generics) if public => {
1234+ ast:: ItemKind :: Ty ( _, ref generics) if public => {
12341235 self . assert_no_generics ( i. ident , generics) ;
12351236 self . test_type ( & i. ident . to_string ( ) ) ;
12361237 }
12371238
1238- ast:: ItemStruct ( ref s, ref generics) if public => {
1239+ ast:: ItemKind :: Struct ( ref s, ref generics) if public => {
12391240 self . assert_no_generics ( i. ident , generics) ;
12401241 let is_c = i. attrs . iter ( ) . any ( |a| {
12411242 attr:: find_repr_attrs ( self . sh , a) . iter ( ) . any ( |a| {
@@ -1248,12 +1249,12 @@ impl<'a, 'v> Visitor<'v> for Generator<'a> {
12481249 self . test_struct ( & i. ident . to_string ( ) , s) ;
12491250 }
12501251
1251- ast:: ItemConst ( ref ty, _) if public => {
1252+ ast:: ItemKind :: Const ( ref ty, _) if public => {
12521253 let ty = self . ty2name ( ty, true ) ;
12531254 self . test_const ( & i. ident . to_string ( ) , & ty) ;
12541255 }
12551256
1256- ast:: ItemForeignMod ( ref fm) if public => {
1257+ ast:: ItemKind :: ForeignMod ( ref fm) if public => {
12571258 self . abi = fm. abi ;
12581259 }
12591260
@@ -1269,7 +1270,7 @@ impl<'a, 'v> Visitor<'v> for Generator<'a> {
12691270
12701271 fn visit_foreign_item ( & mut self , i : & ' v ast:: ForeignItem ) {
12711272 match i. node {
1272- ast:: ForeignItemFn ( ref decl, ref generics) => {
1273+ ast:: ForeignItemKind :: Fn ( ref decl, ref generics) => {
12731274 self . assert_no_generics ( i. ident , generics) ;
12741275 let ( ret, args, variadic) = self . decl2rust ( decl) ;
12751276 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> {
12781279 self . test_extern_fn ( & i. ident . to_string ( ) , cname, & args, & ret,
12791280 variadic, abi) ;
12801281 }
1281- ast:: ForeignItemStatic ( _, _) => {
1282+ ast:: ForeignItemKind :: Static ( _, _) => {
12821283 }
12831284 }
12841285 visit:: walk_foreign_item ( self , i)
@@ -1290,10 +1291,10 @@ impl<'a, 'v> Visitor<'v> for Generator<'a> {
12901291impl < ' v > Visitor < ' v > for StructFinder {
12911292 fn visit_item ( & mut self , i : & ' v ast:: Item ) {
12921293 match i. node {
1293- ast:: ItemStruct ( ..) => {
1294+ ast:: ItemKind :: Struct ( ..) => {
12941295 self . structs . insert ( i. ident . to_string ( ) ) ;
12951296 }
1296- ast:: ItemEnum ( ..) => {
1297+ ast:: ItemKind :: Enum ( ..) => {
12971298 self . structs . insert ( i. ident . to_string ( ) ) ;
12981299 }
12991300
0 commit comments