Skip to content

Commit 891ada9

Browse files
committed
syntax: convert LitBinary from @[u8] to Rc<~[u8]>.
1 parent b972cad commit 891ada9

File tree

5 files changed

+8
-9
lines changed

5 files changed

+8
-9
lines changed

src/librustc/middle/trans/consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: ast::Lit)
7575
ast::LitBool(b) => C_bool(b),
7676
ast::LitNil => C_nil(),
7777
ast::LitStr(ref s, _) => C_str_slice(cx, (*s).clone()),
78-
ast::LitBinary(data) => C_binary_slice(cx, data),
78+
ast::LitBinary(ref data) => C_binary_slice(cx, *data.borrow()),
7979
}
8080
}
8181

src/librustdoc/clean.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1151,7 +1151,7 @@ impl ToSource for syntax::codemap::Span {
11511151
fn lit_to_str(lit: &ast::Lit) -> ~str {
11521152
match lit.node {
11531153
ast::LitStr(ref st, _) => st.get().to_owned(),
1154-
ast::LitBinary(data) => format!("{:?}", data.as_slice()),
1154+
ast::LitBinary(ref data) => format!("{:?}", data.borrow().as_slice()),
11551155
ast::LitChar(c) => ~"'" + std::char::from_u32(c).unwrap().to_str() + "'",
11561156
ast::LitInt(i, _t) => i.to_str(),
11571157
ast::LitUint(u, _t) => u.to_str(),

src/libsyntax/ast.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use parse::token;
2020
use std::cell::RefCell;
2121
use std::hashmap::HashMap;
2222
use std::option::Option;
23+
use std::rc::Rc;
2324
use std::to_str::ToStr;
2425
use extra::serialize::{Encodable, Decodable, Encoder, Decoder};
2526

@@ -724,7 +725,7 @@ pub type Lit = Spanned<Lit_>;
724725
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
725726
pub enum Lit_ {
726727
LitStr(InternedString, StrStyle),
727-
LitBinary(@[u8]),
728+
LitBinary(Rc<~[u8]>),
728729
LitChar(u32),
729730
LitInt(i64, IntTy),
730731
LitUint(u64, UintTy),

src/libsyntax/ext/source_util.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use print::pprust;
2222

2323
use std::io;
2424
use std::io::File;
25+
use std::rc::Rc;
2526
use std::str;
2627

2728
// 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])
135136
pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
136137
-> base::MacResult
137138
{
138-
use std::at_vec;
139-
140139
let file = match get_single_str_from_tts(cx, sp, tts, "include_bin!") {
141140
Some(f) => f,
142141
None => return MacResult::dummy_expr()
@@ -148,8 +147,7 @@ pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
148147
return MacResult::dummy_expr();
149148
}
150149
Ok(bytes) => {
151-
let bytes = at_vec::to_managed_move(bytes);
152-
base::MRExpr(cx.expr_lit(sp, ast::LitBinary(bytes)))
150+
base::MRExpr(cx.expr_lit(sp, ast::LitBinary(Rc::new(bytes))))
153151
}
154152
}
155153
}

src/libsyntax/print/pprust.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2212,10 +2212,10 @@ pub fn print_literal(s: &mut State, lit: &ast::Lit) {
22122212
ast::LitBool(val) => {
22132213
if val { word(&mut s.s, "true"); } else { word(&mut s.s, "false"); }
22142214
}
2215-
ast::LitBinary(arr) => {
2215+
ast::LitBinary(ref arr) => {
22162216
ibox(s, indent_unit);
22172217
word(&mut s.s, "[");
2218-
commasep_cmnt(s, Inconsistent, arr, |s, u| word(&mut s.s, format!("{}", *u)),
2218+
commasep_cmnt(s, Inconsistent, *arr.borrow(), |s, u| word(&mut s.s, format!("{}", *u)),
22192219
|_| lit.span);
22202220
word(&mut s.s, "]");
22212221
end(s);

0 commit comments

Comments
 (0)