Skip to content

Commit b9ffbff

Browse files
authored
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.
2 parents 82ee209 + 31b8a15 commit b9ffbff

File tree

2 files changed

+28
-12
lines changed

2 files changed

+28
-12
lines changed

src/libcore/macros.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,10 @@ mod builtin {
612612
#[stable(feature = "rust1", since = "1.0.0")]
613613
#[macro_export]
614614
#[cfg(dox)]
615-
macro_rules! format_args { ($fmt:expr, $($args:tt)*) => ({
616-
/* compiler built-in */
617-
}) }
615+
macro_rules! format_args {
616+
($fmt:expr) => ({ /* compiler built-in */ });
617+
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
618+
}
618619

619620
/// Inspect an environment variable at compile time.
620621
///
@@ -624,7 +625,10 @@ mod builtin {
624625
#[stable(feature = "rust1", since = "1.0.0")]
625626
#[macro_export]
626627
#[cfg(dox)]
627-
macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) }
628+
macro_rules! env {
629+
($name:expr) => ({ /* compiler built-in */ });
630+
($name:expr,) => ({ /* compiler built-in */ });
631+
}
628632

629633
/// Optionally inspect an environment variable at compile time.
630634
///
@@ -645,7 +649,8 @@ mod builtin {
645649
#[macro_export]
646650
#[cfg(dox)]
647651
macro_rules! concat_idents {
648-
($($e:ident),*) => ({ /* compiler built-in */ })
652+
($($e:ident),*) => ({ /* compiler built-in */ });
653+
($($e:ident,)*) => ({ /* compiler built-in */ });
649654
}
650655

651656
/// Concatenates literals into a static string slice.
@@ -656,7 +661,10 @@ mod builtin {
656661
#[stable(feature = "rust1", since = "1.0.0")]
657662
#[macro_export]
658663
#[cfg(dox)]
659-
macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }) }
664+
macro_rules! concat {
665+
($($e:expr),*) => ({ /* compiler built-in */ });
666+
($($e:expr,)*) => ({ /* compiler built-in */ });
667+
}
660668

661669
/// A macro which expands to the line number on which it was invoked.
662670
///

src/libstd/macros.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -325,9 +325,10 @@ pub mod builtin {
325325
/// ```
326326
#[stable(feature = "rust1", since = "1.0.0")]
327327
#[macro_export]
328-
macro_rules! format_args { ($fmt:expr, $($args:tt)*) => ({
329-
/* compiler built-in */
330-
}) }
328+
macro_rules! format_args {
329+
($fmt:expr) => ({ /* compiler built-in */ });
330+
($fmt:expr, $($args:tt)*) => ({ /* compiler built-in */ });
331+
}
331332

332333
/// Inspect an environment variable at compile time.
333334
///
@@ -348,7 +349,10 @@ pub mod builtin {
348349
/// ```
349350
#[stable(feature = "rust1", since = "1.0.0")]
350351
#[macro_export]
351-
macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) }
352+
macro_rules! env {
353+
($name:expr) => ({ /* compiler built-in */ });
354+
($name:expr,) => ({ /* compiler built-in */ });
355+
}
352356

353357
/// Optionally inspect an environment variable at compile time.
354358
///
@@ -400,7 +404,8 @@ pub mod builtin {
400404
#[unstable(feature = "concat_idents_macro", issue = "29599")]
401405
#[macro_export]
402406
macro_rules! concat_idents {
403-
($($e:ident),*) => ({ /* compiler built-in */ })
407+
($($e:ident),*) => ({ /* compiler built-in */ });
408+
($($e:ident,)*) => ({ /* compiler built-in */ });
404409
}
405410

406411
/// Concatenates literals into a static string slice.
@@ -420,7 +425,10 @@ pub mod builtin {
420425
/// ```
421426
#[stable(feature = "rust1", since = "1.0.0")]
422427
#[macro_export]
423-
macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }) }
428+
macro_rules! concat {
429+
($($e:expr),*) => ({ /* compiler built-in */ });
430+
($($e:expr,)*) => ({ /* compiler built-in */ });
431+
}
424432

425433
/// A macro which expands to the line number on which it was invoked.
426434
///

0 commit comments

Comments
 (0)