about summary refs log tree commit diff
path: root/compiler/rustc_macros/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-03-29 21:57:11 +0000
committerbors <bors@rust-lang.org>2023-03-29 21:57:11 +0000
commit2fb0e8d162a021f8a795fb603f5d8c0017855160 (patch)
tree9bff7eab583aa5f93f7186c4a891b9e3d3032c11 /compiler/rustc_macros/src
parent17c11672167827b0dd92c88ef69f24346d1286dd (diff)
parent02cb4da8969ba2d9f2879df33fc13fce83012ed7 (diff)
downloadrust-2fb0e8d162a021f8a795fb603f5d8c0017855160.tar.gz
rust-2fb0e8d162a021f8a795fb603f5d8c0017855160.zip
Auto merge of #109734 - matthiaskrgr:rollup-oy4nlli, r=matthiaskrgr
Rollup of 8 pull requests

Successful merges:

 - #107387 (Use random `HashMap` keys on Hermit)
 - #109511 (Make `EvalCtxt`'s `infcx` private)
 - #109554 (Suggest ..= when someone tries to create an overflowing range)
 - #109675 (Do not consider elaborated projection predicates for objects in new solver)
 - #109693 (Remove ~const from alloc)
 - #109700 (Lint against escape sequences in Fluent files)
 - #109716 (Move `mir::Field` → `abi::FieldIdx`)
 - #109726 (rustdoc: Don't strip crate module)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_macros/src')
-rw-r--r--compiler/rustc_macros/src/diagnostics/fluent.rs12
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,