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

Future compatiblity warning: {:.*} precision will be limited to u16::MAX in future Rust version #1

Closed
m-ou-se opened this issue Feb 19, 2025 · 1 comment

Comments

@m-ou-se
Copy link

m-ou-se commented Feb 19, 2025

Hi there!

In the Rust compiler and standard library we're planning to limit the width and precision formatting options to a u16. This means that, in a future version of Rust, this line will panic when max_len is larger than u16::MAX:

let result = format!("{:.*}", max_len, s);

This is the only code we found on all of Crates.io and GitHub that triggers the new runtime panic. This is a heads-up to give you the time to adjust your code. Apologies for breaking your code.

See rust-lang/rust#136932 for more information.

If you have any thoughts or concerns about the planned change, feel free to leave a comment on that pull request.

Thanks!

@vasekp
Copy link
Owner

vasekp commented Feb 19, 2025

Wow, the only code on all of Crates.io and GitHub? 😀 Thank you so much for your hard work identifying not only what breaks but actually tracking the parts of code leading to the values "close to" usize::MAX! Glad to hear from you about this.

This was nothing but a laziness on my part, equivalent to no limit on precision in all intended cases. I'll fix this promptly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants