-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Invalid char literal error message has an unhelpful snippet #30033
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
Comments
apasel422
added
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
labels
Nov 24, 2015
I get a different error for your example.
$ rustc -V
rustc 1.5.0 (3d7cd77e4 2015-12-04) |
The error message from the original issue remains the same on nightly. |
Ah, sorry, I didn't test with nightly. I see the error now. |
Gonna take a crack at this issue. Should have a PR up soon, seems simple enough. |
gchp
added a commit
to gchp/rust
that referenced
this issue
Jan 14, 2016
Given this code: fn main() { let _ = 'abcd'; } The compiler would give a message like: error: character literal may only contain one codepoint: '; let _ = 'abcd'; ^~ With this change, the message now displays: error: character literal may only contain one codepoint: 'abcd' let _ = 'abcd' ^~~~~~ Fixes rust-lang#30033
bors
added a commit
that referenced
this issue
Jan 15, 2016
This is achieved by adding the scan_back method. This method looks back through the source_text of the StringReader until it finds the target char, returning it's offset in the source. We use this method to find the offset of the opening single quote, and use that offset as the start of the error. Given this code: ```rust fn main() { let _ = 'abcd'; } ``` The compiler would give a message like: ``` error: character literal may only contain one codepoint: '; let _ = 'abcd'; ^~ ``` With this change, the message now displays: ``` error: character literal may only contain one codepoint: 'abcd'; let _ = 'abcd'; ^~~~~~~ ``` Fixes #30033
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-parser
Area: The parsing of Rust source code to an AST
foo.rs
:The snippet at the end of the error message is not helpful, and should probably encompass everything between the two
'
s.The text was updated successfully, but these errors were encountered: