File tree 9 files changed +64
-9
lines changed
rustc_macros/src/diagnostics
9 files changed +64
-9
lines changed Original file line number Diff line number Diff line change @@ -27,7 +27,8 @@ codegen_llvm_error_calling_dlltool =
27
27
Error calling dlltool: { $error }
28
28
29
29
codegen_llvm_dlltool_fail_import_library =
30
- Dlltool could not create import library: { $stdout } \n{ $stderr }
30
+ Dlltool could not create import library: { $stdout }
31
+ { $stderr }
31
32
32
33
codegen_llvm_target_feature_disable_or_enable =
33
34
the target features { $features } must all be either enabled or disabled together
Original file line number Diff line number Diff line change @@ -39,17 +39,25 @@ const_eval_unstable_const_fn = `{$def_path}` is not yet stable as a const fn
39
39
const_eval_unallowed_mutable_refs =
40
40
mutable references are not allowed in the final value of { $kind } s
41
41
.teach_note =
42
- References in statics and constants may only refer to immutable values.\n\n
42
+ References in statics and constants may only refer to immutable values.
43
+
44
+
43
45
Statics are shared everywhere, and if they refer to mutable data one might violate memory
44
- safety since holding multiple mutable references to shared data is not allowed.\n\n
46
+ safety since holding multiple mutable references to shared data is not allowed.
47
+
48
+
45
49
If you really want global mutable state, try using static mut or a global UnsafeCell.
46
50
47
51
const_eval_unallowed_mutable_refs_raw =
48
52
raw mutable references are not allowed in the final value of { $kind } s
49
53
.teach_note =
50
- References in statics and constants may only refer to immutable values.\n\n
54
+ References in statics and constants may only refer to immutable values.
55
+
56
+
51
57
Statics are shared everywhere, and if they refer to mutable data one might violate memory
52
- safety since holding multiple mutable references to shared data is not allowed.\n\n
58
+ safety since holding multiple mutable references to shared data is not allowed.
59
+
60
+
53
61
If you really want global mutable state, try using static mut or a global UnsafeCell.
54
62
55
63
const_eval_non_const_fmt_macro_call =
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ incremental_field_associated_value_expected = associated value expected for `{$n
24
24
incremental_no_field = no field `{ $name } `
25
25
26
26
incremental_assertion_auto =
27
- `except` specified DepNodes that can not be affected for \ "{ $name } \ ": \ "{ $e } \ "
27
+ `except` specified DepNodes that can not be affected for "{ $name } ": "{ $e } "
28
28
29
29
incremental_undefined_clean_dirty_assertions_item =
30
30
clean/dirty auto-assertions not yet defined for Node::Item.node= { $kind }
Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ lint_ty_qualified = usage of qualified `ty::{$ty}`
91
91
lint_lintpass_by_hand = implementing `LintPass` by hand
92
92
.help = try using `declare_lint_pass!` or `impl_lint_pass!` instead
93
93
94
- lint_non_existant_doc_keyword = found non-existing keyword `{ $keyword } ` used in `#[doc(keyword = \ "...\ ")]`
94
+ lint_non_existant_doc_keyword = found non-existing keyword `{ $keyword } ` used in `#[doc(keyword = "...")]`
95
95
.help = only existing keywords are allowed in core/std
96
96
97
97
lint_diag_out_of_impl =
Original file line number Diff line number Diff line change @@ -111,6 +111,18 @@ pub(crate) fn fluent_messages(input: proc_macro::TokenStream) -> proc_macro::Tok
111
111
. emit ( ) ;
112
112
return failed ( & crate_name) ;
113
113
}
114
+ let mut bad = false ;
115
+ for esc in [ "\\ n" , "\\ \" " , "\\ '" ] {
116
+ for _ in resource_contents. matches ( esc) {
117
+ bad = true ;
118
+ Diagnostic :: spanned ( resource_span, Level :: Error , format ! ( "invalid escape `{esc}` in Fluent resource" ) )
119
+ . note ( "Fluent does not interpret these escape sequences (<https://projectfluent.org/fluent/guide/special.html>)" )
120
+ . emit ( ) ;
121
+ }
122
+ }
123
+ if bad {
124
+ return failed ( & crate_name) ;
125
+ }
114
126
115
127
let resource = match FluentResource :: try_new ( resource_contents) {
116
128
Ok ( resource) => resource,
Original file line number Diff line number Diff line change
1
+ no_crate_bad_escape = don't use \n, \', or \"
Original file line number Diff line number Diff line change @@ -92,3 +92,12 @@ mod missing_message_ref {
92
92
fluent_messages ! { "./missing-message-ref.ftl" }
93
93
//~^ ERROR referenced message `message` does not exist
94
94
}
95
+
96
+ mod bad_escape {
97
+ use super :: fluent_messages;
98
+
99
+ fluent_messages ! { "./invalid-escape.ftl" }
100
+ //~^ ERROR invalid escape `\n`
101
+ //~| ERROR invalid escape `\"`
102
+ //~| ERROR invalid escape `\'`
103
+ }
Original file line number Diff line number Diff line change @@ -83,5 +83,29 @@ LL | fluent_messages! { "./missing-message-ref.ftl" }
83
83
|
84
84
= help: you may have meant to use a variable reference (`{$message}`)
85
85
86
- error: aborting due to 10 previous errors
86
+ error: invalid escape `\n` in Fluent resource
87
+ --> $DIR/test.rs:99:24
88
+ |
89
+ LL | fluent_messages! { "./invalid-escape.ftl" }
90
+ | ^^^^^^^^^^^^^^^^^^^^^^
91
+ |
92
+ = note: os-specific message
93
+
94
+ error: invalid escape `\"` in Fluent resource
95
+ --> $DIR/test.rs:99:24
96
+ |
97
+ LL | fluent_messages! { "./invalid-escape.ftl" }
98
+ | ^^^^^^^^^^^^^^^^^^^^^^
99
+ |
100
+ = note: os-specific message
101
+
102
+ error: invalid escape `\'` in Fluent resource
103
+ --> $DIR/test.rs:99:24
104
+ |
105
+ LL | fluent_messages! { "./invalid-escape.ftl" }
106
+ | ^^^^^^^^^^^^^^^^^^^^^^
107
+ |
108
+ = note: os-specific message
109
+
110
+ error: aborting due to 13 previous errors
87
111
Original file line number Diff line number Diff line change 1
- error: found non-existing keyword `tadam` used in `#[doc(keyword = \ "...\ ")]`
1
+ error: found non-existing keyword `tadam` used in `#[doc(keyword = "...")]`
2
2
--> $DIR/existing_doc_keyword.rs:10:1
3
3
|
4
4
LL | #[doc(keyword = "tadam")]
You can’t perform that action at this time.
0 commit comments