-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #134366 - harrisonkaiser:no-break-space, r=davidtwco
Fix logical error with what text is considered whitespace. There appears to be 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. In that case the subtraction will cause a ICE (for a compiler in debug mode) as described in #132918.
- Loading branch information
Showing
5 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// 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} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
error: unknown start of token: \u{a0} | ||
--> $DIR/emitter-overflow-bad-whitespace.rs:10:1 | ||
| | ||
LL | ... | ||
| ^ | ||
| | ||
help: Unicode character ' ' (No-Break Space) looks like ' ' (Space), but it is not | ||
| | ||
LL | fn main() { return; } | ||
| + | ||
|
||
error: aborting due to 1 previous error | ||
|