From 49f71dff77a153e3abf86a0c6c4294c651711902 Mon Sep 17 00:00:00 2001 From: Jack Moffitt Date: Fri, 27 Sep 2013 15:27:36 -0600 Subject: [PATCH] Upgrade to latest Rust. --- Makefile.in | 6 +++--- cssparser.rc => lib.rs | 1 - nth.rs | 3 +-- tokenizer.rs | 20 ++++++++++---------- 4 files changed, 14 insertions(+), 16 deletions(-) rename cssparser.rc => lib.rs (95%) diff --git a/Makefile.in b/Makefile.in index 7e12dfc4..a0b82f4e 100644 --- a/Makefile.in +++ b/Makefile.in @@ -13,11 +13,11 @@ RUST_SRC=$(shell find $(VPATH)/. -type f -name '*.rs') $(COLOR_DATA_RS) .PHONY: all all: libcssparser.dummy -libcssparser.dummy: cssparser.rc $(RUST_SRC) - $(RUSTC) $(RUSTFLAGS) $< --out-dir . +libcssparser.dummy: lib.rs $(RUST_SRC) + $(RUSTC) $(RUSTFLAGS) $< --lib --out-dir . touch $@ -cssparser-test: cssparser.rc $(RUST_SRC) +cssparser-test: lib.rs $(RUST_SRC) $(RUSTC) $(RUSTFLAGS) $< -o $@ --test .PHONY: check diff --git a/cssparser.rc b/lib.rs similarity index 95% rename from cssparser.rc rename to lib.rs index 06327daa..05305f46 100644 --- a/cssparser.rc +++ b/lib.rs @@ -3,7 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #[link(name = "cssparser", vers = "0.1")]; -#[crate_type = "lib"]; extern mod extra; diff --git a/nth.rs b/nth.rs index 2b7286fc..1e4e9cf0 100644 --- a/nth.rs +++ b/nth.rs @@ -2,7 +2,6 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -use std::i32; use std::ascii::StrAsciiExt; use ast::*; @@ -108,7 +107,7 @@ fn parse_n_dash_digits(string: &str) -> Option { && string.starts_with("n-") && string.slice_from(2).iter().all(|c| match c { '0'..'9' => true, _ => false }) { - let result = i32::from_str(string.slice_from(1)); // Include the minus sign + let result = from_str(string.slice_from(1)); // Include the minus sign assert!(result.is_some()); result } diff --git a/tokenizer.rs b/tokenizer.rs index 5a209296..3da10e0b 100644 --- a/tokenizer.rs +++ b/tokenizer.rs @@ -4,7 +4,7 @@ // http://dev.w3.org/csswg/css3-syntax/#tokenization -use std::{char, str, u32, i64, f64}; +use std::{char, str, num}; use std::ascii::StrAsciiExt; use ast::*; @@ -440,12 +440,12 @@ fn consume_numeric(tokenizer: &mut Tokenizer) -> ComponentValue { int_value: if is_integer { Some( // Remove any + sign as int::from_str() does not parse them. if representation[0] != '+' as u8 { - i64::from_str(representation) + from_str(representation) } else { - i64::from_str(representation.slice_from(1)) + from_str(representation.slice_from(1)) }.unwrap() )} else { None }, - value: f64::from_str(representation).unwrap(), + value: from_str(representation).unwrap(), representation: representation, }; if !tokenizer.is_eof() && tokenizer.current_char() == '%' { @@ -547,10 +547,10 @@ fn consume_unicode_range(tokenizer: &mut Tokenizer) -> ComponentValue { let start; let end; if question_marks > 0 { - start = u32::from_str_radix(hex + "0".repeat(question_marks), 16).unwrap(); - end = u32::from_str_radix(hex + "F".repeat(question_marks), 16).unwrap(); + start = num::from_str_radix(hex + "0".repeat(question_marks), 16).unwrap(); + end = num::from_str_radix(hex + "F".repeat(question_marks), 16).unwrap(); } else { - start = u32::from_str_radix(hex, 16).unwrap(); + start = num::from_str_radix(hex, 16).unwrap(); hex = ~""; if !tokenizer.is_eof() && tokenizer.current_char() == '-' { tokenizer.position += 1; @@ -563,7 +563,7 @@ fn consume_unicode_range(tokenizer: &mut Tokenizer) -> ComponentValue { } } } - end = if hex.len() > 0 { u32::from_str_radix(hex, 16).unwrap() } else { start } + end = if hex.len() > 0 { num::from_str_radix(hex, 16).unwrap() } else { start } } UnicodeRange {start: start, end: end} } @@ -594,10 +594,10 @@ fn consume_escape(tokenizer: &mut Tokenizer) -> char { } } static REPLACEMENT_CHAR: char = '\uFFFD'; - let c = u32::from_str_radix(hex, 16).unwrap(); + let c: u32 = num::from_str_radix(hex, 16).unwrap(); if c != 0 { let c = char::from_u32(c); - c.unwrap_or_default(REPLACEMENT_CHAR) + c.unwrap_or(REPLACEMENT_CHAR) } else { REPLACEMENT_CHAR }