You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Expressions in meta items must macro-expand to literal expressions, which must not
include integer or float type suffixes. Expressions which are not literal expressions
will be syntactically accepted (and can be passed to proc-macros), but will be rejected after parsing.
To me this implies that #[attr(name= literal_expr!())]is valid, but it is not. It appears that macro expanding expressions in attributes only happens for #[attr = literal_expr!()].
For example (to take a random attribute that accepts multiple flavors of metaitem syntax):
error: expected unsuffixed literal, found `concat`
--> src/lib.rs:7:36
|
7 | #[rustc_on_unimplemented(message = concat!("the", " ", "message"))]
| ^^^^^^
|
help: surround the identifier with quotation marks to make it into a string literal
|
7 | #[rustc_on_unimplemented(message = "concat"!("the", " ", "message"))]
| + +
error: could not compile `playground` (lib) due to 1 previous error
The text was updated successfully, but these errors were encountered:
See https://doc.rust-lang.org/nightly/reference/attributes.html#r-attributes.meta.literal-expr
To me this implies that
#[attr(name= literal_expr!())]
is valid, but it is not. It appears that macro expanding expressions in attributes only happens for#[attr = literal_expr!()]
.For example (to take a random attribute that accepts multiple flavors of metaitem syntax):
Results in:
The text was updated successfully, but these errors were encountered: