-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-grammarArea: The grammar of RustArea: The grammar of RustA-proc-macrosArea: Procedural macrosArea: Procedural macrosC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.I-lang-easy-decisionIssue: The decision needed by the team is conjectured to be easy; this does not imply nominationIssue: The decision needed by the team is conjectured to be easy; this does not imply nominationT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Description
I tried this code:
// This could also be a complex proc macro
macro_rules! print_token {
($x:tt) => { println!("{}", stringify!($x)) }
}
fn main() {
print_token!(123aefg123); // ok, unknown suffix
print_token!(123e123); // ok: float literal
print_token!(123ef3); // error: expected at least one digit in exponent
}
I expected to see this happen: It should compile in print the token verbatim. If unkown/invalid suffix are OK, so should invalid float, because the macro DSL my use it for something else
Instead, this happened: Compilation error :
error: expected at least one digit in exponent
--> src/main.rs:11:18
|
11 | print_token!(123ef3); // error: expected at least one digit in exponent
| ^^^^^^
(tested with Rust 1.69 as well as current nightly, this always has been a problem)
Context
This was discussed with @nnethercote and others last week and I wanted to make sure there is a track of this.
The usecase is so that Slint's color literal work in the slint!
maco DSL.
Currently one can do color: #0e9
but not color:#0ea
in the slint! macro. And Makepad DSL has to workaround the same issue.
vldm, dtolnay and richard-uk1
Metadata
Metadata
Assignees
Labels
A-grammarArea: The grammar of RustArea: The grammar of RustA-proc-macrosArea: Procedural macrosArea: Procedural macrosC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.I-lang-easy-decisionIssue: The decision needed by the team is conjectured to be easy; this does not imply nominationIssue: The decision needed by the team is conjectured to be easy; this does not imply nominationT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team