-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Improve handling of numbers in IntoDiagnosticArg
#120398
Conversation
r? @TaKO8Ki (rustbot has picked a reviewer for you, use r? to override) |
if let Ok(n) = TryInto::<i128>::try_into(self) && n >= -100 && n <= 100 { | ||
DiagnosticArgValue::Number(n) | ||
} else { | ||
self.to_string().into_diagnostic_arg() | ||
} |
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.
Hm, this seems quite confusing. If someone is matching on different numbers, say 0, 1, 100, and 1000, then the latter one will be different, which is pretty inconsistent.
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.
I think it's a necessary compromise given the usage of f64
in FluentNumber
. In reality, you're probably using one of the CLDR numerical selectors, rather than the number directly.
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.
I agree. I thought of using a more complicated system which would take into account f64 maximum representable base-10 number but I think it's overkill.
The reason I wanted to match on the numbers was to change the sentence in the 1 case, and it will be the case of many other peoples and I think that in many languages phrases with numbers generally only care about 0, 1, >1. So to be safe I choose 100 as a low but consistent and predictable number.
I think this is a good step even if it's a bit inconsistent. @bors r+ |
…piler-errors Improve handling of numbers in `IntoDiagnosticArg` While working on rust-lang#120393, I realize that my fluent selectors were not working. So here is an improvement (not a fix unfortunately).
…piler-errors Improve handling of numbers in `IntoDiagnosticArg` While working on rust-lang#120393, I realize that my fluent selectors were not working. So here is an improvement (not a fix unfortunately).
Rollup of 9 pull requests Successful merges: - rust-lang#111379 (Boost iterator intersperse(_with) performance) - rust-lang#118182 (Properly recover from trailing attr in body) - rust-lang#119641 (Remove feature not required by `Ipv6Addr::to_cononical` doctest) - rust-lang#119759 (Add FileCheck annotations to dataflow-const-prop tests) - rust-lang#120275 (Avoid ICE in trait without `dyn` lint) - rust-lang#120376 (Update codegen test for LLVM 18) - rust-lang#120386 (ScopeTree: remove destruction_scopes as unused) - rust-lang#120398 (Improve handling of numbers in `IntoDiagnosticArg`) - rust-lang#120399 (Remove myself from review rotation) r? `@ghost` `@rustbot` modify labels: rollup
…piler-errors Improve handling of numbers in `IntoDiagnosticArg` While working on rust-lang#120393, I realize that my fluent selectors were not working. So here is an improvement (not a fix unfortunately).
Rollup of 9 pull requests Successful merges: - rust-lang#111379 (Boost iterator intersperse(_with) performance) - rust-lang#118182 (Properly recover from trailing attr in body) - rust-lang#119641 (Remove feature not required by `Ipv6Addr::to_cononical` doctest) - rust-lang#119957 (fix: correct suggestion arg for impl trait) - rust-lang#120275 (Avoid ICE in trait without `dyn` lint) - rust-lang#120376 (Update codegen test for LLVM 18) - rust-lang#120386 (ScopeTree: remove destruction_scopes as unused) - rust-lang#120398 (Improve handling of numbers in `IntoDiagnosticArg`) - rust-lang#120399 (Remove myself from review rotation) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#118182 (Properly recover from trailing attr in body) - rust-lang#119641 (Remove feature not required by `Ipv6Addr::to_cononical` doctest) - rust-lang#119957 (fix: correct suggestion arg for impl trait) - rust-lang#120386 (ScopeTree: remove destruction_scopes as unused) - rust-lang#120398 (Improve handling of numbers in `IntoDiagnosticArg`) - rust-lang#120399 (Remove myself from review rotation) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120398 - Urgau:into_diag_arg-numbers, r=compiler-errors Improve handling of numbers in `IntoDiagnosticArg` While working on rust-lang#120393, I realize that my fluent selectors were not working. So here is an improvement (not a fix unfortunately).
While working on #120393, I realize that my fluent selectors were not working. So here is an improvement (not a fix unfortunately).