From 8927da024970a8916babf8da89c5e5150ac61a20 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Wed, 4 Mar 2015 15:06:51 -0800 Subject: [PATCH 1/2] Upgrade to rustc 1.0.0-dev (fed12499e 2015-03-03) (built 2015-03-04) --- benches/tokenizer.rs | 2 +- examples/noop-tokenize.rs | 2 +- macros/src/match_token.rs | 4 ++-- macros/src/named_entities.rs | 4 ++-- src/sink/owned_dom.rs | 4 ++-- tests/tokenizer.rs | 2 +- tests/tree_builder.rs | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/benches/tokenizer.rs b/benches/tokenizer.rs index 4cb117f5..806edc8f 100644 --- a/benches/tokenizer.rs +++ b/benches/tokenizer.rs @@ -7,7 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(box_syntax, core, env, old_io, old_path, std_misc, start, test)] +#![feature(box_syntax, core, old_io, old_path, std_misc, start, test)] extern crate test; extern crate html5ever; diff --git a/examples/noop-tokenize.rs b/examples/noop-tokenize.rs index cc846039..8ee7b59e 100644 --- a/examples/noop-tokenize.rs +++ b/examples/noop-tokenize.rs @@ -9,7 +9,7 @@ // Run a single benchmark once. For use with profiling tools. -#![feature(core, env, test, io, path, fs)] +#![feature(core, test, io, path, fs)] extern crate test; extern crate html5ever; diff --git a/macros/src/match_token.rs b/macros/src/match_token.rs index 746e9dfb..41278863 100644 --- a/macros/src/match_token.rs +++ b/macros/src/match_token.rs @@ -106,7 +106,7 @@ use syntax::ast; use syntax::parse::parser::Parser; use syntax::parse::{token, parser, classify}; use syntax::parse; -use syntax::ext::base::{ExtCtxt, MacResult, MacExpr}; +use syntax::ext::base::{ExtCtxt, MacResult, MacEager}; use self::TagKind::{StartTag, EndTag}; use self::LHS::{Pat, Tags}; @@ -454,7 +454,7 @@ pub fn expand(cx: &mut ExtCtxt, span: Span, toks: &[ast::TokenTree]) -> Box Box [$c0, $c1],)).into_iter() }).collect(); - MacExpr::new(quote_expr!(&mut *cx, phf_map!($toks))) + MacEager::expr(quote_expr!(&mut *cx, phf_map!($toks))) } diff --git a/src/sink/owned_dom.rs b/src/sink/owned_dom.rs index b375885c..ed32e06c 100644 --- a/src/sink/owned_dom.rs +++ b/src/sink/owned_dom.rs @@ -45,7 +45,7 @@ use std::ops::{Deref, DerefMut}; use string_cache::QualName; /// The internal type we use for nodes during parsing. -struct SquishyNode { +pub struct SquishyNode { node: NodeEnum, parent: Handle, children: Vec, @@ -61,7 +61,7 @@ impl SquishyNode { } } -struct Handle { +pub struct Handle { ptr: *const UnsafeCell, } diff --git a/tests/tokenizer.rs b/tests/tokenizer.rs index 031c8b29..8acd3fd1 100644 --- a/tests/tokenizer.rs +++ b/tests/tokenizer.rs @@ -7,7 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(core, env, old_io, old_path, plugin, rustc_private, start, std_misc, test)] +#![feature(core, old_io, old_path, plugin, rustc_private, start, std_misc, test)] #![plugin(string_cache_plugin)] diff --git a/tests/tree_builder.rs b/tests/tree_builder.rs index dd14a35a..5eafa0fa 100644 --- a/tests/tree_builder.rs +++ b/tests/tree_builder.rs @@ -7,7 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(core, env, old_io, old_path, plugin, start, std_misc, test)] +#![feature(core, old_io, old_path, plugin, start, std_misc, test)] #![plugin(string_cache_plugin)] @@ -142,7 +142,7 @@ fn make_test( idx: usize, fields: HashMap) { - let get_field = |&:key| { + let get_field = |key| { let field = fields.get(key).expect("missing field"); field.as_slice().trim_right_matches('\n').to_string() }; From 4c7da6b67a7f4c83e5c6a089632c406dc6478f4c Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Wed, 4 Mar 2015 15:21:03 -0800 Subject: [PATCH 2/2] Use explicit wrapping ops in char_ref We already account for overflow, and don't want to panic. --- src/tokenizer/char_ref/mod.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tokenizer/char_ref/mod.rs b/src/tokenizer/char_ref/mod.rs index dbea40a0..619f3b79 100644 --- a/src/tokenizer/char_ref/mod.rs +++ b/src/tokenizer/char_ref/mod.rs @@ -169,17 +169,19 @@ impl CharRefTokenizer { } fn do_numeric(&mut self, tokenizer: &mut Tokenizer, base: u32) -> Status { + use std::num::wrapping::WrappingOps; + let c = unwrap_or_return!(tokenizer.peek(), Stuck); match c.to_digit(base as u32) { Some(n) => { tokenizer.discard_char(); - self.num *= base; + self.num = self.num.wrapping_mul(base); if self.num > 0x10FFFF { // We might overflow, and the character is definitely invalid. // We still parse digits and semicolon, but don't use the result. self.num_too_big = true; } - self.num += n as u32; + self.num = self.num.wrapping_add(n as u32); self.seen_digit = true; Progress }