Skip to content

Commit 651d289

Browse files
committed
Add note about encoding when null bytes found
1 parent 5605b5d commit 651d289

File tree

4 files changed

+3
-0
lines changed

4 files changed

+3
-0
lines changed

compiler/rustc_parse/src/lexer/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ impl<'a> StringReader<'a> {
268268
// tokens like `<<` from `rustc_lexer`, and then add fancier error recovery to it,
269269
// as there will be less overall work to do this way.
270270
let token = unicode_chars::check_for_substitution(self, start, c, &mut err);
271+
if c == '\x00' {
272+
err.help("source files must be encoded in UTF-8, unexpected null bytes might occur when the wrong text encoding is used");
273+
}
271274
err.emit();
272275
token?
273276
}

src/test/ui/parser/issue-66473.stderr

2.46 KB
Binary file not shown.

src/test/ui/parser/issue-68629.stderr

378 Bytes
Binary file not shown.

src/test/ui/parser/issue-68730.stderr

252 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)