Rollup merge of #106971 - oli-obk:tait_error, r=davidtwco
Handle diagnostics customization on the fluent side (for one specific diagnostic) r? ```@davidtwco```
This commit is contained in:
commit
4b97f07534
8 changed files with 24 additions and 19 deletions
|
@ -123,4 +123,7 @@ borrowck_cannot_move_when_borrowed =
|
|||
|
||||
borrowck_opaque_type_non_generic_param =
|
||||
expected generic {$kind} parameter, found `{$ty}`
|
||||
.label = this generic parameter must be used with a generic {$kind} parameter
|
||||
.label = {STREQ($ty, "'static") ->
|
||||
[true] cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type
|
||||
*[other] this generic parameter must be used with a generic {$kind} parameter
|
||||
}
|
||||
|
|
|
@ -147,8 +147,6 @@ infer_region_explanation = {$pref_kind ->
|
|||
}{$desc_kind ->
|
||||
*[should_not_happen] [{$desc_kind}]
|
||||
[restatic] the static lifetime
|
||||
[reempty] the empty lifetime
|
||||
[reemptyuni] the empty lifetime in universe {$desc_arg}
|
||||
[revar] lifetime {$desc_arg}
|
||||
|
||||
[as_defined] the lifetime `{$desc_arg}` as defined here
|
||||
|
|
|
@ -182,6 +182,9 @@ pub fn fluent_bundle(
|
|||
trace!(?locale);
|
||||
let mut bundle = new_bundle(vec![locale]);
|
||||
|
||||
// Add convenience functions available to ftl authors.
|
||||
register_functions(&mut bundle);
|
||||
|
||||
// Fluent diagnostics can insert directionality isolation markers around interpolated variables
|
||||
// indicating that there may be a shift from right-to-left to left-to-right text (or
|
||||
// vice-versa). These are disabled because they are sometimes visible in the error output, but
|
||||
|
@ -244,6 +247,15 @@ pub fn fluent_bundle(
|
|||
Ok(Some(bundle))
|
||||
}
|
||||
|
||||
fn register_functions(bundle: &mut FluentBundle) {
|
||||
bundle
|
||||
.add_function("STREQ", |positional, _named| match positional {
|
||||
[FluentValue::String(a), FluentValue::String(b)] => format!("{}", (a == b)).into(),
|
||||
_ => FluentValue::Error,
|
||||
})
|
||||
.expect("Failed to add a function to the bundle.");
|
||||
}
|
||||
|
||||
/// Type alias for the result of `fallback_fluent_bundle` - a reference-counted pointer to a lazily
|
||||
/// evaluated fluent bundle.
|
||||
pub type LazyFallbackBundle = Lrc<Lazy<FluentBundle, impl FnOnce() -> FluentBundle>>;
|
||||
|
@ -256,6 +268,9 @@ pub fn fallback_fluent_bundle(
|
|||
) -> LazyFallbackBundle {
|
||||
Lrc::new(Lazy::new(move || {
|
||||
let mut fallback_bundle = new_bundle(vec![langid!("en-US")]);
|
||||
|
||||
register_functions(&mut fallback_bundle);
|
||||
|
||||
// See comment in `fluent_bundle`.
|
||||
fallback_bundle.set_use_isolating(with_directionality_markers);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue