Skip to content

Commit 07c72db

Browse files
Add validation to inline_fluent messages
1 parent 3055a20 commit 07c72db

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

compiler/rustc_const_eval/src/errors.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -393,16 +393,17 @@ impl Subdiagnostic for FrameNote {
393393
}
394394
let msg = diag.eagerly_translate(inline_fluent!(
395395
r#"{$times ->
396-
[0] {const_eval_frame_note_inner}
397-
*[other] [... {$times} additional calls {const_eval_frame_note_inner} ...]
398-
}
399-
400-
const_eval_frame_note_inner = inside {$where_ ->
401-
[closure] closure
402-
[instance] `{$instance}`
403-
*[other] {""}
404-
}
405-
"#
396+
[0] inside {$where_ ->
397+
[closure] closure
398+
[instance] `{$instance}`
399+
*[other] {""}
400+
}
401+
*[other] [... {$times} additional calls inside {$where_ ->
402+
[closure] closure
403+
[instance] `{$instance}`
404+
*[other] {""}
405+
} ...]
406+
}"#
406407
));
407408
diag.remove_arg("times");
408409
diag.remove_arg("where_");
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
use quote::quote;
21
use syn::{LitStr, parse_macro_input};
2+
use crate::diagnostics::message::Message;
33

44
pub(crate) fn inline_fluent(input: proc_macro::TokenStream) -> proc_macro::TokenStream {
55
let inline = parse_macro_input!(input as LitStr);
6-
quote! {
7-
rustc_errors::DiagMessage::Inline(std::borrow::Cow::Borrowed(#inline))
8-
}
9-
.into()
6+
let message = Message {
7+
message_span: inline.span(),
8+
value: inline.value(),
9+
};
10+
message.diag_message(None).into()
1011
}

0 commit comments

Comments
 (0)