-
Notifications
You must be signed in to change notification settings - Fork 0
Use icu_list
to emit list in diagnostics.
#2
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
base: master_after_tinystr_update
Are you sure you want to change the base?
Conversation
@@ -539,3 +541,47 @@ impl From<Vec<Span>> for MultiSpan { | |||
MultiSpan::from_spans(spans) | |||
} | |||
} | |||
|
|||
#[macro_export] | |||
macro_rules! pluralize { |
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.
issue: we should be using icu_pluralrules for this
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.
fluent also supports this built-in
} else { | ||
let data_provider = rustc_baked_icu_data::baked_data_provider(); | ||
let locale = icu_locid::locale!("en").into(); | ||
let list_formatter = icu_list::ListFormatter::try_new_and_with_length_unstable( |
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.
thought: ideally the list formatter is built once and stored in the session or something
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.
basically it needs to be stored alongside the fluent stuff
assert!(value_count > 0); | ||
|
||
if value_count > spread_limit { | ||
format!("multiple {descr}{s}", s = pluralize!(value_count),) |
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 descr stuff shouldn't be handled here. if we want to handle it, it ought to be handled via Fluent's builtin support for pluralization
Thanks for the review! I'll dig into the usage part of the diagnostic infrastructure, before addressing these review comments. |
No description provided.