-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disallow leading underscores in float exponents. #114567
Disallow leading underscores in float exponents. #114567
Conversation
Such as `1e_3`, `1E+__3`, `1e-_________3_3`. - They are ugly and never used in practice. (The test suite and compiler code have no examples of them.) - They don't match normal decimal literals. (You can't write `x = _3;`.) - They complicate attempts to allow integers with suffixes beginning with `e`, such as `1em` (currently disallowed, but desired in rust-lang#111615). Because when given a char sequence like `1e` the lexer must decide whether what follows the `e` is a decimal integer (in which case it's a float with exponent) or something else (in which case it's an integer with a suffix). But unbounded char lookahead is required to get past the possibly unlimited number of leading underscores. Disallowing the leading underscores reduces the lookahead to two: one for a possible `+`/`-`, and then one more for a digit or non-digit.
@bors try |
⌛ Trying commit 99c21f2 with merge 77c31533f5de739620341d1e55d79a35cbb15b78... |
☀️ Try build successful - checks-actions |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
I always have trouble reading crater results, but there are at least two genuine regressions.
In both cases allowing a single leading underscore would be enough.
|
Also a surprising number of failures caused by "no space left on device", i.e. disks filling up. |
From what I've seen it always happens with crater runs nowadays. |
Wait a second, I completely missed that the implementation is incorrect. The |
lexer: Disallow some leading underscores in float exponents A second, scaled down, attempt at rust-lang#114567. cc rust-lang#111628 (comment)
Such as
1e_3
,1E+__3
,1e-_________3_3
.x = _3;
.)e
, such as1em
(currently disallowed, but desired in Allow numeric tokens containing 'e' that aren't exponents be passed to proc macros #111615). Because when given a char sequence like1e
the lexer must decide whether what follows thee
is a decimal integer (in which case it's a float with exponent) or something else (in which case it's an integer with a suffix). But unbounded char lookahead is required to get past the possibly unlimited number of leading underscores. Disallowing the leading underscores reduces the lookahead to two: one for a possible+
/-
, and then one more for a digit or non-digit.r? @ghost