Rollup merge of #152356 - JonathanBrouwer:inline_diag4, r=jdonszelmann
Improve the `inline_fluent!` macro For https://github.com/rust-lang/rust/issues/151366 This PR turns `inline_fluent!` into a proc macro, so we can run validation on the messages in this macro :) I started a thread here because I don't like the name of the macro, but that's for a future PR: [#t-compiler > Bikeshed the new `inline_fluent!` macro](https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Bikeshed.20the.20new.20.60inline_fluent!.60.20macro/with/572646242)
This commit is contained in:
commit
f1b935d08f
20 changed files with 320 additions and 275 deletions
|
|
@ -446,7 +446,7 @@ impl<'a> LintDiagnostic<'a, ()> for ImplTraitOvercapturesLint<'_> {
|
|||
"specifically, {$num_captured ->
|
||||
[one] this lifetime is
|
||||
*[other] these lifetimes are
|
||||
} in scope but not mentioned in the type's bounds"
|
||||
} in scope but not mentioned in the type's bounds"
|
||||
),
|
||||
)
|
||||
.note(inline_fluent!(
|
||||
|
|
|
|||
|
|
@ -353,8 +353,10 @@ impl<'a> LintDiagnostic<'a, ()> for BuiltinTypeAliasBounds<'_> {
|
|||
self.label,
|
||||
inline_fluent!("will not be checked at usage sites of the type alias"),
|
||||
);
|
||||
diag.note(inline_fluent!("this is a known limitation of the type checker that may be lifted in a future edition.
|
||||
see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information"));
|
||||
diag.note(inline_fluent!(
|
||||
"this is a known limitation of the type checker that may be lifted in a future edition.
|
||||
see issue #112792 <https://github.com/rust-lang/rust/issues/112792> for more information"
|
||||
));
|
||||
if self.enable_feat_help {
|
||||
diag.help(inline_fluent!("add `#![feature(lazy_type_alias)]` to the crate attributes to enable the desired semantics"));
|
||||
}
|
||||
|
|
@ -1748,10 +1750,12 @@ impl<'a> LintDiagnostic<'a, ()> for NonLocalDefinitionsDiag {
|
|||
if doctest {
|
||||
diag.help(inline_fluent!(r#"remove the `#[macro_export]` or make this doc-test a standalone test with its own `fn main() {"{"} ... {"}"}`"#));
|
||||
} else {
|
||||
diag.help(inline_fluent!("remove the `#[macro_export]` or move this `macro_rules!` outside the of the current {$body_kind_descr} {$depth ->
|
||||
[one] `{$body_name}`
|
||||
*[other] `{$body_name}` and up {$depth} bodies
|
||||
}"));
|
||||
diag.help(inline_fluent!(
|
||||
"remove the `#[macro_export]` or move this `macro_rules!` outside the of the current {$body_kind_descr} {$depth ->
|
||||
[one] `{$body_name}`
|
||||
*[other] `{$body_name}` and up {$depth} bodies
|
||||
}"
|
||||
));
|
||||
}
|
||||
|
||||
diag.note(inline_fluent!("a `macro_rules!` definition is non-local if it is nested inside an item and has a `#[macro_export]` attribute"));
|
||||
|
|
|
|||
|
|
@ -196,10 +196,12 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
|
|||
if let Some((open, close, del)) = find_delimiters(cx, span) {
|
||||
lint.arg("already_suggested", suggest_display || suggest_debug);
|
||||
lint.multipart_suggestion(
|
||||
inline_fluent!("{$already_suggested ->
|
||||
[true] or use
|
||||
*[false] use
|
||||
} std::panic::panic_any instead"),
|
||||
inline_fluent!(
|
||||
"{$already_suggested ->
|
||||
[true] or use
|
||||
*[false] use
|
||||
} std::panic::panic_any instead"
|
||||
),
|
||||
if del == '(' {
|
||||
vec![(span.until(open), "std::panic::panic_any".into())]
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue