Skip to content

Commit 2567dec

Browse files
metajackSimonSapin
authored andcommitted
Upgrade to rustc 058242141b54bf9e9b82caf02a39c4b9083023c1 2014-07-16
1 parent 5b292cb commit 2567dec

File tree

5 files changed

+28
-24
lines changed

5 files changed

+28
-24
lines changed

color.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,10 @@ fn parse_color_hash(value: &str) -> Option<Color> {
205205
macro_rules! from_hex(
206206
($c: expr) => {{
207207
let c = $c;
208-
match c as char {
209-
'0' .. '9' => c - ('0' as u8),
210-
'a' .. 'f' => c - ('a' as u8) + 10,
211-
'A' .. 'F' => c - ('A' as u8) + 10,
208+
match c {
209+
'0' .. '9' => c as u8 - ('0' as u8),
210+
'a' .. 'f' => c as u8 - ('a' as u8) + 10,
211+
'A' .. 'F' => c as u8 - ('A' as u8) + 10,
212212
_ => return None // Not a valid color
213213
}
214214
}};
@@ -224,14 +224,14 @@ fn parse_color_hash(value: &str) -> Option<Color> {
224224

225225
match value.len() {
226226
6 => to_rgba!(
227-
from_hex!(value[0]) * 16 + from_hex!(value[1]),
228-
from_hex!(value[2]) * 16 + from_hex!(value[3]),
229-
from_hex!(value[4]) * 16 + from_hex!(value[5]),
227+
from_hex!(value.char_at(0)) * 16 + from_hex!(value.char_at(1)),
228+
from_hex!(value.char_at(2)) * 16 + from_hex!(value.char_at(3)),
229+
from_hex!(value.char_at(4)) * 16 + from_hex!(value.char_at(5)),
230230
),
231231
3 => to_rgba!(
232-
from_hex!(value[0]) * 17,
233-
from_hex!(value[1]) * 17,
234-
from_hex!(value[2]) * 17,
232+
from_hex!(value.char_at(0)) * 17,
233+
from_hex!(value.char_at(1)) * 17,
234+
from_hex!(value.char_at(2)) * 17,
235235
),
236236
_ => None
237237
}

css-parsing-tests/color3.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
"#FFCc99", [1, 0.8, 0.6, 1],
3434
"#369", [0.2, 0.4, 0.6, 1],
3535

36+
"#ffé", null, "#fffffé", null,
37+
3638
"rgb(00, 51, 102)", [0, 0.2, 0.4, 1],
3739
"r\\gb(00, 51, 102)", [0, 0.2, 0.4, 1],
3840
"r\\67 b(00, 51, 102)", [0, 0.2, 0.4, 1],

from_bytes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

55
use std::cmp;
6-
use std::str;
76

87
use encoding::label::encoding_from_whatwg_label;
98
use encoding::all::UTF_8;
@@ -50,7 +49,7 @@ pub fn decode_stylesheet_bytes(css: &[u8], protocol_encoding_label: Option<&str>
5049
Some(label_length)
5150
=> if css.slice_from(10 + label_length).starts_with("\";".as_bytes()) {
5251
let label = css.slice(10, 10 + label_length);
53-
let label = str::from_chars(label.iter().map(|&b| b as char).collect::<Vec<char>>().as_slice());
52+
let label = String::from_chars(label.iter().map(|&b| b as char).collect::<Vec<char>>().as_slice());
5453
match encoding_from_whatwg_label(label.as_slice()) {
5554
None => (),
5655
Some(fallback) => match fallback.name() {

lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
#![crate_id = "github.com/mozilla-servo/rust-cssparser#cssparser:0.1"]
5+
#![crate_name = "cssparser"]
66
#![crate_type = "lib"]
77
#![crate_type = "dylib"]
88
#![crate_type = "rlib"]

tests.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
* License, v. 2.0. If a copy of the MPL was not distributed with this
33
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
44

5-
use std::{io, str, task};
5+
use std::io;
66
use std::io::{File, Command, Writer, TempDir};
7+
use std::task;
78
use serialize::{json};
89
use serialize::json::ToJson;
910
use test;
@@ -49,7 +50,9 @@ fn assert_json_eq(results: json::Json, expected: json::Json, message: String) {
4950
let temp = TempDir::new("rust-cssparser-tests").unwrap();
5051
let results = results.to_pretty_str().append("\n");
5152
let expected = expected.to_pretty_str().append("\n");
52-
task::try(proc() {
53+
// NB: The task try is to prevent error message generation from
54+
// stopping us, we don't care about the result.
55+
let _ = task::try(proc() {
5356
let mut result_path = temp.path().clone();
5457
result_path.push("results.json");
5558
let mut expected_path = temp.path().clone();
@@ -58,10 +61,10 @@ fn assert_json_eq(results: json::Json, expected: json::Json, message: String) {
5861
write_whole_file(&expected_path, expected.as_slice());
5962
Command::new("colordiff")
6063
.arg("-u1000")
61-
.arg(result_path.display().to_str())
62-
.arg(expected_path.display().to_str())
63-
.status().unwrap();
64-
}).unwrap();
64+
.arg(result_path.display().to_string())
65+
.arg(expected_path.display().to_string())
66+
.status().unwrap()
67+
});
6568

6669
fail!(message)
6770
}
@@ -166,20 +169,20 @@ fn stylesheet_from_bytes() {
166169
};
167170

168171
let result = {
169-
let css = get_string(map, &"css_bytes".to_string()).unwrap().chars().map(|c| {
172+
let css = get_string(&map, &"css_bytes".to_string()).unwrap().chars().map(|c| {
170173
assert!(c as u32 <= 0xFF);
171174
c as u8
172175
}).collect::<Vec<u8>>();
173-
let protocol_encoding_label = get_string(map, &"protocol_encoding".to_string());
174-
let environment_encoding = get_string(map, &"environment_encoding".to_string())
176+
let protocol_encoding_label = get_string(&map, &"protocol_encoding".to_string());
177+
let environment_encoding = get_string(&map, &"environment_encoding".to_string())
175178
.and_then(encoding_from_whatwg_label);
176179

177180
let (mut rules, used_encoding) = parse_stylesheet_rules_from_bytes(
178181
css.as_slice(), protocol_encoding_label, environment_encoding);
179182

180183
(rules.collect::<Vec<Result<Rule, SyntaxError>>>(), used_encoding.name().to_string()).to_json()
181184
};
182-
assert_json_eq(result, expected, json::Object(map).to_str());
185+
assert_json_eq(result, expected, json::Object(map).to_string());
183186
});
184187

185188
fn get_string<'a>(map: &'a json::Object, key: &String) -> Option<&'a str> {
@@ -410,7 +413,7 @@ impl ToJson for ComponentValue {
410413
String(ref value) => JList!(JString!("string"), value.to_json()),
411414
URL(ref value) => JList!(JString!("url"), value.to_json()),
412415
Delim('\\') => JString!("\\"),
413-
Delim(value) => json::String(str::from_char(value)),
416+
Delim(value) => json::String(String::from_char(1, value)),
414417

415418
Number(ref value) => json::List(vec!(JString!("number")) + numeric(value)),
416419
Percentage(ref value) => json::List(vec!(JString!("percentage")) + numeric(value)),

0 commit comments

Comments
 (0)