syntax: convert LitBinary from @[u8] to Rc<~[u8]>.
This commit is contained in:
@@ -20,6 +20,7 @@ use parse::token;
|
||||
use std::cell::RefCell;
|
||||
use std::hashmap::HashMap;
|
||||
use std::option::Option;
|
||||
use std::rc::Rc;
|
||||
use std::to_str::ToStr;
|
||||
use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
|
||||
|
||||
@@ -724,7 +725,7 @@ pub type Lit = Spanned<Lit_>;
|
||||
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
|
||||
pub enum Lit_ {
|
||||
LitStr(InternedString, StrStyle),
|
||||
LitBinary(@[u8]),
|
||||
LitBinary(Rc<~[u8]>),
|
||||
LitChar(u32),
|
||||
LitInt(i64, IntTy),
|
||||
LitUint(u64, UintTy),
|
||||
|
||||
@@ -22,6 +22,7 @@ use print::pprust;
|
||||
|
||||
use std::io;
|
||||
use std::io::File;
|
||||
use std::rc::Rc;
|
||||
use std::str;
|
||||
|
||||
// These macros all relate to the file system; they either return
|
||||
@@ -135,8 +136,6 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
||||
pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
||||
-> base::MacResult
|
||||
{
|
||||
use std::at_vec;
|
||||
|
||||
let file = match get_single_str_from_tts(cx, sp, tts, "include_bin!") {
|
||||
Some(f) => f,
|
||||
None => return MacResult::dummy_expr()
|
||||
@@ -148,8 +147,7 @@ pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
|
||||
return MacResult::dummy_expr();
|
||||
}
|
||||
Ok(bytes) => {
|
||||
let bytes = at_vec::to_managed_move(bytes);
|
||||
base::MRExpr(cx.expr_lit(sp, ast::LitBinary(bytes)))
|
||||
base::MRExpr(cx.expr_lit(sp, ast::LitBinary(Rc::new(bytes))))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2212,10 +2212,10 @@ pub fn print_literal(s: &mut State, lit: &ast::Lit) {
|
||||
ast::LitBool(val) => {
|
||||
if val { word(&mut s.s, "true"); } else { word(&mut s.s, "false"); }
|
||||
}
|
||||
ast::LitBinary(arr) => {
|
||||
ast::LitBinary(ref arr) => {
|
||||
ibox(s, indent_unit);
|
||||
word(&mut s.s, "[");
|
||||
commasep_cmnt(s, Inconsistent, arr, |s, u| word(&mut s.s, format!("{}", *u)),
|
||||
commasep_cmnt(s, Inconsistent, *arr.borrow(), |s, u| word(&mut s.s, format!("{}", *u)),
|
||||
|_| lit.span);
|
||||
word(&mut s.s, "]");
|
||||
end(s);
|
||||
|
||||
Reference in New Issue
Block a user