diff options
| author | Corey Farwell <coreyf@rwell.org> | 2017-12-03 17:43:44 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-12-03 17:43:44 -0500 |
| commit | b9ffbff9595112af6144ea0f833d7c22e940a824 (patch) | |
| tree | aa58b88d8e79d184c19562488d988c11a082d9ce /src/libstd | |
| parent | 82ee2094927dbf969a9b37582e54c1fdf6358b17 (diff) | |
| parent | 31b8a15e7026eb882aeda7b7b1c704f444da4e81 (diff) | |
| download | rust-b9ffbff9595112af6144ea0f833d7c22e940a824.tar.gz rust-b9ffbff9595112af6144ea0f833d7c22e940a824.zip | |
Rollup merge of #46260 - ExpHP:builtin-macro-doc-sync, r=steveklabnik
Make doc stubs for builtin macros reflect existing support for trailing commas This modifies the `macro_rules!` stubs in `std` for some of the compiler builtin macros in order to better reflect their currently supported grammar. To my understanding these stubs have no impact on compiler output whatsoever, and only exist so that they may appear in the documentation. P.S. It is in fact true that `env!` supports trailing commas while `option_env!` currently does not. (I have another issue for this) I don't imagine there's any way to automatically test these stubs, but I did *informally* test the new definitions on the playpen to see that they accept the desired invocations, as well as inspect the updated doc output.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/macros.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 9d0373404aa..7d62f94056f 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -325,9 +325,10 @@ pub mod builtin { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] - macro_rules! format_args { ($fmt:expr, $($args:tt)*) => ({ - /* compiler built-in */ - }) } + macro_rules! format_args { + ($fmt:expr) => ({ /* compiler built-in */ }); + ($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ }); + } /// Inspect an environment variable at compile time. /// @@ -348,7 +349,10 @@ pub mod builtin { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] - macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) } + macro_rules! env { + ($name:expr) => ({ /* compiler built-in */ }); + ($name:expr,) => ({ /* compiler built-in */ }); + } /// Optionally inspect an environment variable at compile time. /// @@ -400,7 +404,8 @@ pub mod builtin { #[unstable(feature = "concat_idents_macro", issue = "29599")] #[macro_export] macro_rules! concat_idents { - ($($e:ident),*) => ({ /* compiler built-in */ }) + ($($e:ident),*) => ({ /* compiler built-in */ }); + ($($e:ident,)*) => ({ /* compiler built-in */ }); } /// Concatenates literals into a static string slice. @@ -420,7 +425,10 @@ pub mod builtin { /// ``` #[stable(feature = "rust1", since = "1.0.0")] #[macro_export] - macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }) } + macro_rules! concat { + ($($e:expr),*) => ({ /* compiler built-in */ }); + ($($e:expr,)*) => ({ /* compiler built-in */ }); + } /// A macro which expands to the line number on which it was invoked. /// |
