about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-11-05 10:30:02 +0000
committerbors <bors@rust-lang.org>2015-11-05 10:30:02 +0000
commit792a9f12cff83186a5426bc6e713fbc11261a4b1 (patch)
treed9f8f5b3cc858779fae251596f142ebcdbdb9849 /src/libsyntax/parse
parent7839827a39c9f2eff7dd8146d167de574d09809b (diff)
parent00e9ad1df82efc61b91a1a546629e8d1e529203d (diff)
downloadrust-792a9f12cff83186a5426bc6e713fbc11261a4b1.tar.gz
rust-792a9f12cff83186a5426bc6e713fbc11261a4b1.zip
Auto merge of #28887 - steveklabnik:gh28851, r=alexcrichton
If you try to put something that's bigger than a char into a char
literal, you get an error:

    fn main() {
        let c = 'ஶ்ரீ';
    }

    error: unterminated character constant:

This is a very compiler-centric message. Yes, it's technically
'unterminated', but that's not what you, the user did wrong.

Instead, this commit changes it to

    error: character literal that's larger than a char:

As this actually tells you what went wrong.

Fixes #28851
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/lexer/mod.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs
index 9e38ffe7f0d..e1d8a4d8c54 100644
--- a/src/libsyntax/parse/lexer/mod.rs
+++ b/src/libsyntax/parse/lexer/mod.rs
@@ -1081,11 +1081,12 @@ impl<'a> StringReader<'a> {
             if !self.curr_is('\'') {
                 let last_bpos = self.last_pos;
                 panic!(self.fatal_span_verbose(
-                                   // Byte offsetting here is okay because the
-                                   // character before position `start` is an
-                                   // ascii single quote.
-                                   start - BytePos(1), last_bpos,
-                                   "unterminated character constant".to_string()));
+                        // Byte offsetting here is okay because the
+                        // character before position `start` is an
+                        // ascii single quote.
+                        start - BytePos(1), last_bpos,
+
+                        String::from("character literal may only contain one codepoint")));
             }
             let id = if valid { self.name_from(start) } else { token::intern("0") };
             self.bump(); // advance curr past token