about summary refs log tree commit diff
path: root/compiler/rustc_interface/src/interface.rs
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-01-22 20:37:24 +0100
committerGitHub <noreply@github.com>2025-01-22 20:37:24 +0100
commitb4266b0bcdbfcf40c3b76f37a9b31dbc3f1992bb (patch)
tree1f5bef3c1213b1334639f19f54d046b6d6153e0d /compiler/rustc_interface/src/interface.rs
parentf8759830353d9d0391712552f7359489cac97f73 (diff)
parent57dd42d6134539f5a98f59039bcba6d93daf9d6a (diff)
downloadrust-b4266b0bcdbfcf40c3b76f37a9b31dbc3f1992bb.tar.gz
rust-b4266b0bcdbfcf40c3b76f37a9b31dbc3f1992bb.zip
Rollup merge of #135557 - estebank:wtf8, r=fee1-dead
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: byte `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.
Diffstat (limited to 'compiler/rustc_interface/src/interface.rs')
0 files changed, 0 insertions, 0 deletions