syntax: store char literals/tokens as chars rather than u32s.

Clearly storing them as `char` is semantically nicer, but this also
fixes a bug whereby `quote_expr!(cx, 'a')` wasn't working, because the
code created by quotation was not matching the actual AST definitions.
This commit is contained in:
Huon Wilson
2014-05-01 23:35:06 +10:00
parent 239557de6d
commit 5c424ba34a
8 changed files with 13 additions and 19 deletions

View File

@@ -26,7 +26,6 @@ use print::pp::{Breaks, Consistent, Inconsistent, eof};
use print::pp;
use std::cast;
use std::char;
use std::io::{IoResult, MemWriter};
use std::io;
use std::rc::Rc;
@@ -2196,7 +2195,7 @@ impl<'a> State<'a> {
ast::LitStr(ref st, style) => self.print_string(st.get(), style),
ast::LitChar(ch) => {
let mut res = StrBuf::from_str("'");
char::from_u32(ch).unwrap().escape_default(|c| res.push_char(c));
ch.escape_default(|c| res.push_char(c));
res.push_char('\'');
word(&mut self.s, res.into_owned())
}