]> git.lizzy.rs Git - rust.git/blobdiff - tests/target/macros.rs
Fix static async closure qualifier order
[rust.git] / tests / target / macros.rs
index 8db2fbb60ee99ebbd74d77b3322dd738b13b6619..e930b5037d930f79873633881acce0468c0f5371 100644 (file)
@@ -1,4 +1,5 @@
 // rustfmt-normalize_comments: true
+// rustfmt-format_macro_matchers: true
 itemmacro!(this, is.now().formatted(yay));
 
 itemmacro!(
@@ -8,13 +9,13 @@
         .formatted()
 );
 
-itemmacro!{this, is.bracket().formatted()}
-
-peg_file! modname("mygrammarfile.rustpeg");
+itemmacro! {this, is.brace().formatted()}
 
 fn main() {
     foo!();
 
+    foo!(,);
+
     bar!(a, b, c);
 
     bar!(a, b, c,);
@@ -91,7 +92,7 @@ fn main() {
 
     foo(makro!(1, 3));
 
-    hamkaas!{ () };
+    hamkaas! { () };
 
     macrowithbraces! {dont,    format, me}
 
@@ -101,11 +102,11 @@ fn main() {
 
     some_macro![];
 
-    some_macro!{
+    some_macro! {
         // comment
     };
 
-    some_macro!{
+    some_macro! {
         // comment
     };
 
@@ -122,10 +123,14 @@ fn main() {
 
     // #1092
     chain!(input, a: take!(max_size), || []);
+
+    // #2727
+    foo!("bar");
 }
 
 impl X {
-    empty_invoc!{}
+    empty_invoc! {}
+    empty_invoc! {}
 }
 
 fn issue_1279() {
@@ -141,7 +146,7 @@ fn issue_1555() {
 
 fn issue1178() {
     macro_rules! foo {
-        (#[$attr: meta] $name: ident) => {};
+        (#[$attr:meta] $name:ident) => {};
     }
 
     foo!(
@@ -167,7 +172,8 @@ fn issue1739() {
         ..,
         init_size[1] - extreeeeeeeeeeeeeeeeeeeeeeeem..init_size[1],
         ..
-    ]).par_map_inplace(|el| *el = 0.);
+    ])
+    .par_map_inplace(|el| *el = 0.);
 }
 
 fn issue_1885() {
@@ -218,6 +224,18 @@ fn issue1577() {
     });
 }
 
+// #3174
+fn issue_3174() {
+    let data = if let Some(debug) = error.debug_info() {
+        json!({
+            "errorKind": format!("{:?}", error.err_kind()),
+            "debugMessage": debug.message,
+        })
+    } else {
+        json!({ "errorKind": format!("{:?}", error.err_kind()) })
+    };
+}
+
 gfx_pipeline!(pipe {
     vbuf: gfx::VertexBuffer<Vertex> = (),
     out: gfx::RenderTarget<ColorFormat> = "Target0",
@@ -246,7 +264,7 @@ fn __bindgen_test_layout_HandleWithDtor_open0_int_close0_instantiation() {
 
 // #878
 macro_rules! try_opt {
-    ($expr: expr) => {
+    ($expr:expr) => {
         match $expr {
             Some(val) => val,
 
@@ -891,7 +909,7 @@ fn macro_in_pattern_position() {
 
 macro foo() {}
 
-pub macro bar($x: ident + $y: expr;) {
+pub macro bar($x:ident + $y:expr;) {
     fn foo($x: Foo) {
         long_function(
             a_long_argument_to_a_long_function_is_what_this_is(AAAAAAAAAAAAAAAAAAAAAAAAAAAA),
@@ -908,6 +926,11 @@ fn foo() {
     }
 }
 
+// #2574
+macro_rules! test {
+    () => {{}};
+}
+
 macro lex_err($kind: ident $(, $body: expr)*) {
     Err(QlError::LexError(LexError::$kind($($body,)*)))
 }
@@ -915,3 +938,125 @@ fn foo() {
 // Preserve trailing comma on item-level macro with `()` or `[]`.
 methods![get, post, delete,];
 methods!(get, post, delete,);
+
+// #2588
+macro_rules! m {
+    () => {
+        r#"
+            test
+        "#
+    };
+}
+fn foo() {
+    f! {r#"
+            test
+       "#};
+}
+
+// #2591
+fn foo() {
+    match 0u32 {
+        0 => (),
+        _ => unreachable!(/* obviously */),
+    }
+}
+
+fn foo() {
+    let _ = column!(/* here */);
+}
+
+// #2616
+// Preserve trailing comma when using mixed layout for macro call.
+fn foo() {
+    foo!(
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
+    );
+    foo!(
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+    );
+}
+
+// #2830
+// Preserve trailing comma-less/ness inside nested macro.
+named!(
+    do_parse_gsv<GsvData>,
+    map_res!(
+        do_parse!(
+            number_of_sentences: map_res!(digit, parse_num::<u16>)
+                >> char!(',')
+                >> sentence_index: map_res!(digit, parse_num::<u16>)
+                >> char!(',')
+                >> total_number_of_sats: map_res!(digit, parse_num::<u16>)
+                >> char!(',')
+                >> sat0: opt!(complete!(parse_gsv_sat_info))
+                >> sat1: opt!(complete!(parse_gsv_sat_info))
+                >> sat2: opt!(complete!(parse_gsv_sat_info))
+                >> sat3: opt!(complete!(parse_gsv_sat_info))
+                >> (
+                    number_of_sentences,
+                    sentence_index,
+                    total_number_of_sats,
+                    sat0,
+                    sat1,
+                    sat2,
+                    sat3
+                )
+        ),
+        construct_gsv_data
+    )
+);
+
+// #2857
+convert_args!(vec!(1, 2, 3));
+
+// #3031
+thread_local!(
+    /// TLV Holds a set of JSTraceables that need to be rooted
+    static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> = RefCell::new(RootedTraceableSet::new());
+);
+
+thread_local![
+    /// TLV Holds a set of JSTraceables that need to be rooted
+    static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> = RefCell::new(RootedTraceableSet::new());
+
+    /// TLV Holds a set of JSTraceables that need to be rooted
+    static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> =
+        RefCell::new(RootedTraceableSet::new(0));
+
+    /// TLV Holds a set of JSTraceables that need to be rooted
+    static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> =
+        RefCell::new(RootedTraceableSet::new(), xxx, yyy);
+
+    /// TLV Holds a set of JSTraceables that need to be rooted
+    static ROOTED_TRACEABLES: RefCell<RootedTraceableSet> =
+        RefCell::new(RootedTraceableSet::new(1234));
+];
+
+fn issue3004() {
+    foo!(|_| { () });
+    stringify!((foo+));
+}
+
+// #3331
+pub fn fold_abi<V: Fold + ?Sized>(_visitor: &mut V, _i: Abi) -> Abi {
+    Abi {
+        extern_token: Token![extern](tokens_helper(_visitor, &_i.extern_token.span)),
+        name: (_i.name).map(|it| _visitor.fold_lit_str(it)),
+    }
+}
+
+// #3463
+x! {()}
+
+// #3746
+f!(match a {
+    4 => &[
+        (3, false), // Missing
+        (4, true)   // I-frame
+    ][..],
+});
+
+// #3583
+foo!(|x = y|);