diff options
Diffstat (limited to 'compiler/rustc_macros/src')
| -rw-r--r-- | compiler/rustc_macros/src/diagnostics/fluent.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_macros/src/diagnostics/fluent.rs b/compiler/rustc_macros/src/diagnostics/fluent.rs index 38c0f4895db..3b2f5cfdc73 100644 --- a/compiler/rustc_macros/src/diagnostics/fluent.rs +++ b/compiler/rustc_macros/src/diagnostics/fluent.rs @@ -111,6 +111,18 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok .emit(); return failed(&crate_name); } + let mut bad = false; + for esc in ["\\n", "\\\"", "\\'"] { + for _ in resource_contents.matches(esc) { + bad = true; + Diagnostic::spanned(resource_span, Level::Error, format!("invalid escape `{esc}` in Fluent resource")) + .note("Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>)") + .emit(); + } + } + if bad { + return failed(&crate_name); + } let resource = match FluentResource::try_new(resource_contents) { Ok(resource) => resource, |
