@@ -34,7 +34,7 @@ macro_rules! panic {
34
34
#[ cfg_attr( not( test) , rustc_diagnostic_item = "assert_eq_macro" ) ]
35
35
#[ allow_internal_unstable( core_panic) ]
36
36
macro_rules! assert_eq {
37
- ( $left: expr, $right: expr $( , ) ?) => ( {
37
+ ( $left: expr, $right: expr $( , ) ?) => {
38
38
match ( & $left, & $right) {
39
39
( left_val, right_val) => {
40
40
if !( * left_val == * right_val) {
@@ -46,8 +46,8 @@ macro_rules! assert_eq {
46
46
}
47
47
}
48
48
}
49
- } ) ;
50
- ( $left: expr, $right: expr, $( $arg: tt) +) => ( {
49
+ } ;
50
+ ( $left: expr, $right: expr, $( $arg: tt) +) => {
51
51
match ( & $left, & $right) {
52
52
( left_val, right_val) => {
53
53
if !( * left_val == * right_val) {
@@ -59,7 +59,7 @@ macro_rules! assert_eq {
59
59
}
60
60
}
61
61
}
62
- } ) ;
62
+ } ;
63
63
}
64
64
65
65
/// Asserts that two expressions are not equal to each other (using [`PartialEq`]).
@@ -84,7 +84,7 @@ macro_rules! assert_eq {
84
84
#[ cfg_attr( not( test) , rustc_diagnostic_item = "assert_ne_macro" ) ]
85
85
#[ allow_internal_unstable( core_panic) ]
86
86
macro_rules! assert_ne {
87
- ( $left: expr, $right: expr $( , ) ?) => ( {
87
+ ( $left: expr, $right: expr $( , ) ?) => {
88
88
match ( & $left, & $right) {
89
89
( left_val, right_val) => {
90
90
if * left_val == * right_val {
@@ -96,8 +96,8 @@ macro_rules! assert_ne {
96
96
}
97
97
}
98
98
}
99
- } ) ;
100
- ( $left: expr, $right: expr, $( $arg: tt) +) => ( {
99
+ } ;
100
+ ( $left: expr, $right: expr, $( $arg: tt) +) => {
101
101
match ( & ( $left) , & ( $right) ) {
102
102
( left_val, right_val) => {
103
103
if * left_val == * right_val {
@@ -109,7 +109,7 @@ macro_rules! assert_ne {
109
109
}
110
110
}
111
111
}
112
- } ) ;
112
+ } ;
113
113
}
114
114
115
115
/// Asserts that an expression matches any of the given patterns.
@@ -142,7 +142,7 @@ macro_rules! assert_ne {
142
142
#[ allow_internal_unstable( core_panic) ]
143
143
#[ rustc_macro_transparency = "semitransparent" ]
144
144
pub macro assert_matches {
145
- ( $left: expr, $( |) ? $( $pattern: pat_param ) |+ $( if $guard: expr ) ? $( , ) ?) => ( {
145
+ ( $left: expr, $( |) ? $( $pattern: pat_param ) |+ $( if $guard: expr ) ? $( , ) ?) => {
146
146
match $left {
147
147
$( $pattern ) |+ $( if $guard ) ? => { }
148
148
ref left_val => {
@@ -153,8 +153,8 @@ pub macro assert_matches {
153
153
) ;
154
154
}
155
155
}
156
- } ) ,
157
- ( $left: expr, $( |) ? $( $pattern: pat_param ) |+ $( if $guard: expr ) ?, $( $arg: tt) +) => ( {
156
+ } ,
157
+ ( $left: expr, $( |) ? $( $pattern: pat_param ) |+ $( if $guard: expr ) ?, $( $arg: tt) +) => {
158
158
match $left {
159
159
$( $pattern ) |+ $( if $guard ) ? => { }
160
160
ref left_val => {
@@ -165,7 +165,7 @@ pub macro assert_matches {
165
165
) ;
166
166
}
167
167
}
168
- } ) ,
168
+ } ,
169
169
}
170
170
171
171
/// Asserts that a boolean expression is `true` at runtime.
@@ -214,7 +214,11 @@ pub macro assert_matches {
214
214
#[ rustc_diagnostic_item = "debug_assert_macro" ]
215
215
#[ allow_internal_unstable ( edition_panic) ]
216
216
macro_rules! debug_assert {
217
- ( $( $arg: tt) * ) => ( if $crate:: cfg!( debug_assertions) { $crate:: assert!( $( $arg) * ) ; } )
217
+ ( $( $arg: tt) * ) => {
218
+ if $crate:: cfg!( debug_assertions) {
219
+ $crate:: assert!( $( $arg) * ) ;
220
+ }
221
+ } ;
218
222
}
219
223
220
224
/// Asserts that two expressions are equal to each other.
@@ -240,7 +244,11 @@ macro_rules! debug_assert {
240
244
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
241
245
#[ cfg_attr( not( test) , rustc_diagnostic_item = "debug_assert_eq_macro" ) ]
242
246
macro_rules! debug_assert_eq {
243
- ( $( $arg: tt) * ) => ( if $crate:: cfg!( debug_assertions) { $crate:: assert_eq!( $( $arg) * ) ; } )
247
+ ( $( $arg: tt) * ) => {
248
+ if $crate:: cfg!( debug_assertions) {
249
+ $crate:: assert_eq!( $( $arg) * ) ;
250
+ }
251
+ } ;
244
252
}
245
253
246
254
/// Asserts that two expressions are not equal to each other.
@@ -266,7 +274,11 @@ macro_rules! debug_assert_eq {
266
274
#[ stable( feature = "assert_ne" , since = "1.13.0" ) ]
267
275
#[ cfg_attr( not( test) , rustc_diagnostic_item = "debug_assert_ne_macro" ) ]
268
276
macro_rules! debug_assert_ne {
269
- ( $( $arg: tt) * ) => ( if $crate :: cfg!( debug_assertions) { $crate :: assert_ne!( $( $arg) * ) ; } )
277
+ ( $( $arg: tt) * ) => {
278
+ if $crate:: cfg!( debug_assertions) {
279
+ $crate:: assert_ne!( $( $arg) * ) ;
280
+ }
281
+ } ;
270
282
}
271
283
272
284
/// Asserts that an expression matches any of the given patterns.
@@ -305,7 +317,9 @@ macro_rules! debug_assert_ne {
305
317
#[ allow_internal_unstable( assert_matches) ]
306
318
#[ rustc_macro_transparency = "semitransparent" ]
307
319
pub macro debug_assert_matches( $( $arg: tt) * ) {
308
- if $crate :: cfg!( debug_assertions) { $crate :: assert_matches:: assert_matches!( $( $arg) * ) ; }
320
+ if $crate:: cfg!( debug_assertions) {
321
+ $crate:: assert_matches:: assert_matches!( $( $arg) * ) ;
322
+ }
309
323
}
310
324
311
325
/// Returns whether the given expression matches any of the given patterns.
@@ -331,7 +345,7 @@ macro_rules! matches {
331
345
$( $pattern ) |+ $( if $guard ) ? => true ,
332
346
_ => false
333
347
}
334
- }
348
+ } ;
335
349
}
336
350
337
351
/// Unwraps a result or propagates its error.
@@ -482,7 +496,9 @@ macro_rules! r#try {
482
496
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
483
497
#[ cfg_attr( not( test) , rustc_diagnostic_item = "write_macro" ) ]
484
498
macro_rules! write {
485
- ( $dst: expr, $( $arg: tt) * ) => ( $dst. write_fmt( $crate :: format_args!( $( $arg) * ) ) )
499
+ ( $dst: expr, $( $arg: tt) * ) => {
500
+ $dst. write_fmt( $crate:: format_args!( $( $arg) * ) )
501
+ } ;
486
502
}
487
503
488
504
/// Write formatted data into a buffer, with a newline appended.
@@ -534,12 +550,12 @@ macro_rules! write {
534
550
#[ cfg_attr( not( test) , rustc_diagnostic_item = "writeln_macro" ) ]
535
551
#[ allow_internal_unstable( format_args_nl) ]
536
552
macro_rules! writeln {
537
- ( $dst: expr $( , ) ?) => (
553
+ ( $dst: expr $( , ) ?) => {
538
554
$crate:: write!( $dst, "\n " )
539
- ) ;
540
- ( $dst: expr, $( $arg: tt) * ) => (
555
+ } ;
556
+ ( $dst: expr, $( $arg: tt) * ) => {
541
557
$dst. write_fmt( $crate:: format_args_nl!( $( $arg) * ) )
542
- ) ;
558
+ } ;
543
559
}
544
560
545
561
/// Indicates unreachable code.
@@ -683,8 +699,12 @@ macro_rules! unreachable {
683
699
#[ cfg_attr( not( test) , rustc_diagnostic_item = "unimplemented_macro" ) ]
684
700
#[ allow_internal_unstable( core_panic) ]
685
701
macro_rules! unimplemented {
686
- ( ) => ( $crate :: panicking:: panic( "not implemented" ) ) ;
687
- ( $( $arg: tt) +) => ( $crate :: panic!( "not implemented: {}" , $crate :: format_args!( $( $arg) +) ) ) ;
702
+ ( ) => {
703
+ $crate:: panicking:: panic( "not implemented" )
704
+ } ;
705
+ ( $( $arg: tt) +) => {
706
+ $crate:: panic!( "not implemented: {}" , $crate:: format_args!( $( $arg) +) )
707
+ } ;
688
708
}
689
709
690
710
/// Indicates unfinished code.
@@ -746,8 +766,12 @@ macro_rules! unimplemented {
746
766
#[ cfg_attr( not( test) , rustc_diagnostic_item = "todo_macro" ) ]
747
767
#[ allow_internal_unstable( core_panic) ]
748
768
macro_rules! todo {
749
- ( ) => ( $crate :: panicking:: panic( "not yet implemented" ) ) ;
750
- ( $( $arg: tt) +) => ( $crate :: panic!( "not yet implemented: {}" , $crate :: format_args!( $( $arg) +) ) ) ;
769
+ ( ) => {
770
+ $crate:: panicking:: panic( "not yet implemented" )
771
+ } ;
772
+ ( $( $arg: tt) +) => {
773
+ $crate:: panic!( "not yet implemented: {}" , $crate:: format_args!( $( $arg) +) )
774
+ } ;
751
775
}
752
776
753
777
/// Definitions of built-in macros.
0 commit comments