@@ -6,15 +6,12 @@ macro_rules! panic {
6
6
( ) => (
7
7
$crate:: panic!( "explicit panic" )
8
8
) ;
9
- ( $msg: literal) => (
9
+ ( $msg: literal $ ( , ) ? ) => (
10
10
$crate:: panicking:: panic( $msg)
11
11
) ;
12
- ( $msg: expr) => (
12
+ ( $msg: expr $ ( , ) ? ) => (
13
13
$crate:: panicking:: panic_str( $msg)
14
14
) ;
15
- ( $msg: expr, ) => (
16
- $crate:: panic!( $msg)
17
- ) ;
18
15
( $fmt: expr, $( $arg: tt) +) => (
19
16
$crate:: panicking:: panic_fmt( $crate:: format_args!( $fmt, $( $arg) +) )
20
17
) ;
@@ -40,7 +37,7 @@ macro_rules! panic {
40
37
#[ macro_export]
41
38
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
42
39
macro_rules! assert_eq {
43
- ( $left: expr, $right: expr) => ( {
40
+ ( $left: expr, $right: expr $ ( , ) ? ) => ( {
44
41
match ( & $left, & $right) {
45
42
( left_val, right_val) => {
46
43
if !( * left_val == * right_val) {
@@ -54,9 +51,6 @@ macro_rules! assert_eq {
54
51
}
55
52
}
56
53
} ) ;
57
- ( $left: expr, $right: expr, ) => ( {
58
- $crate:: assert_eq!( $left, $right)
59
- } ) ;
60
54
( $left: expr, $right: expr, $( $arg: tt) +) => ( {
61
55
match ( & ( $left) , & ( $right) ) {
62
56
( left_val, right_val) => {
@@ -94,7 +88,7 @@ macro_rules! assert_eq {
94
88
#[ macro_export]
95
89
#[ stable( feature = "assert_ne" , since = "1.13.0" ) ]
96
90
macro_rules! assert_ne {
97
- ( $left: expr, $right: expr) => ( {
91
+ ( $left: expr, $right: expr $ ( , ) ? ) => ( {
98
92
match ( & $left, & $right) {
99
93
( left_val, right_val) => {
100
94
if * left_val == * right_val {
@@ -108,9 +102,6 @@ macro_rules! assert_ne {
108
102
}
109
103
}
110
104
} ) ;
111
- ( $left: expr, $right: expr, ) => {
112
- $crate:: assert_ne!( $left, $right)
113
- } ;
114
105
( $left: expr, $right: expr, $( $arg: tt) +) => ( {
115
106
match ( & ( $left) , & ( $right) ) {
116
107
( left_val, right_val) => {
@@ -315,17 +306,14 @@ macro_rules! matches {
315
306
#[ rustc_deprecated( since = "1.39.0" , reason = "use the `?` operator instead" ) ]
316
307
#[ doc( alias = "?" ) ]
317
308
macro_rules! r#try {
318
- ( $expr: expr) => {
309
+ ( $expr: expr $ ( , ) ? ) => {
319
310
match $expr {
320
311
$crate:: result:: Result :: Ok ( val) => val,
321
312
$crate:: result:: Result :: Err ( err) => {
322
313
return $crate:: result:: Result :: Err ( $crate:: convert:: From :: from( err) ) ;
323
314
}
324
315
}
325
316
} ;
326
- ( $expr: expr, ) => {
327
- $crate:: r#try!( $expr)
328
- } ;
329
317
}
330
318
331
319
/// Writes formatted data into a buffer.
@@ -451,12 +439,9 @@ macro_rules! write {
451
439
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
452
440
#[ allow_internal_unstable( format_args_nl) ]
453
441
macro_rules! writeln {
454
- ( $dst: expr) => (
442
+ ( $dst: expr $ ( , ) ? ) => (
455
443
$crate:: write!( $dst, "\n " )
456
444
) ;
457
- ( $dst: expr, ) => (
458
- $crate:: writeln!( $dst)
459
- ) ;
460
445
( $dst: expr, $( $arg: tt) * ) => (
461
446
$dst. write_fmt( $crate:: format_args_nl!( $( $arg) * ) )
462
447
) ;
@@ -517,12 +502,9 @@ macro_rules! unreachable {
517
502
( ) => ( {
518
503
panic!( "internal error: entered unreachable code" )
519
504
} ) ;
520
- ( $msg: expr) => ( {
505
+ ( $msg: expr $ ( , ) ? ) => ( {
521
506
$crate:: unreachable!( "{}" , $msg)
522
507
} ) ;
523
- ( $msg: expr, ) => ( {
524
- $crate:: unreachable!( $msg)
525
- } ) ;
526
508
( $fmt: expr, $( $arg: tt) * ) => ( {
527
509
panic!( $crate:: concat!( "internal error: entered unreachable code: " , $fmt) , $( $arg) * )
528
510
} ) ;
@@ -711,8 +693,7 @@ pub(crate) mod builtin {
711
693
#[ rustc_builtin_macro]
712
694
#[ macro_export]
713
695
macro_rules! compile_error {
714
- ( $msg: expr) => { { /* compiler built-in */ } } ;
715
- ( $msg: expr, ) => { { /* compiler built-in */ } } ;
696
+ ( $msg: expr $( , ) ?) => { { /* compiler built-in */ } } ;
716
697
}
717
698
718
699
/// Constructs parameters for the other string-formatting macros.
@@ -816,8 +797,7 @@ pub(crate) mod builtin {
816
797
#[ rustc_builtin_macro]
817
798
#[ macro_export]
818
799
macro_rules! env {
819
- ( $name: expr) => { { /* compiler built-in */ } } ;
820
- ( $name: expr, ) => { { /* compiler built-in */ } } ;
800
+ ( $name: expr $( , ) ?) => { { /* compiler built-in */ } } ;
821
801
}
822
802
823
803
/// Optionally inspects an environment variable at compile time.
@@ -841,8 +821,7 @@ pub(crate) mod builtin {
841
821
#[ rustc_builtin_macro]
842
822
#[ macro_export]
843
823
macro_rules! option_env {
844
- ( $name: expr) => { { /* compiler built-in */ } } ;
845
- ( $name: expr, ) => { { /* compiler built-in */ } } ;
824
+ ( $name: expr $( , ) ?) => { { /* compiler built-in */ } } ;
846
825
}
847
826
848
827
/// Concatenates identifiers into one identifier.
@@ -877,8 +856,7 @@ pub(crate) mod builtin {
877
856
#[ rustc_builtin_macro]
878
857
#[ macro_export]
879
858
macro_rules! concat_idents {
880
- ( $( $e: ident) ,+) => { { /* compiler built-in */ } } ;
881
- ( $( $e: ident, ) +) => { { /* compiler built-in */ } } ;
859
+ ( $( $e: ident) ,+ $( , ) ?) => { { /* compiler built-in */ } } ;
882
860
}
883
861
884
862
/// Concatenates literals into a static string slice.
@@ -900,8 +878,7 @@ pub(crate) mod builtin {
900
878
#[ rustc_builtin_macro]
901
879
#[ macro_export]
902
880
macro_rules! concat {
903
- ( $( $e: expr) ,* ) => { { /* compiler built-in */ } } ;
904
- ( $( $e: expr, ) * ) => { { /* compiler built-in */ } } ;
881
+ ( $( $e: expr) ,* $( , ) ?) => { { /* compiler built-in */ } } ;
905
882
}
906
883
907
884
/// Expands to the line number on which it was invoked.
@@ -1043,8 +1020,7 @@ pub(crate) mod builtin {
1043
1020
#[ rustc_builtin_macro]
1044
1021
#[ macro_export]
1045
1022
macro_rules! include_str {
1046
- ( $file: expr) => { { /* compiler built-in */ } } ;
1047
- ( $file: expr, ) => { { /* compiler built-in */ } } ;
1023
+ ( $file: expr $( , ) ?) => { { /* compiler built-in */ } } ;
1048
1024
}
1049
1025
1050
1026
/// Includes a file as a reference to a byte array.
@@ -1083,8 +1059,7 @@ pub(crate) mod builtin {
1083
1059
#[ rustc_builtin_macro]
1084
1060
#[ macro_export]
1085
1061
macro_rules! include_bytes {
1086
- ( $file: expr) => { { /* compiler built-in */ } } ;
1087
- ( $file: expr, ) => { { /* compiler built-in */ } } ;
1062
+ ( $file: expr $( , ) ?) => { { /* compiler built-in */ } } ;
1088
1063
}
1089
1064
1090
1065
/// Expands to a string that represents the current module path.
@@ -1191,8 +1166,7 @@ pub(crate) mod builtin {
1191
1166
#[ rustc_builtin_macro]
1192
1167
#[ macro_export]
1193
1168
macro_rules! include {
1194
- ( $file: expr) => { { /* compiler built-in */ } } ;
1195
- ( $file: expr, ) => { { /* compiler built-in */ } } ;
1169
+ ( $file: expr $( , ) ?) => { { /* compiler built-in */ } } ;
1196
1170
}
1197
1171
1198
1172
/// Asserts that a boolean expression is `true` at runtime.
@@ -1242,8 +1216,7 @@ pub(crate) mod builtin {
1242
1216
#[ rustc_builtin_macro]
1243
1217
#[ macro_export]
1244
1218
macro_rules! assert {
1245
- ( $cond: expr) => { { /* compiler built-in */ } } ;
1246
- ( $cond: expr, ) => { { /* compiler built-in */ } } ;
1219
+ ( $cond: expr $( , ) ?) => { { /* compiler built-in */ } } ;
1247
1220
( $cond: expr, $( $arg: tt) +) => { { /* compiler built-in */ } } ;
1248
1221
}
1249
1222
0 commit comments