@@ -975,8 +975,19 @@ fn new_span(cx: &ExtCtxt, sp: Span) -> Span {
975975}
976976
977977pub struct ExpansionConfig {
978- pub deriving_hash_type_parameter : bool ,
979978 pub crate_name : String ,
979+ pub deriving_hash_type_parameter : bool ,
980+ pub enable_quotes : bool ,
981+ }
982+
983+ impl ExpansionConfig {
984+ pub fn default ( crate_name : String ) -> ExpansionConfig {
985+ ExpansionConfig {
986+ crate_name : crate_name,
987+ deriving_hash_type_parameter : false ,
988+ enable_quotes : false ,
989+ }
990+ }
980991}
981992
982993pub struct ExportedMacros {
@@ -1106,7 +1117,7 @@ impl<'a, 'v> Visitor<'v> for MacroExterminator<'a> {
11061117#[ cfg( test) ]
11071118mod test {
11081119 use super :: { pattern_bindings, expand_crate, contains_macro_escape} ;
1109- use super :: { PatIdentFinder , IdentRenamer , PatIdentRenamer } ;
1120+ use super :: { PatIdentFinder , IdentRenamer , PatIdentRenamer , ExpansionConfig } ;
11101121 use ast;
11111122 use ast:: { Attribute_ , AttrOuter , MetaWord , Name } ;
11121123 use attr;
@@ -1171,6 +1182,10 @@ mod test {
11711182 // these following tests are quite fragile, in that they don't test what
11721183 // *kind* of failure occurs.
11731184
1185+ fn test_ecfg ( ) -> ExpansionConfig {
1186+ ExpansionConfig :: default ( "test" . to_string ( ) )
1187+ }
1188+
11741189 // make sure that macros can't escape fns
11751190 #[ should_fail]
11761191 #[ test] fn macros_cant_escape_fns_test ( ) {
@@ -1182,11 +1197,7 @@ mod test {
11821197 src,
11831198 Vec :: new ( ) , & sess) ;
11841199 // should fail:
1185- let cfg = :: syntax:: ext:: expand:: ExpansionConfig {
1186- deriving_hash_type_parameter : false ,
1187- crate_name : "test" . to_string ( ) ,
1188- } ;
1189- expand_crate ( & sess, cfg, vec ! ( ) , vec ! ( ) , crate_ast) ;
1200+ expand_crate ( & sess, test_ecfg ( ) , vec ! ( ) , vec ! ( ) , crate_ast) ;
11901201 }
11911202
11921203 // make sure that macros can't escape modules
@@ -1199,11 +1210,7 @@ mod test {
11991210 "<test>" . to_string ( ) ,
12001211 src,
12011212 Vec :: new ( ) , & sess) ;
1202- let cfg = :: syntax:: ext:: expand:: ExpansionConfig {
1203- deriving_hash_type_parameter : false ,
1204- crate_name : "test" . to_string ( ) ,
1205- } ;
1206- expand_crate ( & sess, cfg, vec ! ( ) , vec ! ( ) , crate_ast) ;
1213+ expand_crate ( & sess, test_ecfg ( ) , vec ! ( ) , vec ! ( ) , crate_ast) ;
12071214 }
12081215
12091216 // macro_escape modules should allow macros to escape
@@ -1215,11 +1222,7 @@ mod test {
12151222 "<test>" . to_string ( ) ,
12161223 src,
12171224 Vec :: new ( ) , & sess) ;
1218- let cfg = :: syntax:: ext:: expand:: ExpansionConfig {
1219- deriving_hash_type_parameter : false ,
1220- crate_name : "test" . to_string ( ) ,
1221- } ;
1222- expand_crate ( & sess, cfg, vec ! ( ) , vec ! ( ) , crate_ast) ;
1225+ expand_crate ( & sess, test_ecfg ( ) , vec ! ( ) , vec ! ( ) , crate_ast) ;
12231226 }
12241227
12251228 #[ test] fn test_contains_flatten ( ) {
@@ -1252,11 +1255,7 @@ mod test {
12521255 let ps = parse:: new_parse_sess ( ) ;
12531256 let crate_ast = string_to_parser ( & ps, crate_str) . parse_crate_mod ( ) ;
12541257 // the cfg argument actually does matter, here...
1255- let cfg = :: syntax:: ext:: expand:: ExpansionConfig {
1256- deriving_hash_type_parameter : false ,
1257- crate_name : "test" . to_string ( ) ,
1258- } ;
1259- expand_crate ( & ps, cfg, vec ! ( ) , vec ! ( ) , crate_ast)
1258+ expand_crate ( & ps, test_ecfg ( ) , vec ! ( ) , vec ! ( ) , crate_ast)
12601259 }
12611260
12621261 // find the pat_ident paths in a crate
0 commit comments