File tree Expand file tree Collapse file tree
compiler/rustc_macros/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ use syn:: { LitStr , parse_macro_input} ;
2+
3+ use crate :: diagnostics:: message:: Message ;
4+
5+ pub ( crate ) fn inline_fluent ( input : proc_macro:: TokenStream ) -> proc_macro:: TokenStream {
6+ let inline = parse_macro_input ! ( input as LitStr ) ;
7+ let message =
8+ Message { attr_span : inline. span ( ) , message_span : inline. span ( ) , value : inline. value ( ) } ;
9+ message. diag_message ( None ) . into ( )
10+ }
Original file line number Diff line number Diff line change 11mod diagnostic;
22mod diagnostic_builder;
33mod error;
4+ mod inline_fluent;
45mod message;
56mod subdiagnostic;
67mod utils;
78
89use diagnostic:: { DiagnosticDerive , LintDiagnosticDerive } ;
10+ pub ( super ) use inline_fluent:: inline_fluent;
911use proc_macro2:: TokenStream ;
1012use subdiagnostic:: SubdiagnosticDerive ;
1113use synstructure:: Structure ;
Original file line number Diff line number Diff line change @@ -241,6 +241,15 @@ decl_derive!(
241241 applicability) ] => diagnostics:: subdiagnostic_derive
242242) ;
243243
244+ /// This macro creates a translatable `DiagMessage` from a fluent format string.
245+ /// It should be used in places where a translatable message is needed, but struct diagnostics are undesired.
246+ ///
247+ /// This macro statically checks that the message is valid Fluent, but not that variables in the Fluent message actually exist.
248+ #[ proc_macro]
249+ pub fn inline_fluent ( input : TokenStream ) -> TokenStream {
250+ diagnostics:: inline_fluent ( input)
251+ }
252+
244253decl_derive ! {
245254 [ PrintAttribute ] =>
246255 /// Derives `PrintAttribute` for `AttributeKind`.
You can’t perform that action at this time.
0 commit comments