-
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
Make ".e0" not parse as 0.0 #48235
Make ".e0" not parse as 0.0 #48235
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@alexcrichton can we get a review on this PR? |
r? @rkruppe |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation looks correct (just have one nit with the test), but since this is a behavioral change, I do not feel confident giving r+ and would like a libs team member to OK the potential breakage.
src/libcore/tests/num/dec2flt/mod.rs
Outdated
@@ -99,6 +99,8 @@ fn fast_path_correct() { | |||
fn lonely_dot() { | |||
assert!(".".parse::<f32>().is_err()); | |||
assert!(".".parse::<f64>().is_err()); | |||
assert!(".e0".parse::<f32>().is_err()); | |||
assert!(".e0".parse::<f64>().is_err()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't really match the test name IMO. Better create a new test with an appropriate name (or issue_40654
if you, like me, can't think of a good succinct name).
This forces floats to have either a digit before the separating point, or after. Thus ".e0" is invalid like ".", when using `parse()`.
7210f4a
to
c0e87f1
Compare
Looks good to me, thanks! Let's get a signoff from other libs members on the breaking change aspect, but I'm personally comfortable with a change like this. @rfcbot fcp merge |
Team member @alexcrichton has proposed to merge this. The next step is review by the rest of the tagged teams: No concerns currently listed. Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
@bors: r+ Ok! |
📌 Commit c0e87f1 has been approved by |
… r=alexcrichton Make ".e0" not parse as 0.0 This forces floats to have either a digit before the separating point, or after. Thus `".e0"` is invalid like `"."`, when using `parse()`. Fixes rust-lang#40654. As mentioned in the issue, this is technically a breaking change... but clearly incorrect behaviour at present.
This forces floats to have either a digit before the separating point, or after. Thus
".e0"
is invalid like"."
, when usingparse()
. Fixes #40654. As mentioned in the issue, this is technically a breaking change... but clearly incorrect behaviour at present.