Skip to content

Show better diagnostics for unicode escapes #26947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 13, 2015

Conversation

nagisa
Copy link
Member

@nagisa nagisa commented Jul 10, 2015

Inspired by the now-mysteriously-closed #26782.

This PR introduces better error messages when unicode escapes have invalid format (e.g. \uFFFF). It also makes rustc always tell the user that escape may not be used in byte-strings and bytes and fixes some spans to not include unecessary characters and include escape backslash in some others.

nagisa added 2 commits July 10, 2015 22:26
This improves diagnostic messages when \u escape is used incorrectly and { is
missing. Instead of saying “unknown character escape: u”, it will now report
that unicode escape sequence is incomplete and suggest what the correct syntax
is.
@rust-highfive
Copy link
Contributor

r? @nrc

(rust_highfive has picked a reviewer for you, use r? to override)

'u' => {
let valid = if self.curr_is('{') {
let valid = self.scan_unicode_escape(delim);
if ascii_only { false } else { valid }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

!ascii_only && self.scan_unicode_escape(delim)

@nrc
Copy link
Member

nrc commented Jul 12, 2015

r+ with the nits addressed

@nagisa nagisa force-pushed the unicode-escape-error branch from ecb8f87 to 4d65ef4 Compare July 12, 2015 23:09
@nagisa
Copy link
Member Author

nagisa commented Jul 12, 2015

Comments addressed.

@nrc
Copy link
Member

nrc commented Jul 13, 2015

@bors: r+

@bors
Copy link
Collaborator

bors commented Jul 13, 2015

📌 Commit 4d65ef4 has been approved by nrc

bors added a commit that referenced this pull request Jul 13, 2015
Inspired by the now-mysteriously-closed #26782.

This PR introduces better error messages when unicode escapes have invalid format (e.g. `\uFFFF`). It also makes rustc always tell the user that escape may not be used in byte-strings and bytes and fixes some spans to not include unecessary characters and include escape backslash in some others.
@bors
Copy link
Collaborator

bors commented Jul 13, 2015

⌛ Testing commit 4d65ef4 with merge 07be629...

@bors bors merged commit 4d65ef4 into rust-lang:master Jul 13, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants