Skip to content

Commit cec158b

Browse files
committed
doc: concat_idents! macro: more on its limitations.
Signed-off-by: NODA, Kai <[email protected]>
1 parent 052b3fd commit cec158b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/libstd/macros.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,10 @@ pub mod builtin {
269269
/// This macro takes any number of comma-separated identifiers, and
270270
/// concatenates them all into one, yielding an expression which is a new
271271
/// identifier. Note that hygiene makes it such that this macro cannot
272-
/// capture local variables, and macros are only allowed in item,
273-
/// statement or expression position, meaning this macro may be difficult to
274-
/// use in some situations.
272+
/// capture local variables. Also, as a general rule, macros are only
273+
/// allowed in item, statement or expression position. That means while
274+
/// you may use this macro for referring to existing variables, functions or
275+
/// modules etc, you cannot define a new one with it.
275276
///
276277
/// # Examples
277278
///
@@ -283,6 +284,8 @@ pub mod builtin {
283284
///
284285
/// let f = concat_idents!(foo, bar);
285286
/// println!("{}", f());
287+
///
288+
/// // fn concat_idents!(new, fun, name) { } // not usable in this way!
286289
/// # }
287290
/// ```
288291
#[stable(feature = "rust1", since = "1.0.0")]

0 commit comments

Comments
 (0)