File tree Expand file tree Collapse file tree 5 files changed +22
-11
lines changed
Expand file tree Collapse file tree 5 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -63,6 +63,7 @@ pub use rustc_error_messages::{
6363use rustc_hashes:: Hash128 ;
6464use rustc_lint_defs:: LintExpectationId ;
6565pub use rustc_lint_defs:: { Applicability , listify, pluralize} ;
66+ pub use rustc_macros:: inline_fluent;
6667use rustc_macros:: { Decodable , Encodable } ;
6768pub use rustc_span:: ErrorGuaranteed ;
6869pub use rustc_span:: fatal_error:: { FatalError , FatalErrorMarker , catch_fatal_errors} ;
Original file line number Diff line number Diff line change @@ -90,14 +90,3 @@ impl Translator {
9090 }
9191 }
9292}
93-
94- /// This macro creates a translatable `DiagMessage` from a literal string.
95- /// It should be used in places where a translatable message is needed, but struct diagnostics are undesired.
96- ///
97- /// This is a macro because in the future we may want to globally register these messages.
98- #[ macro_export]
99- macro_rules! inline_fluent {
100- ( $inline: literal) => {
101- rustc_errors:: DiagMessage :: Inline ( std:: borrow:: Cow :: Borrowed ( $inline) )
102- } ;
103- }
Original file line number Diff line number Diff line change 1+ use quote:: quote;
2+ use syn:: { LitStr , parse_macro_input} ;
3+
4+ pub ( crate ) fn inline_fluent ( input : proc_macro:: TokenStream ) -> proc_macro:: TokenStream {
5+ let inline = parse_macro_input ! ( input as LitStr ) ;
6+ quote ! {
7+ rustc_errors:: DiagMessage :: Inline ( std:: borrow:: Cow :: Borrowed ( #inline) )
8+ }
9+ . 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