rust/tests/ui/errors/emitter-overflow-bad-whitespace.rs
Harrison Kaiser 1e33dd1711 Fix logical error with what text is considered whitespace.
There is a logical issue around what counts as leading white-space.
There is code which does a subtraction assuming that no errors will be reported
inside the leading whitespace. However we compute the length of
that whitespace with std::char::is_whitespace and not
rustc_lexer::is_whitespace. The former will include a no-break space while
later will excluded it. We can only safely make the assumption that no errors
will be reported  in whitespace if it is all "Rust Standard" whitespace.
Indeed an error does occur in unicode whitespace if it contains a no-break
space.
2024-12-16 23:34:46 -05:00

12 lines
523 B
Rust
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Invalid whitespace (not listed here: https://doc.rust-lang.org/reference/whitespace.html
// e.g. \u{a0}) before any other syntax on the line should not cause any integer overflow
// in the emitter, even when the terminal width causes the line to be truncated.
//
// issue #132918
//@ check-fail
//@ needs-rustc-debug-assertions
//@ compile-flags: --diagnostic-width=1
                                        fn main() { return; }
//~^ ERROR unknown start of token: \u{a0}