@@ -6,15 +6,12 @@ macro_rules! panic {
66 ( ) => (
77 $crate:: panic!( "explicit panic" )
88 ) ;
9- ( $msg: literal) => (
9+ ( $msg: literal $ ( , ) ? ) => (
1010 $crate:: panicking:: panic( $msg)
1111 ) ;
12- ( $msg: expr) => (
12+ ( $msg: expr $ ( , ) ? ) => (
1313 $crate:: panicking:: panic_str( $msg)
1414 ) ;
15- ( $msg: expr, ) => (
16- $crate:: panic!( $msg)
17- ) ;
1815 ( $fmt: expr, $( $arg: tt) +) => (
1916 $crate:: panicking:: panic_fmt( $crate:: format_args!( $fmt, $( $arg) +) )
2017 ) ;
@@ -40,7 +37,7 @@ macro_rules! panic {
4037#[ macro_export]
4138#[ stable( feature = "rust1" , since = "1.0.0" ) ]
4239macro_rules! assert_eq {
43- ( $left: expr, $right: expr) => ( {
40+ ( $left: expr, $right: expr $ ( , ) ? ) => ( {
4441 match ( & $left, & $right) {
4542 ( left_val, right_val) => {
4643 if !( * left_val == * right_val) {
@@ -54,9 +51,6 @@ macro_rules! assert_eq {
5451 }
5552 }
5653 } ) ;
57- ( $left: expr, $right: expr, ) => ( {
58- $crate:: assert_eq!( $left, $right)
59- } ) ;
6054 ( $left: expr, $right: expr, $( $arg: tt) +) => ( {
6155 match ( & ( $left) , & ( $right) ) {
6256 ( left_val, right_val) => {
@@ -94,7 +88,7 @@ macro_rules! assert_eq {
9488#[ macro_export]
9589#[ stable( feature = "assert_ne" , since = "1.13.0" ) ]
9690macro_rules! assert_ne {
97- ( $left: expr, $right: expr) => ( {
91+ ( $left: expr, $right: expr $ ( , ) ? ) => ( {
9892 match ( & $left, & $right) {
9993 ( left_val, right_val) => {
10094 if * left_val == * right_val {
@@ -108,9 +102,6 @@ macro_rules! assert_ne {
108102 }
109103 }
110104 } ) ;
111- ( $left: expr, $right: expr, ) => {
112- $crate:: assert_ne!( $left, $right)
113- } ;
114105 ( $left: expr, $right: expr, $( $arg: tt) +) => ( {
115106 match ( & ( $left) , & ( $right) ) {
116107 ( left_val, right_val) => {
@@ -315,17 +306,14 @@ macro_rules! matches {
315306#[ rustc_deprecated( since = "1.39.0" , reason = "use the `?` operator instead" ) ]
316307#[ doc( alias = "?" ) ]
317308macro_rules! r#try {
318- ( $expr: expr) => {
309+ ( $expr: expr $ ( , ) ? ) => {
319310 match $expr {
320311 $crate:: result:: Result :: Ok ( val) => val,
321312 $crate:: result:: Result :: Err ( err) => {
322313 return $crate:: result:: Result :: Err ( $crate:: convert:: From :: from( err) ) ;
323314 }
324315 }
325316 } ;
326- ( $expr: expr, ) => {
327- $crate:: r#try!( $expr)
328- } ;
329317}
330318
331319/// Writes formatted data into a buffer.
@@ -451,12 +439,9 @@ macro_rules! write {
451439#[ stable( feature = "rust1" , since = "1.0.0" ) ]
452440#[ allow_internal_unstable( format_args_nl) ]
453441macro_rules! writeln {
454- ( $dst: expr) => (
442+ ( $dst: expr $ ( , ) ? ) => (
455443 $crate:: write!( $dst, "\n " )
456444 ) ;
457- ( $dst: expr, ) => (
458- $crate:: writeln!( $dst)
459- ) ;
460445 ( $dst: expr, $( $arg: tt) * ) => (
461446 $dst. write_fmt( $crate:: format_args_nl!( $( $arg) * ) )
462447 ) ;
@@ -517,12 +502,9 @@ macro_rules! unreachable {
517502 ( ) => ( {
518503 panic!( "internal error: entered unreachable code" )
519504 } ) ;
520- ( $msg: expr) => ( {
505+ ( $msg: expr $ ( , ) ? ) => ( {
521506 $crate:: unreachable!( "{}" , $msg)
522507 } ) ;
523- ( $msg: expr, ) => ( {
524- $crate:: unreachable!( $msg)
525- } ) ;
526508 ( $fmt: expr, $( $arg: tt) * ) => ( {
527509 panic!( $crate:: concat!( "internal error: entered unreachable code: " , $fmt) , $( $arg) * )
528510 } ) ;
@@ -711,8 +693,7 @@ pub(crate) mod builtin {
711693 #[ rustc_builtin_macro]
712694 #[ macro_export]
713695 macro_rules! compile_error {
714- ( $msg: expr) => { { /* compiler built-in */ } } ;
715- ( $msg: expr, ) => { { /* compiler built-in */ } } ;
696+ ( $msg: expr $( , ) ?) => { { /* compiler built-in */ } } ;
716697 }
717698
718699 /// Constructs parameters for the other string-formatting macros.
@@ -816,8 +797,7 @@ pub(crate) mod builtin {
816797 #[ rustc_builtin_macro]
817798 #[ macro_export]
818799 macro_rules! env {
819- ( $name: expr) => { { /* compiler built-in */ } } ;
820- ( $name: expr, ) => { { /* compiler built-in */ } } ;
800+ ( $name: expr $( , ) ?) => { { /* compiler built-in */ } } ;
821801 }
822802
823803 /// Optionally inspects an environment variable at compile time.
@@ -841,8 +821,7 @@ pub(crate) mod builtin {
841821 #[ rustc_builtin_macro]
842822 #[ macro_export]
843823 macro_rules! option_env {
844- ( $name: expr) => { { /* compiler built-in */ } } ;
845- ( $name: expr, ) => { { /* compiler built-in */ } } ;
824+ ( $name: expr $( , ) ?) => { { /* compiler built-in */ } } ;
846825 }
847826
848827 /// Concatenates identifiers into one identifier.
@@ -877,8 +856,7 @@ pub(crate) mod builtin {
877856 #[ rustc_builtin_macro]
878857 #[ macro_export]
879858 macro_rules! concat_idents {
880- ( $( $e: ident) ,+) => { { /* compiler built-in */ } } ;
881- ( $( $e: ident, ) +) => { { /* compiler built-in */ } } ;
859+ ( $( $e: ident) ,+ $( , ) ?) => { { /* compiler built-in */ } } ;
882860 }
883861
884862 /// Concatenates literals into a static string slice.
@@ -900,8 +878,7 @@ pub(crate) mod builtin {
900878 #[ rustc_builtin_macro]
901879 #[ macro_export]
902880 macro_rules! concat {
903- ( $( $e: expr) ,* ) => { { /* compiler built-in */ } } ;
904- ( $( $e: expr, ) * ) => { { /* compiler built-in */ } } ;
881+ ( $( $e: expr) ,* $( , ) ?) => { { /* compiler built-in */ } } ;
905882 }
906883
907884 /// Expands to the line number on which it was invoked.
@@ -1043,8 +1020,7 @@ pub(crate) mod builtin {
10431020 #[ rustc_builtin_macro]
10441021 #[ macro_export]
10451022 macro_rules! include_str {
1046- ( $file: expr) => { { /* compiler built-in */ } } ;
1047- ( $file: expr, ) => { { /* compiler built-in */ } } ;
1023+ ( $file: expr $( , ) ?) => { { /* compiler built-in */ } } ;
10481024 }
10491025
10501026 /// Includes a file as a reference to a byte array.
@@ -1083,8 +1059,7 @@ pub(crate) mod builtin {
10831059 #[ rustc_builtin_macro]
10841060 #[ macro_export]
10851061 macro_rules! include_bytes {
1086- ( $file: expr) => { { /* compiler built-in */ } } ;
1087- ( $file: expr, ) => { { /* compiler built-in */ } } ;
1062+ ( $file: expr $( , ) ?) => { { /* compiler built-in */ } } ;
10881063 }
10891064
10901065 /// Expands to a string that represents the current module path.
@@ -1191,8 +1166,7 @@ pub(crate) mod builtin {
11911166 #[ rustc_builtin_macro]
11921167 #[ macro_export]
11931168 macro_rules! include {
1194- ( $file: expr) => { { /* compiler built-in */ } } ;
1195- ( $file: expr, ) => { { /* compiler built-in */ } } ;
1169+ ( $file: expr $( , ) ?) => { { /* compiler built-in */ } } ;
11961170 }
11971171
11981172 /// Asserts that a boolean expression is `true` at runtime.
@@ -1242,8 +1216,7 @@ pub(crate) mod builtin {
12421216 #[ rustc_builtin_macro]
12431217 #[ macro_export]
12441218 macro_rules! assert {
1245- ( $cond: expr) => { { /* compiler built-in */ } } ;
1246- ( $cond: expr, ) => { { /* compiler built-in */ } } ;
1219+ ( $cond: expr $( , ) ?) => { { /* compiler built-in */ } } ;
12471220 ( $cond: expr, $( $arg: tt) +) => { { /* compiler built-in */ } } ;
12481221 }
12491222
0 commit comments