aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_mbe/src/mbe_expander.rs4
-rw-r--r--crates/ra_mbe/src/mbe_parser.rs2
-rw-r--r--crates/ra_mbe/src/tests.rs140
3 files changed, 73 insertions, 73 deletions
diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs
index 7fff8deff..a0bd0c5f8 100644
--- a/crates/ra_mbe/src/mbe_expander.rs
+++ b/crates/ra_mbe/src/mbe_expander.rs
@@ -597,7 +597,7 @@ mod tests {
597 } 597 }
598 598
599 fn create_rules(macro_definition: &str) -> crate::MacroRules { 599 fn create_rules(macro_definition: &str) -> crate::MacroRules {
600 let source_file = ast::SourceFile::parse(macro_definition); 600 let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap();
601 let macro_definition = 601 let macro_definition =
602 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 602 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
603 603
@@ -609,7 +609,7 @@ mod tests {
609 rules: &crate::MacroRules, 609 rules: &crate::MacroRules,
610 invocation: &str, 610 invocation: &str,
611 ) -> Result<tt::Subtree, ExpandError> { 611 ) -> Result<tt::Subtree, ExpandError> {
612 let source_file = ast::SourceFile::parse(invocation); 612 let source_file = ast::SourceFile::parse(invocation).ok().unwrap();
613 let macro_invocation = 613 let macro_invocation =
614 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 614 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
615 615
diff --git a/crates/ra_mbe/src/mbe_parser.rs b/crates/ra_mbe/src/mbe_parser.rs
index 797c70bc7..d8fe293c7 100644
--- a/crates/ra_mbe/src/mbe_parser.rs
+++ b/crates/ra_mbe/src/mbe_parser.rs
@@ -175,7 +175,7 @@ mod tests {
175 } 175 }
176 176
177 fn create_rules(macro_definition: &str) -> Result<crate::MacroRules, ParseError> { 177 fn create_rules(macro_definition: &str) -> Result<crate::MacroRules, ParseError> {
178 let source_file = ast::SourceFile::parse(macro_definition); 178 let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap();
179 let macro_definition = 179 let macro_definition =
180 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 180 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
181 181
diff --git a/crates/ra_mbe/src/tests.rs b/crates/ra_mbe/src/tests.rs
index e3a5ceecf..5e4017f77 100644
--- a/crates/ra_mbe/src/tests.rs
+++ b/crates/ra_mbe/src/tests.rs
@@ -29,11 +29,11 @@ macro_rules! impl_froms {
29impl_froms!(TokenTree: Leaf, Subtree); 29impl_froms!(TokenTree: Leaf, Subtree);
30"#; 30"#;
31 31
32 let source_file = ast::SourceFile::parse(macro_definition); 32 let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap();
33 let macro_definition = 33 let macro_definition =
34 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 34 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
35 35
36 let source_file = ast::SourceFile::parse(macro_invocation); 36 let source_file = ast::SourceFile::parse(macro_invocation).ok().unwrap();
37 let macro_invocation = 37 let macro_invocation =
38 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 38 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
39 39
@@ -49,7 +49,7 @@ impl_froms!(TokenTree: Leaf, Subtree);
49} 49}
50 50
51pub(crate) fn create_rules(macro_definition: &str) -> MacroRules { 51pub(crate) fn create_rules(macro_definition: &str) -> MacroRules {
52 let source_file = ast::SourceFile::parse(macro_definition); 52 let source_file = ast::SourceFile::parse(macro_definition).ok().unwrap();
53 let macro_definition = 53 let macro_definition =
54 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 54 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
55 55
@@ -58,7 +58,7 @@ pub(crate) fn create_rules(macro_definition: &str) -> MacroRules {
58} 58}
59 59
60pub(crate) fn expand(rules: &MacroRules, invocation: &str) -> tt::Subtree { 60pub(crate) fn expand(rules: &MacroRules, invocation: &str) -> tt::Subtree {
61 let source_file = ast::SourceFile::parse(invocation); 61 let source_file = ast::SourceFile::parse(invocation).ok().unwrap();
62 let macro_invocation = 62 let macro_invocation =
63 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap(); 63 source_file.syntax().descendants().find_map(ast::MacroCall::cast).unwrap();
64 64
@@ -95,7 +95,7 @@ pub(crate) fn expand_to_expr(
95pub(crate) fn text_to_tokentree(text: &str) -> tt::Subtree { 95pub(crate) fn text_to_tokentree(text: &str) -> tt::Subtree {
96 // wrap the given text to a macro call 96 // wrap the given text to a macro call
97 let wrapped = format!("wrap_macro!( {} )", text); 97 let wrapped = format!("wrap_macro!( {} )", text);
98 let wrapped = ast::SourceFile::parse(&wrapped); 98 let wrapped = ast::SourceFile::parse(&wrapped).ok().unwrap();
99 let wrapped = wrapped.syntax().descendants().find_map(ast::TokenTree::cast).unwrap(); 99 let wrapped = wrapped.syntax().descendants().find_map(ast::TokenTree::cast).unwrap();
100 let mut wrapped = ast_to_token_tree(wrapped).unwrap().0; 100 let mut wrapped = ast_to_token_tree(wrapped).unwrap().0;
101 wrapped.delimiter = tt::Delimiter::None; 101 wrapped.delimiter = tt::Delimiter::None;
@@ -294,7 +294,7 @@ fn test_match_group_pattern_with_multiple_defs() {
294 macro_rules! foo { 294 macro_rules! foo {
295 ($ ($ i:ident),*) => ( struct Bar { $ ( 295 ($ ($ i:ident),*) => ( struct Bar { $ (
296 fn $ i {} 296 fn $ i {}
297 )*} ); 297 )*} );
298 } 298 }
299"#, 299"#,
300 ); 300 );
@@ -314,7 +314,7 @@ fn test_match_group_pattern_with_multiple_statement() {
314 macro_rules! foo { 314 macro_rules! foo {
315 ($ ($ i:ident),*) => ( fn baz { $ ( 315 ($ ($ i:ident),*) => ( fn baz { $ (
316 $ i (); 316 $ i ();
317 )*} ); 317 )*} );
318 } 318 }
319"#, 319"#,
320 ); 320 );
@@ -329,7 +329,7 @@ fn test_match_group_pattern_with_multiple_statement_without_semi() {
329 macro_rules! foo { 329 macro_rules! foo {
330 ($ ($ i:ident),*) => ( fn baz { $ ( 330 ($ ($ i:ident),*) => ( fn baz { $ (
331 $i() 331 $i()
332 );*} ); 332 );*} );
333 } 333 }
334"#, 334"#,
335 ); 335 );
@@ -344,7 +344,7 @@ fn test_match_group_empty_fixed_token() {
344 macro_rules! foo { 344 macro_rules! foo {
345 ($ ($ i:ident)* #abc) => ( fn baz { $ ( 345 ($ ($ i:ident)* #abc) => ( fn baz { $ (
346 $ i (); 346 $ i ();
347 )*} ); 347 )*} );
348 } 348 }
349"#, 349"#,
350 ); 350 );
@@ -356,10 +356,10 @@ fn test_match_group_empty_fixed_token() {
356fn test_match_group_in_subtree() { 356fn test_match_group_in_subtree() {
357 let rules = create_rules( 357 let rules = create_rules(
358 r#" 358 r#"
359 macro_rules! foo { 359 macro_rules! foo {
360 (fn $name:ident {$($i:ident)*} ) => ( fn $name() { $ ( 360 (fn $name:ident {$($i:ident)*} ) => ( fn $name() { $ (
361 $ i (); 361 $ i ();
362 )*} ); 362 )*} );
363 }"#, 363 }"#,
364 ); 364 );
365 365
@@ -370,8 +370,8 @@ fn test_match_group_in_subtree() {
370fn test_match_group_with_multichar_sep() { 370fn test_match_group_with_multichar_sep() {
371 let rules = create_rules( 371 let rules = create_rules(
372 r#" 372 r#"
373 macro_rules! foo { 373 macro_rules! foo {
374 (fn $name:ident {$($i:literal)*} ) => ( fn $name() -> bool { $($i)&&*} ); 374 (fn $name:ident {$($i:literal)*} ) => ( fn $name() -> bool { $($i)&&*} );
375 }"#, 375 }"#,
376 ); 376 );
377 377
@@ -387,8 +387,8 @@ fn test_match_group_with_multichar_sep() {
387fn test_match_group_zero_match() { 387fn test_match_group_zero_match() {
388 let rules = create_rules( 388 let rules = create_rules(
389 r#" 389 r#"
390 macro_rules! foo { 390 macro_rules! foo {
391 ( $($i:ident)* ) => (); 391 ( $($i:ident)* ) => ();
392 }"#, 392 }"#,
393 ); 393 );
394 394
@@ -399,7 +399,7 @@ fn test_match_group_zero_match() {
399fn test_match_group_in_group() { 399fn test_match_group_in_group() {
400 let rules = create_rules( 400 let rules = create_rules(
401 r#" 401 r#"
402 macro_rules! foo { 402 macro_rules! foo {
403 { $( ( $($i:ident)* ) )* } => ( $( ( $($i)* ) )* ); 403 { $( ( $($i:ident)* ) )* } => ( $( ( $($i)* ) )* );
404 }"#, 404 }"#,
405 ); 405 );
@@ -651,7 +651,7 @@ fn test_expr() {
651 r#" 651 r#"
652 macro_rules! foo { 652 macro_rules! foo {
653 ($ i:expr) => { 653 ($ i:expr) => {
654 fn bar() { $ i; } 654 fn bar() { $ i; }
655 } 655 }
656 } 656 }
657"#, 657"#,
@@ -671,7 +671,7 @@ fn test_expr_order() {
671 r#" 671 r#"
672 macro_rules! foo { 672 macro_rules! foo {
673 ($ i:expr) => { 673 ($ i:expr) => {
674 fn bar() { $ i * 2; } 674 fn bar() { $ i * 2; }
675 } 675 }
676 } 676 }
677"#, 677"#,
@@ -896,9 +896,9 @@ fn test_meta_doc_comments() {
896 assert_expansion( 896 assert_expansion(
897 MacroKind::Items, 897 MacroKind::Items,
898 &rules, 898 &rules,
899 r#"foo! { 899 r#"foo! {
900 /// Single Line Doc 1 900 /// Single Line Doc 1
901 /** 901 /**
902 MultiLines Doc 902 MultiLines Doc
903 */ 903 */
904 }"#, 904 }"#,
@@ -984,7 +984,7 @@ macro_rules! foo {
984 bar!($a); 984 bar!($a);
985 fn $b() -> u8 {$c} 985 fn $b() -> u8 {$c}
986 } 986 }
987} 987}
988"#, 988"#,
989 ); 989 );
990 assert_expansion( 990 assert_expansion(
@@ -1119,7 +1119,7 @@ macro_rules! STRUCT {
1119 // from https://github.com/retep998/winapi-rs/blob/a7ef2bca086aae76cf6c4ce4c2552988ed9798ad/src/shared/d3d9caps.rs 1119 // from https://github.com/retep998/winapi-rs/blob/a7ef2bca086aae76cf6c4ce4c2552988ed9798ad/src/shared/d3d9caps.rs
1120 assert_expansion(MacroKind::Items, &rules, r#"STRUCT!{struct D3DVSHADERCAPS2_0 {Caps: u8,}}"#, 1120 assert_expansion(MacroKind::Items, &rules, r#"STRUCT!{struct D3DVSHADERCAPS2_0 {Caps: u8,}}"#,
1121 "# [repr (C)] # [derive (Copy)] pub struct D3DVSHADERCAPS2_0 {pub Caps : u8 ,} impl Clone for D3DVSHADERCAPS2_0 {# [inline] fn clone (& self) -> D3DVSHADERCAPS2_0 {* self}} # [cfg (feature = \"impl-default\")] impl Default for D3DVSHADERCAPS2_0 {# [inline] fn default () -> D3DVSHADERCAPS2_0 {unsafe {$crate :: _core :: mem :: zeroed ()}}}"); 1121 "# [repr (C)] # [derive (Copy)] pub struct D3DVSHADERCAPS2_0 {pub Caps : u8 ,} impl Clone for D3DVSHADERCAPS2_0 {# [inline] fn clone (& self) -> D3DVSHADERCAPS2_0 {* self}} # [cfg (feature = \"impl-default\")] impl Default for D3DVSHADERCAPS2_0 {# [inline] fn default () -> D3DVSHADERCAPS2_0 {unsafe {$crate :: _core :: mem :: zeroed ()}}}");
1122 assert_expansion(MacroKind::Items, &rules, r#"STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct D3DCONTENTPROTECTIONCAPS {Caps : u8 ,}}"#, 1122 assert_expansion(MacroKind::Items, &rules, r#"STRUCT!{#[cfg_attr(target_arch = "x86", repr(packed))] struct D3DCONTENTPROTECTIONCAPS {Caps : u8 ,}}"#,
1123 "# [repr (C)] # [derive (Copy)] # [cfg_attr (target_arch = \"x86\" , repr (packed))] pub struct D3DCONTENTPROTECTIONCAPS {pub Caps : u8 ,} impl Clone for D3DCONTENTPROTECTIONCAPS {# [inline] fn clone (& self) -> D3DCONTENTPROTECTIONCAPS {* self}} # [cfg (feature = \"impl-default\")] impl Default for D3DCONTENTPROTECTIONCAPS {# [inline] fn default () -> D3DCONTENTPROTECTIONCAPS {unsafe {$crate :: _core :: mem :: zeroed ()}}}"); 1123 "# [repr (C)] # [derive (Copy)] # [cfg_attr (target_arch = \"x86\" , repr (packed))] pub struct D3DCONTENTPROTECTIONCAPS {pub Caps : u8 ,} impl Clone for D3DCONTENTPROTECTIONCAPS {# [inline] fn clone (& self) -> D3DCONTENTPROTECTIONCAPS {* self}} # [cfg (feature = \"impl-default\")] impl Default for D3DCONTENTPROTECTIONCAPS {# [inline] fn default () -> D3DCONTENTPROTECTIONCAPS {unsafe {$crate :: _core :: mem :: zeroed ()}}}");
1124} 1124}
1125 1125
@@ -1136,11 +1136,11 @@ macro_rules! int_base {
1136 } 1136 }
1137 } 1137 }
1138 } 1138 }
1139} 1139}
1140"#, 1140"#,
1141 ); 1141 );
1142 1142
1143 assert_expansion(MacroKind::Items, &rules, r#" int_base!{Binary for isize as usize -> Binary}"#, 1143 assert_expansion(MacroKind::Items, &rules, r#" int_base!{Binary for isize as usize -> Binary}"#,
1144 "# [stable (feature = \"rust1\" , since = \"1.0.0\")] impl fmt ::Binary for isize {fn fmt (& self , f : & mut fmt :: Formatter < \'_ >) -> fmt :: Result {Binary . fmt_int (* self as usize , f)}}" 1144 "# [stable (feature = \"rust1\" , since = \"1.0.0\")] impl fmt ::Binary for isize {fn fmt (& self , f : & mut fmt :: Formatter < \'_ >) -> fmt :: Result {Binary . fmt_int (* self as usize , f)}}"
1145 ); 1145 );
1146} 1146}
@@ -1150,7 +1150,7 @@ fn test_generate_pattern_iterators() {
1150 // from https://github.com/rust-lang/rust/blob/316a391dcb7d66dc25f1f9a4ec9d368ef7615005/src/libcore/str/mod.rs 1150 // from https://github.com/rust-lang/rust/blob/316a391dcb7d66dc25f1f9a4ec9d368ef7615005/src/libcore/str/mod.rs
1151 let rules = create_rules( 1151 let rules = create_rules(
1152 r#" 1152 r#"
1153macro_rules! generate_pattern_iterators { 1153macro_rules! generate_pattern_iterators {
1154 { double ended; with $(#[$common_stability_attribute:meta])*, 1154 { double ended; with $(#[$common_stability_attribute:meta])*,
1155 $forward_iterator:ident, 1155 $forward_iterator:ident,
1156 $reverse_iterator:ident, $iterty:ty 1156 $reverse_iterator:ident, $iterty:ty
@@ -1161,7 +1161,7 @@ macro_rules! generate_pattern_iterators {
1161"#, 1161"#,
1162 ); 1162 );
1163 1163
1164 assert_expansion(MacroKind::Items, &rules, r#"generate_pattern_iterators ! ( double ended ; with # [ stable ( feature = "rust1" , since = "1.0.0" ) ] , Split , RSplit , & 'a str )"#, 1164 assert_expansion(MacroKind::Items, &rules, r#"generate_pattern_iterators ! ( double ended ; with # [ stable ( feature = "rust1" , since = "1.0.0" ) ] , Split , RSplit , & 'a str )"#,
1165 "fn foo () {}"); 1165 "fn foo () {}");
1166} 1166}
1167 1167
@@ -1170,7 +1170,7 @@ fn test_impl_fn_for_zst() {
1170 // from https://github.com/rust-lang/rust/blob/5d20ff4d2718c820632b38c1e49d4de648a9810b/src/libcore/internal_macros.rs 1170 // from https://github.com/rust-lang/rust/blob/5d20ff4d2718c820632b38c1e49d4de648a9810b/src/libcore/internal_macros.rs
1171 let rules = create_rules( 1171 let rules = create_rules(
1172 r#" 1172 r#"
1173macro_rules! impl_fn_for_zst { 1173macro_rules! impl_fn_for_zst {
1174 { $( $( #[$attr: meta] )* 1174 { $( $( #[$attr: meta] )*
1175 struct $Name: ident impl$( <$( $lifetime : lifetime ),+> )? Fn = 1175 struct $Name: ident impl$( <$( $lifetime : lifetime ),+> )? Fn =
1176 |$( $arg: ident: $ArgTy: ty ),*| -> $ReturnTy: ty 1176 |$( $arg: ident: $ArgTy: ty ),*| -> $ReturnTy: ty
@@ -1213,22 +1213,22 @@ $body: block; )+
1213 ); 1213 );
1214 1214
1215 assert_expansion(MacroKind::Items, &rules, r#" 1215 assert_expansion(MacroKind::Items, &rules, r#"
1216impl_fn_for_zst ! { 1216impl_fn_for_zst ! {
1217 # [ derive ( Clone ) ] 1217 # [ derive ( Clone ) ]
1218 struct CharEscapeDebugContinue impl Fn = | c : char | -> char :: EscapeDebug { 1218 struct CharEscapeDebugContinue impl Fn = | c : char | -> char :: EscapeDebug {
1219 c . escape_debug_ext ( false ) 1219 c . escape_debug_ext ( false )
1220 } ; 1220 } ;
1221 1221
1222 # [ derive ( Clone ) ] 1222 # [ derive ( Clone ) ]
1223 struct CharEscapeUnicode impl Fn = | c : char | -> char :: EscapeUnicode { 1223 struct CharEscapeUnicode impl Fn = | c : char | -> char :: EscapeUnicode {
1224 c . escape_unicode ( ) 1224 c . escape_unicode ( )
1225 } ; 1225 } ;
1226 # [ derive ( Clone ) ] 1226 # [ derive ( Clone ) ]
1227 struct CharEscapeDefault impl Fn = | c : char | -> char :: EscapeDefault { 1227 struct CharEscapeDefault impl Fn = | c : char | -> char :: EscapeDefault {
1228 c . escape_default ( ) 1228 c . escape_default ( )
1229 } ; 1229 } ;
1230 } 1230 }
1231"#, 1231"#,
1232 "# [derive (Clone)] struct CharEscapeDebugContinue ; impl Fn < (char ,) > for CharEscapeDebugContinue {# [inline] extern \"rust-call\" fn call (& self , (c ,) : (char ,)) -> char :: EscapeDebug {{c . escape_debug_ext (false)}}} impl FnMut < (char ,) > for CharEscapeDebugContinue {# [inline] extern \"rust-call\" fn call_mut (& mut self , (c ,) : (char ,)) -> char :: EscapeDebug {Fn :: call (&* self , (c ,))}} impl FnOnce < (char ,) > for CharEscapeDebugContinue {type Output = char :: EscapeDebug ; # [inline] extern \"rust-call\" fn call_once (self , (c ,) : (char ,)) -> char :: EscapeDebug {Fn :: call (& self , (c ,))}} # [derive (Clone)] struct CharEscapeUnicode ; impl Fn < (char ,) > for CharEscapeUnicode {# [inline] extern \"rust-call\" fn call (& self , (c ,) : (char ,)) -> char :: EscapeUnicode {{c . escape_unicode ()}}} impl FnMut < (char ,) > for CharEscapeUnicode {# [inline] extern \"rust-call\" fn call_mut (& mut self , (c ,) : (char ,)) -> char :: EscapeUnicode {Fn :: call (&* self , (c ,))}} impl FnOnce < (char ,) > for CharEscapeUnicode {type Output = char :: EscapeUnicode ; # [inline] extern \"rust-call\" fn call_once (self , (c ,) : (char ,)) -> char :: EscapeUnicode {Fn :: call (& self , (c ,))}} # [derive (Clone)] struct CharEscapeDefault ; impl Fn < (char ,) > for CharEscapeDefault {# [inline] extern \"rust-call\" fn call (& self , (c ,) : (char ,)) -> char :: EscapeDefault {{c . escape_default ()}}} impl FnMut < (char ,) > for CharEscapeDefault {# [inline] extern \"rust-call\" fn call_mut (& mut self , (c ,) : (char ,)) -> char :: EscapeDefault {Fn :: call (&* self , (c ,))}} impl FnOnce < (char ,) > for CharEscapeDefault {type Output = char :: EscapeDefault ; # [inline] extern \"rust-call\" fn call_once (self , (c ,) : (char ,)) -> char :: EscapeDefault {Fn :: call (& self , (c ,))}}"); 1232 "# [derive (Clone)] struct CharEscapeDebugContinue ; impl Fn < (char ,) > for CharEscapeDebugContinue {# [inline] extern \"rust-call\" fn call (& self , (c ,) : (char ,)) -> char :: EscapeDebug {{c . escape_debug_ext (false)}}} impl FnMut < (char ,) > for CharEscapeDebugContinue {# [inline] extern \"rust-call\" fn call_mut (& mut self , (c ,) : (char ,)) -> char :: EscapeDebug {Fn :: call (&* self , (c ,))}} impl FnOnce < (char ,) > for CharEscapeDebugContinue {type Output = char :: EscapeDebug ; # [inline] extern \"rust-call\" fn call_once (self , (c ,) : (char ,)) -> char :: EscapeDebug {Fn :: call (& self , (c ,))}} # [derive (Clone)] struct CharEscapeUnicode ; impl Fn < (char ,) > for CharEscapeUnicode {# [inline] extern \"rust-call\" fn call (& self , (c ,) : (char ,)) -> char :: EscapeUnicode {{c . escape_unicode ()}}} impl FnMut < (char ,) > for CharEscapeUnicode {# [inline] extern \"rust-call\" fn call_mut (& mut self , (c ,) : (char ,)) -> char :: EscapeUnicode {Fn :: call (&* self , (c ,))}} impl FnOnce < (char ,) > for CharEscapeUnicode {type Output = char :: EscapeUnicode ; # [inline] extern \"rust-call\" fn call_once (self , (c ,) : (char ,)) -> char :: EscapeUnicode {Fn :: call (& self , (c ,))}} # [derive (Clone)] struct CharEscapeDefault ; impl Fn < (char ,) > for CharEscapeDefault {# [inline] extern \"rust-call\" fn call (& self , (c ,) : (char ,)) -> char :: EscapeDefault {{c . escape_default ()}}} impl FnMut < (char ,) > for CharEscapeDefault {# [inline] extern \"rust-call\" fn call_mut (& mut self , (c ,) : (char ,)) -> char :: EscapeDefault {Fn :: call (&* self , (c ,))}} impl FnOnce < (char ,) > for CharEscapeDefault {type Output = char :: EscapeDefault ; # [inline] extern \"rust-call\" fn call_once (self , (c ,) : (char ,)) -> char :: EscapeDefault {Fn :: call (& self , (c ,))}}");
1233} 1233}
1234 1234
@@ -1263,7 +1263,7 @@ fn test_cfg_if_items() {
1263"#, 1263"#,
1264 ); 1264 );
1265 1265
1266 assert_expansion(MacroKind::Items, &rules, r#"__cfg_if_items ! { ( rustdoc , ) ; ( ( ) ( # [ cfg ( any ( target_os = "redox" , unix ) ) ] # [ stable ( feature = "rust1" , since = "1.0.0" ) ] pub use sys :: ext as unix ; # [ cfg ( windows ) ] # [ stable ( feature = "rust1" , since = "1.0.0" ) ] pub use sys :: ext as windows ; # [ cfg ( any ( target_os = "linux" , target_os = "l4re" ) ) ] pub mod linux ; ) ) , }"#, 1266 assert_expansion(MacroKind::Items, &rules, r#"__cfg_if_items ! { ( rustdoc , ) ; ( ( ) ( # [ cfg ( any ( target_os = "redox" , unix ) ) ] # [ stable ( feature = "rust1" , since = "1.0.0" ) ] pub use sys :: ext as unix ; # [ cfg ( windows ) ] # [ stable ( feature = "rust1" , since = "1.0.0" ) ] pub use sys :: ext as windows ; # [ cfg ( any ( target_os = "linux" , target_os = "l4re" ) ) ] pub mod linux ; ) ) , }"#,
1267 "__cfg_if_items ! {(rustdoc ,) ;}"); 1267 "__cfg_if_items ! {(rustdoc ,) ;}");
1268} 1268}
1269 1269
@@ -1294,23 +1294,23 @@ fn test_cfg_if_main() {
1294 ); 1294 );
1295 1295
1296 assert_expansion(MacroKind::Items, &rules, r#" 1296 assert_expansion(MacroKind::Items, &rules, r#"
1297cfg_if ! { 1297cfg_if ! {
1298 if # [ cfg ( target_env = "msvc" ) ] { 1298 if # [ cfg ( target_env = "msvc" ) ] {
1299 // no extra unwinder support needed 1299 // no extra unwinder support needed
1300 } else if # [ cfg ( all ( target_arch = "wasm32" , not ( target_os = "emscripten" ) ) ) ] { 1300 } else if # [ cfg ( all ( target_arch = "wasm32" , not ( target_os = "emscripten" ) ) ) ] {
1301 // no unwinder on the system! 1301 // no unwinder on the system!
1302 } else { 1302 } else {
1303 mod libunwind ; 1303 mod libunwind ;
1304 pub use libunwind :: * ; 1304 pub use libunwind :: * ;
1305 } 1305 }
1306 } 1306 }
1307"#, 1307"#,
1308 "__cfg_if_items ! {() ; ((target_env = \"msvc\") ()) , ((all (target_arch = \"wasm32\" , not (target_os = \"emscripten\"))) ()) , (() (mod libunwind ; pub use libunwind :: * ;)) ,}"); 1308 "__cfg_if_items ! {() ; ((target_env = \"msvc\") ()) , ((all (target_arch = \"wasm32\" , not (target_os = \"emscripten\"))) ()) , (() (mod libunwind ; pub use libunwind :: * ;)) ,}");
1309 1309
1310 assert_expansion(MacroKind::Items, &rules, r#" 1310 assert_expansion(MacroKind::Items, &rules, r#"
1311cfg_if ! { @ __apply cfg ( all ( not ( any ( not ( any ( target_os = "solaris" , target_os = "illumos" ) ) ) ) ) ) , } 1311cfg_if ! { @ __apply cfg ( all ( not ( any ( not ( any ( target_os = "solaris" , target_os = "illumos" ) ) ) ) ) ) , }
1312"#, 1312"#,
1313 "" 1313 ""
1314 ); 1314 );
1315} 1315}
1316 1316
@@ -1329,16 +1329,16 @@ macro_rules! arbitrary {
1329 $logic 1329 $logic
1330 } 1330 }
1331 } 1331 }
1332 }; 1332 };
1333 1333
1334}"#, 1334}"#,
1335 ); 1335 );
1336 1336
1337 assert_expansion(MacroKind::Items, &rules, r#"arbitrary ! ( [ A : Arbitrary ] 1337 assert_expansion(MacroKind::Items, &rules, r#"arbitrary ! ( [ A : Arbitrary ]
1338 Vec < A > , 1338 Vec < A > ,
1339 VecStrategy < A :: Strategy > , 1339 VecStrategy < A :: Strategy > ,
1340 RangedParams1 < A :: Parameters > ; 1340 RangedParams1 < A :: Parameters > ;
1341 args => { let product_unpack ! [ range , a ] = args ; vec ( any_with :: < A > ( a ) , range ) } 1341 args => { let product_unpack ! [ range , a ] = args ; vec ( any_with :: < A > ( a ) , range ) }
1342 ) ;"#, 1342 ) ;"#,
1343 "impl <A : Arbitrary > $crate :: arbitrary :: Arbitrary for Vec < A > {type Parameters = RangedParams1 < A :: Parameters > ; type Strategy = VecStrategy < A :: Strategy > ; fn arbitrary_with (args : Self :: Parameters) -> Self :: Strategy {{let product_unpack ! [range , a] = args ; vec (any_with :: < A > (a) , range)}}}"); 1343 "impl <A : Arbitrary > $crate :: arbitrary :: Arbitrary for Vec < A > {type Parameters = RangedParams1 < A :: Parameters > ; type Strategy = VecStrategy < A :: Strategy > ; fn arbitrary_with (args : Self :: Parameters) -> Self :: Strategy {{let product_unpack ! [range , a] = args ; vec (any_with :: < A > (a) , range)}}}");
1344} 1344}
@@ -1350,7 +1350,7 @@ fn test_old_ridl() {
1350 let rules = create_rules( 1350 let rules = create_rules(
1351 r#" 1351 r#"
1352#[macro_export] 1352#[macro_export]
1353macro_rules! RIDL { 1353macro_rules! RIDL {
1354 (interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident) 1354 (interface $interface:ident ($vtbl:ident) : $pinterface:ident ($pvtbl:ident)
1355 {$( 1355 {$(
1356 fn $method:ident(&mut self $(,$p:ident : $t:ty)*) -> $rtr:ty 1356 fn $method:ident(&mut self $(,$p:ident : $t:ty)*) -> $rtr:ty
@@ -1360,7 +1360,7 @@ macro_rules! RIDL {
1360 $(pub unsafe fn $method(&mut self) -> $rtr { 1360 $(pub unsafe fn $method(&mut self) -> $rtr {
1361 ((*self.lpVtbl).$method)(self $(,$p)*) 1361 ((*self.lpVtbl).$method)(self $(,$p)*)
1362 })+ 1362 })+
1363 } 1363 }
1364 }; 1364 };
1365}"#, 1365}"#,
1366 ); 1366 );
@@ -1388,11 +1388,11 @@ macro_rules! quick_error {
1388 quick_error!(ENUM_DEFINITION [enum $name $( #[$meta] )*] 1388 quick_error!(ENUM_DEFINITION [enum $name $( #[$meta] )*]
1389 body [] 1389 body []
1390 queue [$( 1390 queue [$(
1391 $( #[$imeta] )* 1391 $( #[$imeta] )*
1392 => 1392 =>
1393 $iitem: $imode [$( $ivar: $ityp ),*] 1393 $iitem: $imode [$( $ivar: $ityp ),*]
1394 )*] 1394 )*]
1395 ); 1395 );
1396}; 1396};
1397 1397
1398} 1398}
@@ -1403,7 +1403,7 @@ macro_rules! quick_error {
1403 &rules, 1403 &rules,
1404 r#" 1404 r#"
1405quick_error ! (SORT [enum Wrapped # [derive (Debug)]] items [ 1405quick_error ! (SORT [enum Wrapped # [derive (Debug)]] items [
1406 => One : UNIT [] {} 1406 => One : UNIT [] {}
1407 => Two : TUPLE [s :String] {display ("two: {}" , s) from ()} 1407 => Two : TUPLE [s :String] {display ("two: {}" , s) from ()}
1408 ] buf [] queue []) ; 1408 ] buf [] queue []) ;
1409"#, 1409"#,