-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
move some invalid exponent detection into rustc_session #131656
Open
richard-uk1
wants to merge
6
commits into
rust-lang:master
Choose a base branch
from
richard-uk1:move_empty_exponent_to_rustc_session
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
move some invalid exponent detection into rustc_session #131656
richard-uk1
wants to merge
6
commits into
rust-lang:master
from
richard-uk1:move_empty_exponent_to_rustc_session
+205
−66
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
rustbot has assigned @petrochenkov. Use |
rustbot
added
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
labels
Oct 13, 2024
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
richard-uk1
force-pushed
the
move_empty_exponent_to_rustc_session
branch
from
October 13, 2024 23:06
8b41315
to
e8c244e
Compare
This comment has been minimized.
This comment has been minimized.
richard-uk1
force-pushed
the
move_empty_exponent_to_rustc_session
branch
from
November 10, 2024 12:06
a642bff
to
82a8103
Compare
This comment has been minimized.
This comment has been minimized.
I've added some ui tests and I think this is now ready for review. It doesn't stop @petrochenkov changing the whole thing later if they so choose. |
This comment has been minimized.
This comment has been minimized.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR moves part of the exponent checks from
rustc_lexer
/rustc_parser
intorustc_session
.This change does not affect which programs are accepted by the complier, or the diagnostics that are reported, with one main exception. That exception is that floats or ints with suffixes beginning with
e
are rejected after the token stream is passed to proc macros, rather than being rejected by the parser as was the case. This gives proc macro authors more consistent access to numeric literals: currently a proc macro could interpret1m
or30s
but not7eggs
or3em
. After this change all are handled the same. The lexer will still reject input if it containse
followed by a number,+
/-
, or_
if they are not followed by a valid integer literal (number +_
), but this doesn't affect macro authors who just want to access alpha suffixes.This PR is a continuation of #79912. In that PR, it was suggested that a new enum was used to indicate type of exponent (whether accepted or rejected). I originally took that approach with this PR, but it didn't seem necessary and made the changes more complex. I can try to go down that road instead if that's the consensus. It is also solving exactly the same problem as #111628.
TODO before ready for review (assuming approach is OK)
1em
)e
(if suffix begins with 'e' suggest an exponential)Currently if the character following theThis now handles arbitrarye
is_
, then the lexer tries to parse an exponent and fails if there are no digits after. The issue is that a valid integer can have any number of_
s before the digit, meaning deciding whether a the suffix is a number or not requires unbounded lookahead. There are a few options here_
s, removing the special case.Although I haven't marked this PR as 'ready for review' since there are outstanding stuff that need doing, I do want to get feedback on the approach.Ready for review now.Also do you want me to write an MCP
r: @petrochenkov, since they reviewed #79912.