Skip to content
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

fix: Fix double rounding of f32 literals #17558

Merged
merged 1 commit into from
Jul 8, 2024

Conversation

beetrees
Copy link
Contributor

@beetrees beetrees commented Jul 7, 2024

Fixes #17556 by delaying parsing until the type is known. Also adds a test to check the issue is fixed.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 7, 2024
#[derive(Default, Debug, Clone, Copy, Eq, PartialEq)]
pub struct FloatTypeWrapper(u64);
#[derive(Default, Debug, Clone, Eq, PartialEq)]
pub struct FloatTypeWrapper(String);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub struct FloatTypeWrapper(String);
pub struct FloatTypeWrapper(Box<str>);

let's use a boxed string to shrink the type a bit (and ensure no left over allocation)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@Veykril Veykril added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 8, 2024
@Veykril
Copy link
Member

Veykril commented Jul 8, 2024

Thanks!
@bors r

@bors
Copy link
Collaborator

bors commented Jul 8, 2024

📌 Commit 3200226 has been approved by Veykril

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Jul 8, 2024

⌛ Testing commit 3200226 with merge da27b89...

@bors
Copy link
Collaborator

bors commented Jul 8, 2024

☀️ Test successful - checks-actions
Approved by: Veykril
Pushing da27b89 to master...

@bors bors merged commit da27b89 into rust-lang:master Jul 8, 2024
11 checks passed
@beetrees beetrees deleted the fix-double-rounding branch July 8, 2024 19:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

f32 literals are sometimes double rounded
4 participants