diff options
author | David Tolnay <dtolnay@gmail.com> | 2019-07-18 09:25:41 -0700 |
---|---|---|
committer | David Tolnay <dtolnay@gmail.com> | 2019-07-18 09:26:21 -0700 |
commit | 3aeee7f849f6a15f58e221ce11843e9b8556d358 (patch) | |
tree | 7168d5a3a219877b6baac0b4a33ccc961d530055 /src/format.rs | |
parent | f67035c1439fee47390be30f5399c1d4238ebe41 (diff) | |
download | platform_external_rust_crates_quote-3aeee7f849f6a15f58e221ce11843e9b8556d358.tar.gz platform_external_rust_crates_quote-3aeee7f849f6a15f58e221ce11843e9b8556d358.tar.bz2 platform_external_rust_crates_quote-3aeee7f849f6a15f58e221ce11843e9b8556d358.zip |
Stricter about trailing commas in format_ident
The implementation previously allowed multiple trailing commas.
Diffstat (limited to 'src/format.rs')
-rw-r--r-- | src/format.rs | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/format.rs b/src/format.rs index 99b0474..04b4e0d 100644 --- a/src/format.rs +++ b/src/format.rs @@ -109,7 +109,7 @@ macro_rules! format_ident { $crate::format_ident_impl!([ ::std::option::Option::None, $fmt - ] $($rest)*,) + ] $($rest)*) }; } @@ -117,11 +117,14 @@ macro_rules! format_ident { #[doc(hidden)] macro_rules! format_ident_impl { // Final state - ([$span:expr, $($fmt:tt)*] $(,)*) => { + ([$span:expr, $($fmt:tt)*]) => { $crate::__rt::mk_ident(&format!($($fmt)*), $span) }; // Span argument + ([$old:expr, $($fmt:tt)*] span = $span:expr) => { + $crate::format_ident_impl!([$old, $($fmt)*] span = $span,) + }; ([$old:expr, $($fmt:tt)*] span = $span:expr, $($rest:tt)*) => { $crate::format_ident_impl!([ ::std::option::Option::Some::<$crate::__rt::Span>($span), @@ -129,14 +132,20 @@ macro_rules! format_ident_impl { ] $($rest)*) }; - // Named arguments + // Named argument + ([$span:expr, $($fmt:tt)*] $name:ident = $arg:expr) => { + $crate::format_ident_impl!([$span, $($fmt)*] $name = $arg,) + }; ([$span:expr, $($fmt:tt)*] $name:ident = $arg:expr, $($rest:tt)*) => { match $crate::__rt::IdentFragmentAdapter(&$arg) { arg => $crate::format_ident_impl!([$span.or(arg.span()), $($fmt)*, $name = arg] $($rest)*), } }; - // Positional arguments + // Positional argument + ([$span:expr, $($fmt:tt)*] $arg:expr) => { + $crate::format_ident_impl!([$span, $($fmt)*] $arg,) + }; ([$span:expr, $($fmt:tt)*] $arg:expr, $($rest:tt)*) => { match $crate::__rt::IdentFragmentAdapter(&$arg) { arg => $crate::format_ident_impl!([$span.or(arg.span()), $($fmt)*, arg] $($rest)*), |