Skip to content

Commit 01bbc87

Browse files
committed
Merge pull request #48 from mozilla-servo/rustup-20140528
Upgrade Rust.
2 parents 83e13e5 + a8ffe38 commit 01bbc87

File tree

9 files changed

+128
-120
lines changed

9 files changed

+128
-120
lines changed

ast.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::vec;
99

1010
#[deriving(Eq)]
1111
pub struct NumericValue {
12-
pub representation: StrBuf,
12+
pub representation: String,
1313
pub value: f64,
1414
pub int_value: Option<i64>,
1515
}
@@ -28,16 +28,16 @@ pub type Node = (ComponentValue, SourceLocation); // TODO this is not a good na
2828
#[deriving(Eq)]
2929
pub enum ComponentValue {
3030
// Preserved tokens.
31-
Ident(StrBuf),
32-
AtKeyword(StrBuf),
33-
Hash(StrBuf),
34-
IDHash(StrBuf), // Hash that is a valid ID selector.
35-
String(StrBuf),
36-
URL(StrBuf),
31+
Ident(String),
32+
AtKeyword(String),
33+
Hash(String),
34+
IDHash(String), // Hash that is a valid ID selector.
35+
String(String),
36+
URL(String),
3737
Delim(char),
3838
Number(NumericValue),
3939
Percentage(NumericValue),
40-
Dimension(NumericValue, StrBuf),
40+
Dimension(NumericValue, String),
4141
UnicodeRange(u32, u32), // (start, end) of range
4242
WhiteSpace,
4343
Colon, // :
@@ -53,7 +53,7 @@ pub enum ComponentValue {
5353
CDC, // -->
5454

5555
// Function
56-
Function(StrBuf, Vec<ComponentValue>), // name, arguments
56+
Function(String, Vec<ComponentValue>), // name, arguments
5757

5858
// Simple block
5959
ParenthesisBlock(Vec<ComponentValue>), // (…)
@@ -72,7 +72,7 @@ pub enum ComponentValue {
7272
#[deriving(Eq)]
7373
pub struct Declaration {
7474
pub location: SourceLocation,
75-
pub name: StrBuf,
75+
pub name: String,
7676
pub value: Vec<ComponentValue>,
7777
pub important: bool,
7878
}
@@ -87,7 +87,7 @@ pub struct QualifiedRule {
8787
#[deriving(Eq)]
8888
pub struct AtRule {
8989
pub location: SourceLocation,
90-
pub name: StrBuf,
90+
pub name: String,
9191
pub prelude: Vec<ComponentValue>,
9292
pub block: Option<Vec<Node>>,
9393
}
@@ -123,7 +123,7 @@ pub enum ErrorReason {
123123

124124
impl fmt::Show for SyntaxError {
125125
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
126-
write!(f.buf, "{:u}:{:u} {:?}", self.location.line, self.location.column, self.reason)
126+
write!(f, "{:u}:{:u} {:?}", self.location.line, self.location.column, self.reason)
127127
}
128128
}
129129

color.rs

+1
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ fn parse_color_hash(value: &str) -> Option<Color> {
241241
fn parse_color_function(name: &str, arguments: &[ComponentValue])
242242
-> Option<Color> {
243243
let lower_name = name.to_ascii_lower();
244+
let lower_name = lower_name.as_slice();
244245

245246
let (is_rgb, has_alpha) =
246247
if "rgba" == lower_name { (true, true) }

from_bytes.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ use parser::{parse_stylesheet_rules, StylesheetParser};
3333
/// and the `Encoding` object that was used.
3434
pub fn decode_stylesheet_bytes(css: &[u8], protocol_encoding_label: Option<&str>,
3535
environment_encoding: Option<EncodingRef>)
36-
-> (StrBuf, EncodingRef) {
36+
-> (String, EncodingRef) {
3737
// http://dev.w3.org/csswg/css-syntax/#the-input-byte-stream
3838
match protocol_encoding_label {
3939
None => (),
@@ -50,8 +50,8 @@ pub fn decode_stylesheet_bytes(css: &[u8], protocol_encoding_label: Option<&str>
5050
Some(label_length)
5151
=> if css.slice_from(10 + label_length).starts_with("\";".as_bytes()) {
5252
let label = css.slice(10, 10 + label_length);
53-
let label = str::from_chars(label.iter().map(|&b| b as char).collect::<~[char]>());
54-
match encoding_from_whatwg_label(label) {
53+
let label = str::from_chars(label.iter().map(|&b| b as char).collect::<Vec<char>>().as_slice());
54+
match encoding_from_whatwg_label(label.as_slice()) {
5555
None => (),
5656
Some(fallback) => match fallback.name() {
5757
"utf-16be" | "utf-16le"
@@ -71,7 +71,7 @@ pub fn decode_stylesheet_bytes(css: &[u8], protocol_encoding_label: Option<&str>
7171

7272

7373
#[inline]
74-
fn decode_replace(input: &[u8], fallback_encoding: EncodingRef)-> (StrBuf, EncodingRef) {
74+
fn decode_replace(input: &[u8], fallback_encoding: EncodingRef)-> (String, EncodingRef) {
7575
let (result, used_encoding) = decode(input, DecodeReplace, fallback_encoding);
7676
(result.unwrap(), used_encoding)
7777
}

lib.rs

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
extern crate encoding; // https://github.com/lifthrasiir/rust-encoding
1313

14+
extern crate debug;
15+
1416
#[cfg(test)]
1517
extern crate test;
1618

nth.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ pub fn parse_nth(input: &[ComponentValue]) -> Option<(i32, i32)> {
1919
},
2020
Some(&Dimension(ref value, ref unit)) => match value.int_value {
2121
Some(a) => {
22-
let unit: &str = unit.as_slice().to_ascii_lower();
22+
let unit = unit.as_slice().to_ascii_lower();
23+
let unit = unit.as_slice();
2324
match unit {
2425
"n" => parse_b(iter, a as i32),
2526
"n-" => parse_signless_b(iter, a as i32, -1),
@@ -32,7 +33,8 @@ pub fn parse_nth(input: &[ComponentValue]) -> Option<(i32, i32)> {
3233
_ => None,
3334
},
3435
Some(&Ident(ref value)) => {
35-
let ident: &str = value.as_slice().to_ascii_lower();
36+
let ident = value.as_slice().to_ascii_lower();
37+
let ident = ident.as_slice();
3638
match ident {
3739
"even" => parse_end(iter, 2, 0),
3840
"odd" => parse_end(iter, 2, 1),
@@ -52,7 +54,8 @@ pub fn parse_nth(input: &[ComponentValue]) -> Option<(i32, i32)> {
5254
},
5355
Some(&Delim('+')) => match iter.iter_with_whitespace.next() {
5456
Some(&Ident(ref value)) => {
55-
let ident: &str = value.as_slice().to_ascii_lower();
57+
let ident = value.as_slice().to_ascii_lower();
58+
let ident = ident.as_slice();
5659
match ident {
5760
"n" => parse_b(iter, 1),
5861
"n-" => parse_signless_b(iter, 1, -1),

parser.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ for DeclarationListParser<T> {
173173
}
174174

175175

176-
fn parse_at_rule<T: Iterator<Node>>(iter: &mut T, name: StrBuf, location: SourceLocation)
176+
fn parse_at_rule<T: Iterator<Node>>(iter: &mut T, name: String, location: SourceLocation)
177177
-> AtRule {
178178
let mut prelude = Vec::new();
179179
let mut block = None;

serializer.rs

+13-13
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ use ast::*;
77

88

99
impl ast::ComponentValue {
10-
pub fn to_css(&mut self) -> StrBuf {
11-
let mut css = StrBuf::new();
10+
pub fn to_css(&mut self) -> String {
11+
let mut css = String::new();
1212
self.to_css_push(&mut css);
1313
css
1414
}
1515

16-
pub fn to_css_push(&self, css: &mut StrBuf) {
16+
pub fn to_css_push(&self, css: &mut String) {
1717
match *self {
1818
Ident(ref value) => serialize_identifier(value.as_slice(), css),
1919
AtKeyword(ref value) => {
@@ -58,9 +58,9 @@ impl ast::ComponentValue {
5858
},
5959

6060
UnicodeRange(start, end) => {
61-
css.push_str(format!("U+{:X}", start));
61+
css.push_str(format!("U+{:X}", start).as_slice());
6262
if end != start {
63-
css.push_str(format!("-{:X}", end));
63+
css.push_str(format!("-{:X}", end).as_slice());
6464
}
6565
}
6666

@@ -109,7 +109,7 @@ impl ast::ComponentValue {
109109
}
110110

111111

112-
pub fn serialize_identifier(value: &str, css: &mut StrBuf) {
112+
pub fn serialize_identifier(value: &str, css: &mut String) {
113113
// TODO: avoid decoding/re-encoding UTF-8?
114114
let mut iter = value.chars();
115115
let mut c = iter.next().unwrap();
@@ -127,9 +127,9 @@ pub fn serialize_identifier(value: &str, css: &mut StrBuf) {
127127

128128

129129
#[inline]
130-
fn serialize_char(c: char, css: &mut StrBuf, is_identifier_start: bool) {
130+
fn serialize_char(c: char, css: &mut String, is_identifier_start: bool) {
131131
match c {
132-
'0'..'9' if is_identifier_start => css.push_str(format!("\\\\3{} ", c)),
132+
'0'..'9' if is_identifier_start => css.push_str(format!("\\\\3{} ", c).as_slice()),
133133
'-' if is_identifier_start => css.push_str("\\-"),
134134
'0'..'9' | 'A'..'Z' | 'a'..'z' | '_' | '-' => css.push_char(c),
135135
_ if c > '\x7F' => css.push_char(c),
@@ -141,7 +141,7 @@ fn serialize_char(c: char, css: &mut StrBuf, is_identifier_start: bool) {
141141
}
142142

143143

144-
pub fn serialize_string(value: &str, css: &mut StrBuf) {
144+
pub fn serialize_string(value: &str, css: &mut String) {
145145
css.push_char('"');
146146
// TODO: avoid decoding/re-encoding UTF-8?
147147
for c in value.chars() {
@@ -159,18 +159,18 @@ pub fn serialize_string(value: &str, css: &mut StrBuf) {
159159

160160

161161
pub trait ToCss {
162-
fn to_css(&mut self) -> StrBuf {
163-
let mut css = StrBuf::new();
162+
fn to_css(&mut self) -> String {
163+
let mut css = String::new();
164164
self.to_css_push(&mut css);
165165
css
166166
}
167167

168-
fn to_css_push(&mut self, css: &mut StrBuf);
168+
fn to_css_push(&mut self, css: &mut String);
169169
}
170170

171171

172172
impl<'a, I: Iterator<&'a ComponentValue>> ToCss for I {
173-
fn to_css_push(&mut self, css: &mut StrBuf) {
173+
fn to_css_push(&mut self, css: &mut String) {
174174
let mut previous = match self.next() {
175175
None => return,
176176
Some(first) => { first.to_css_push(css); first }

0 commit comments

Comments
 (0)