Open
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.
Metadata
Metadata
Assignees
Labels
Area: The grammar of RustArea: Procedural macrosCategory: A feature request, i.e: not implemented / a PR.Issue: The decision needed by the team is conjectured to be easy; this does not imply nominationRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the language team, which will review and decide on the PR/issue.