From 651d289405b9d48005a3e6a14f0f76a792d60c5f Mon Sep 17 00:00:00 2001 From: Smitty Date: Sat, 6 Feb 2021 19:17:14 -0500 Subject: Add note about encoding when null bytes found --- compiler/rustc_parse/src/lexer/mod.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'compiler/rustc_parse/src') diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index 4a638ec3f80..bb63dbd5303 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -268,6 +268,9 @@ impl<'a> StringReader<'a> { // tokens like `<<` from `rustc_lexer`, and then add fancier error recovery to it, // as there will be less overall work to do this way. let token = unicode_chars::check_for_substitution(self, start, c, &mut err); + if c == '\x00' { + err.help("source files must be encoded in UTF-8, unexpected null bytes might occur when the wrong text encoding is used"); + } err.emit(); token? } -- cgit 1.4.1-3-g733a5 From c6cb014ad650f7b46c357d40f469c116cc752575 Mon Sep 17 00:00:00 2001 From: Smitty Date: Sun, 7 Feb 2021 11:02:53 -0500 Subject: Clarify error message wording --- compiler/rustc_parse/src/lexer/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'compiler/rustc_parse/src') diff --git a/compiler/rustc_parse/src/lexer/mod.rs b/compiler/rustc_parse/src/lexer/mod.rs index bb63dbd5303..4bf870eb7ce 100644 --- a/compiler/rustc_parse/src/lexer/mod.rs +++ b/compiler/rustc_parse/src/lexer/mod.rs @@ -269,7 +269,7 @@ impl<'a> StringReader<'a> { // as there will be less overall work to do this way. let token = unicode_chars::check_for_substitution(self, start, c, &mut err); if c == '\x00' { - err.help("source files must be encoded in UTF-8, unexpected null bytes might occur when the wrong text encoding is used"); + err.help("source files must contain UTF-8 encoded text, unexpected null bytes might occur when a different encoding is used"); } err.emit(); token? -- cgit 1.4.1-3-g733a5