Logo
Explore Help
Register Sign In
rust-lang/rust
1
0
Fork 0
You've already forked rust
Code Issues Pull Requests Actions 1 Packages Projects Releases Wiki Activity
Files
b3827e4f3728b77bd3e60587487ebfc3cc8d901b
rust/tests/ui/macros/not-utf8.rs

8 lines
202 B
Rust
Raw Normal View History

Annotate `input` reference tests
2024-10-30 16:47:47 -07:00
//@ reference: input.encoding.utf8
//@ reference: input.encoding.invalid
Reject non-UTF-8 files when reading as str. Close #2918.
2012-07-25 14:58:48 -07:00
fn foo() {
Point at invalid utf-8 span on user's source code ``` error: couldn't read `$DIR/not-utf8-bin-file.rs`: stream did not contain valid UTF-8 --> $DIR/not-utf8-2.rs:6:5 | LL | include!("not-utf8-bin-file.rs"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: `[193]` is not valid utf-8 --> $DIR/not-utf8-bin-file.rs:2:14 | LL | let _ = "�|�␂!5�cc␕␂��"; | ^ = note: this error originates in the macro `include` (in Nightly builds, run with -Z macro-backtrace for more info) ``` When we attempt to load a Rust source code file, if there is a OS file failure we try reading the file as bytes. If that succeeds we try to turn it into UTF-8. If *that* fails, we provide additional context about *where* the file has the first invalid UTF-8 character. Fix #76869.
2025-01-15 21:24:31 +00:00
include!("not-utf8.bin");
compiletest: Require `//~` annotations even if `error-pattern` is specified
2025-03-29 02:41:32 +03:00
//~^ ERROR couldn't read `$DIR/not-utf8.bin`: stream did not contain valid UTF-8
Reject non-UTF-8 files when reading as str. Close #2918.
2012-07-25 14:58:48 -07:00
}
Reference in New Issue Copy Permalink
Powered by Gitea Version: 1.24.6 Page: 6374ms Template: 4ms
English
Bahasa Indonesia Deutsch English Español Français Gaeilge Italiano Latviešu Magyar nyelv Nederlands Polski Português de Portugal Português do Brasil Suomi Svenska Türkçe Čeština Ελληνικά Български Русский Українська فارسی മലയാളം 日本語 简体中文 繁體中文(台灣) 繁體中文(香港) 한국어
Licenses API