From c5d1b8b234ea26f153e0225ee4abd60b053c1eb1 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Tue, 27 Jan 2015 13:03:36 -0500 Subject: [PATCH 1/6] Update to latest html5lib-tests * html5lib-tests a9badff...11aec47 (3): > Merge pull request #40 from html5lib/fix-webencodings > Merge pull request #52 from gsnedders/ignoreErrorOrder > Add tree construction test cases for the fragment parsing algorithm with foreign context elements. Extend the test format to support this case. --- html5lib-tests | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/html5lib-tests b/html5lib-tests index a9badff0..11aec478 160000 --- a/html5lib-tests +++ b/html5lib-tests @@ -1 +1 @@ -Subproject commit a9badff0cd2fe337170769d42ca2df5e96d30f97 +Subproject commit 11aec478545744fe89ba17bac70fbcacdd76922b From 3bc0fb0ee13d5aa58c5ac41615a1fe6770d78a2e Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Tue, 27 Jan 2015 16:31:47 -0500 Subject: [PATCH 2/6] Speed up html5ever-external-test startup time We now wait to split the input until each test actually runs. This means some duplication of work between tests that previously used the same input, but reduces startup overhead by not performing Vec copies. This makes running a single test significantly faster without affecting the total time to run all tests. Before: $ HTML5EVER_SRC_DIR=$(pwd) time -p ./build/html5ever-external-test --help > /dev/null real 9.75 user 9.64 sys 0.10 $ HTML5EVER_SRC_DIR=$(pwd) time -p ./build/html5ever-external-test > /dev/null real 17.72 user 60.12 sys 3.72 After: $ HTML5EVER_SRC_DIR=$(pwd) time -p ./build/html5ever-external-test --help > /dev/null real 0.51 user 0.49 sys 0.01 $ HTML5EVER_SRC_DIR=$(pwd) time -p ./build/html5ever-external-test > /dev/null real 11.30 user 61.63 sys 4.00 --- tests/tokenizer.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/tokenizer.rs b/tests/tokenizer.rs index bacda6c6..d02484f6 100644 --- a/tests/tokenizer.rs +++ b/tests/tokenizer.rs @@ -291,7 +291,7 @@ fn unescape_json(js: &Json) -> Json { } } -fn mk_test(desc: String, insplits: Vec>, expect: Vec, opts: TokenizerOpts) +fn mk_test(desc: String, input: String, expect: Vec, opts: TokenizerOpts) -> TestDescAndFn { TestDescAndFn { desc: TestDesc { @@ -300,6 +300,8 @@ fn mk_test(desc: String, insplits: Vec>, expect: Vec, opts: T should_fail: No, }, testfn: DynTestFn(Thunk::new(move || { + // Split up the input at different points to test incremental tokenization. + let insplits = splits(input.as_slice(), 3); for input in insplits.into_iter() { // Clone 'input' so we have it for the failure message. // Also clone opts. If we don't, we get the wrong @@ -332,9 +334,6 @@ fn mk_tests(tests: &mut Vec, path_str: &str, js: &Json) { expect = unescape_json(&expect); } - // Split up the input at different points to test incremental tokenization. - let insplits = splits(input.as_slice(), 3); - // Some tests have a last start tag name. let start_tag = obj.get(&"lastStartTag".to_string()).map(|s| s.get_str()); @@ -364,7 +363,7 @@ fn mk_tests(tests: &mut Vec, path_str: &str, js: &Json) { } let expect_toks = json_to_tokens(&expect, exact_errors); - tests.push(mk_test(newdesc, insplits.clone(), expect_toks, TokenizerOpts { + tests.push(mk_test(newdesc, input.clone(), expect_toks, TokenizerOpts { exact_errors: exact_errors, initial_state: state, last_start_tag_name: start_tag.clone(), From f2133e6c9708bf94d755c0581c8b1f8f3ccd9786 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Tue, 27 Jan 2015 16:42:15 -0500 Subject: [PATCH 3/6] Fix parsing of comments inside s We were always appending them to the element instead of to the "appropriate place". --- data/test/ignore | 1 - src/tree_builder/rules.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/data/test/ignore b/data/test/ignore index aa5b8cf1..9047c06b 100644 --- a/data/test/ignore +++ b/data/test/ignore @@ -14,7 +14,6 @@ tb: adoption01.dat-8 tb: adoption01.dat-9 tb: adoption02.dat-0 tb: adoption02.dat-1 -tb: domjs-unsafe.dat-34 tb: html5test-com.dat-20 tb: isindex.dat-0 tb: isindex.dat-1 diff --git a/src/tree_builder/rules.rs b/src/tree_builder/rules.rs index e12c50df..24aa481a 100644 --- a/src/tree_builder/rules.rs +++ b/src/tree_builder/rules.rs @@ -957,7 +957,7 @@ impl TreeBuilderStep InColumnGroup => match_token!(token { CharacterTokens(NotSplit, text) => SplitWhitespace(text), CharacterTokens(Whitespace, text) => self.append_text(text), - CommentToken(text) => self.append_comment_to_html(text), + CommentToken(text) => self.append_comment(text), => self.step(InBody, token), From 63186f0a3506132ff995b70f2cab681e0f38d832 Mon Sep 17 00:00:00 2001 From: Adam Roben Date: Tue, 27 Jan 2015 17:12:46 -0500 Subject: [PATCH 4/6] Fix closing of . Instead we were checking whether the child of the is an , which I don't believe is even possible. --- data/test/ignore | 1 - src/tree_builder/rules.rs | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/data/test/ignore b/data/test/ignore index 9047c06b..c8376af3 100644 --- a/data/test/ignore +++ b/data/test/ignore @@ -80,7 +80,6 @@ tb: tests19.dat-96 tb: tests19.dat-97 tb: tests19.dat-98 tb: tests19.dat-99 -tb: tests2.dat-37 tb: tests2.dat-44 tb: tests2.dat-9 tb: tests22.dat-0 diff --git a/src/tree_builder/rules.rs b/src/tree_builder/rules.rs index 24aa481a..14104c95 100644 --- a/src/tree_builder/rules.rs +++ b/src/tree_builder/rules.rs @@ -1158,7 +1158,7 @@ impl TreeBuilderStep => { if self.open_elems.len() >= 2 && self.current_node_named(atom!(option)) - && self.html_elem_named(self.open_elems[1].clone(), + && self.html_elem_named(self.open_elems[self.open_elems.len() - 2].clone(), atom!(optgroup)) { self.pop(); } From 28cd1a528097f902c411da47837821ee3498126b Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Sun, 25 Jan 2015 02:18:01 +0530 Subject: [PATCH 5/6] Fix impl depending on old impl check --- src/lib.rs | 2 +- src/tokenizer/char_ref/mod.rs | 29 ++++++++++++++--------------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1417dccf..d2039e1b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,7 +10,7 @@ #![crate_name="html5ever"] #![crate_type="dylib"] -#![feature(plugin, old_impl_check, int_uint, box_syntax)] +#![feature(plugin, int_uint, box_syntax)] #![deny(warnings)] #![allow(unused_parens, unstable)] diff --git a/src/tokenizer/char_ref/mod.rs b/src/tokenizer/char_ref/mod.rs index c7d7ba59..22aad2db 100644 --- a/src/tokenizer/char_ref/mod.rs +++ b/src/tokenizer/char_ref/mod.rs @@ -113,9 +113,8 @@ impl CharRefTokenizer { } } -#[old_impl_check] -impl CharRefTokenizer { - pub fn step(&mut self, tokenizer: &mut Tokenizer) -> Status { +impl CharRefTokenizer { + pub fn step(&mut self, tokenizer: &mut Tokenizer) -> Status { if self.result.is_some() { return Done; } @@ -131,7 +130,7 @@ impl CharRefTokenizer { } } - fn do_begin(&mut self, tokenizer: &mut Tokenizer) -> Status { + fn do_begin(&mut self, tokenizer: &mut Tokenizer) -> Status { match unwrap_or_return!(tokenizer.peek(), Stuck) { '\t' | '\n' | '\x0C' | ' ' | '<' | '&' => self.finish_none(), @@ -152,7 +151,7 @@ impl CharRefTokenizer { } } - fn do_octothorpe(&mut self, tokenizer: &mut Tokenizer) -> Status { + fn do_octothorpe(&mut self, tokenizer: &mut Tokenizer) -> Status { let c = unwrap_or_return!(tokenizer.peek(), Stuck); match c { 'x' | 'X' => { @@ -169,7 +168,7 @@ impl CharRefTokenizer { Progress } - fn do_numeric(&mut self, tokenizer: &mut Tokenizer, base: u32) -> Status { + fn do_numeric(&mut self, tokenizer: &mut Tokenizer, base: u32) -> Status { let c = unwrap_or_return!(tokenizer.peek(), Stuck); match c.to_digit(base as uint) { Some(n) => { @@ -194,7 +193,7 @@ impl CharRefTokenizer { } } - fn do_numeric_semicolon(&mut self, tokenizer: &mut Tokenizer) -> Status { + fn do_numeric_semicolon(&mut self, tokenizer: &mut Tokenizer) -> Status { match unwrap_or_return!(tokenizer.peek(), Stuck) { ';' => tokenizer.discard_char(), _ => tokenizer.emit_error(Borrowed("Semicolon missing after numeric character reference")), @@ -202,7 +201,7 @@ impl CharRefTokenizer { self.finish_numeric(tokenizer) } - fn unconsume_numeric(&mut self, tokenizer: &mut Tokenizer) -> Status { + fn unconsume_numeric(&mut self, tokenizer: &mut Tokenizer) -> Status { let mut unconsume = String::from_str("#"); match self.hex_marker { Some(c) => unconsume.push(c), @@ -214,7 +213,7 @@ impl CharRefTokenizer { self.finish_none() } - fn finish_numeric(&mut self, tokenizer: &mut Tokenizer) -> Status { + fn finish_numeric(&mut self, tokenizer: &mut Tokenizer) -> Status { fn conv(n: u32) -> char { from_u32(n).expect("invalid char missed by error handling cases") } @@ -247,7 +246,7 @@ impl CharRefTokenizer { self.finish_one(c) } - fn do_named(&mut self, tokenizer: &mut Tokenizer) -> Status { + fn do_named(&mut self, tokenizer: &mut Tokenizer) -> Status { let c = unwrap_or_return!(tokenizer.get_char(), Stuck); self.name_buf_mut().push(c); match data::NAMED_ENTITIES.get(self.name_buf().as_slice()) { @@ -267,18 +266,18 @@ impl CharRefTokenizer { } } - fn emit_name_error(&mut self, tokenizer: &mut Tokenizer) { + fn emit_name_error(&mut self, tokenizer: &mut Tokenizer) { let msg = format_if!(tokenizer.opts.exact_errors, "Invalid character reference", "Invalid character reference &{}", self.name_buf().as_slice()); tokenizer.emit_error(msg); } - fn unconsume_name(&mut self, tokenizer: &mut Tokenizer) { + fn unconsume_name(&mut self, tokenizer: &mut Tokenizer) { tokenizer.unconsume(self.name_buf_opt.take().unwrap()); } - fn finish_named(&mut self, + fn finish_named(&mut self, tokenizer: &mut Tokenizer, end_char: Option) -> Status { match self.name_match { @@ -360,7 +359,7 @@ impl CharRefTokenizer { } } - fn do_bogus_name(&mut self, tokenizer: &mut Tokenizer) -> Status { + fn do_bogus_name(&mut self, tokenizer: &mut Tokenizer) -> Status { let c = unwrap_or_return!(tokenizer.get_char(), Stuck); self.name_buf_mut().push(c); match c { @@ -372,7 +371,7 @@ impl CharRefTokenizer { self.finish_none() } - pub fn end_of_file(&mut self, tokenizer: &mut Tokenizer) { + pub fn end_of_file(&mut self, tokenizer: &mut Tokenizer) { while self.result.is_none() { match self.state { Begin => drop(self.finish_none()), From a89efdca85580800dd1c69c370dbc78ec7c27e58 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Fri, 30 Jan 2015 18:47:24 -0800 Subject: [PATCH 6/6] Upgrade to rustc 1.0.0-dev (c5961ad06 2015-01-28 21:49:38 +0000) --- bench/bin.rs | 2 +- bench/tokenizer.rs | 9 +++++---- examples/html2html.rs | 19 +++++++++--------- examples/noop-tokenize.rs | 5 +++-- examples/noop-tree-builder.rs | 34 ++++++++++++++++---------------- examples/print-rcdom.rs | 7 +++---- examples/print-tree-actions.rs | 34 ++++++++++++++++---------------- examples/tokenize.rs | 4 ++-- macros/src/lib.rs | 4 ++-- macros/src/named_entities.rs | 10 +++++----- src/lib.rs | 8 +++++--- src/serialize/mod.rs | 2 +- src/sink/owned_dom.rs | 9 +++++---- src/sink/rcdom.rs | 2 +- tests/html5ever-external-test.rs | 5 +++-- tests/tokenizer.rs | 4 ++-- tests/tree_builder.rs | 6 +++--- tests/util.rs | 2 +- 18 files changed, 86 insertions(+), 80 deletions(-) diff --git a/bench/bin.rs b/bench/bin.rs index f10a7655..ea0c2fb8 100644 --- a/bench/bin.rs +++ b/bench/bin.rs @@ -11,7 +11,7 @@ #![crate_type="bin"] #![feature(box_syntax)] -#![allow(unstable)] +#![feature(core, collections, io, os, path, test)] extern crate test; diff --git a/bench/tokenizer.rs b/bench/tokenizer.rs index df1a77a4..9a8a1865 100644 --- a/bench/tokenizer.rs +++ b/bench/tokenizer.rs @@ -7,7 +7,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::{io, os, cmp}; +use std::old_io as io; +use std::{os, cmp}; use std::default::Default; use std::vec::IntoIter; @@ -36,7 +37,7 @@ struct Bench { } impl Bench { - fn new(name: &str, size: Option, clone_only: bool, + fn new(name: &str, size: Option, clone_only: bool, opts: TokenizerOpts) -> Bench { let mut path = os::self_exe_path().expect("can't get exe path"); path.push("../data/bench/"); @@ -51,7 +52,7 @@ impl Bench { // Break the input into chunks of 1024 chars (= a few kB). // This simulates reading from the network. let mut input = vec![]; - let mut total = 0u; + let mut total = 0us; while total < size { // The by_ref() call is important, otherwise we get wrong results! // See rust-lang/rust#18045. @@ -90,7 +91,7 @@ impl TDynBenchFn for Bench { } } -fn make_bench(name: &str, size: Option, clone_only: bool, +fn make_bench(name: &str, size: Option, clone_only: bool, opts: TokenizerOpts) -> TestDescAndFn { TestDescAndFn { desc: TestDesc { diff --git a/examples/html2html.rs b/examples/html2html.rs index 91d07c55..5045f6a9 100644 --- a/examples/html2html.rs +++ b/examples/html2html.rs @@ -7,17 +7,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -/// Parse and re-serialize a HTML5 document. -/// -/// This is meant to produce the exact same output (ignoring stderr) as -/// -/// java -classpath htmlparser-1.4.jar nu.validator.htmlparser.tools.HTML2HTML -/// -/// where htmlparser-1.4.jar comes from http://about.validator.nu/htmlparser/ +#![feature(io)] + +//! Parse and re-serialize a HTML5 document. +//! +//! This is meant to produce the exact same output (ignoring stderr) as +//! +//! java -classpath htmlparser-1.4.jar nu.validator.htmlparser.tools.HTML2HTML +//! +//! where htmlparser-1.4.jar comes from http://about.validator.nu/htmlparser/ extern crate html5ever; -use std::io; +use std::old_io as io; use std::default::Default; use html5ever::sink::rcdom::RcDom; @@ -25,7 +27,6 @@ use html5ever::driver::ParseOpts; use html5ever::tree_builder::TreeBuilderOpts; use html5ever::{parse, one_input, serialize}; -#[allow(unstable)] fn main() { let input = io::stdin().read_to_string().unwrap(); let dom: RcDom = parse(one_input(input), ParseOpts { diff --git a/examples/noop-tokenize.rs b/examples/noop-tokenize.rs index 2cd311aa..f368b764 100644 --- a/examples/noop-tokenize.rs +++ b/examples/noop-tokenize.rs @@ -9,12 +9,13 @@ // Run a single benchmark once. For use with profiling tools. -#![allow(unstable)] +#![feature(core, os, io, test, path)] extern crate test; extern crate html5ever; -use std::{io, os}; +use std::old_io as io; +use std::os; use std::default::Default; use test::black_box; diff --git a/examples/noop-tree-builder.rs b/examples/noop-tree-builder.rs index aa298fdb..7491dfbd 100644 --- a/examples/noop-tree-builder.rs +++ b/examples/noop-tree-builder.rs @@ -7,13 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unstable)] +#![feature(io)] extern crate string_cache; extern crate html5ever; -use std::io; +use std::old_io as io; use std::default::Default; use std::string::String; use std::collections::HashMap; @@ -25,12 +25,12 @@ use html5ever::tokenizer::Attribute; use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText}; struct Sink { - next_id: uint, - names: HashMap, + next_id: usize, + names: HashMap, } impl Sink { - fn get_id(&mut self) -> uint { + fn get_id(&mut self) -> usize { let id = self.next_id; self.next_id += 1; id @@ -38,33 +38,33 @@ impl Sink { } impl TreeSink for Sink { - type Handle = uint; + type Handle = usize; - fn get_document(&mut self) -> uint { + fn get_document(&mut self) -> usize { 0 } - fn same_node(&self, x: uint, y: uint) -> bool { + fn same_node(&self, x: usize, y: usize) -> bool { x == y } - fn elem_name(&self, target: uint) -> QualName { + fn elem_name(&self, target: usize) -> QualName { self.names.get(&target).expect("not an element").clone() } - fn create_element(&mut self, name: QualName, _attrs: Vec) -> uint { + fn create_element(&mut self, name: QualName, _attrs: Vec) -> usize { let id = self.get_id(); self.names.insert(id, name); id } - fn create_comment(&mut self, _text: String) -> uint { + fn create_comment(&mut self, _text: String) -> usize { self.get_id() } fn append_before_sibling(&mut self, - _sibling: uint, - _new_node: NodeOrText) -> Result<(), NodeOrText> { + _sibling: usize, + _new_node: NodeOrText) -> Result<(), NodeOrText> { // `sibling` will have a parent unless a script moved it, and we're // not running scripts. Therefore we can aways return `Ok(())`. Ok(()) @@ -72,12 +72,12 @@ impl TreeSink for Sink { fn parse_error(&mut self, _msg: CowString<'static>) { } fn set_quirks_mode(&mut self, _mode: QuirksMode) { } - fn append(&mut self, _parent: uint, _child: NodeOrText) { } + fn append(&mut self, _parent: usize, _child: NodeOrText) { } fn append_doctype_to_document(&mut self, _name: String, _public_id: String, _system_id: String) { } - fn add_attrs_if_missing(&mut self, _target: uint, _attrs: Vec) { } - fn remove_from_parent(&mut self, _target: uint) { } - fn mark_script_already_started(&mut self, _node: uint) { } + fn add_attrs_if_missing(&mut self, _target: usize, _attrs: Vec) { } + fn remove_from_parent(&mut self, _target: usize) { } + fn mark_script_already_started(&mut self, _node: usize) { } } fn main() { diff --git a/examples/print-rcdom.rs b/examples/print-rcdom.rs index 9cd42c7f..1997840e 100644 --- a/examples/print-rcdom.rs +++ b/examples/print-rcdom.rs @@ -7,8 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(plugin)] -#![allow(unstable)] +#![feature(plugin, io)] extern crate html5ever; @@ -17,7 +16,7 @@ extern crate string_cache; #[macro_use] extern crate string_cache_macros; -use std::io; +use std::old_io as io; use std::iter::repeat; use std::default::Default; use std::string::String; @@ -28,7 +27,7 @@ use html5ever::{parse, one_input}; // This is not proper HTML serialization, of course. -fn walk(indent: uint, handle: Handle) { +fn walk(indent: usize, handle: Handle) { let node = handle.borrow(); // FIXME: don't allocate print!("{}", repeat(" ").take(indent).collect::()); diff --git a/examples/print-tree-actions.rs b/examples/print-tree-actions.rs index b1d18157..0f4d0e33 100644 --- a/examples/print-tree-actions.rs +++ b/examples/print-tree-actions.rs @@ -7,13 +7,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unstable)] +#![feature(io)] extern crate string_cache; extern crate html5ever; -use std::io; +use std::old_io as io; use std::default::Default; use std::string::String; use std::collections::HashMap; @@ -25,12 +25,12 @@ use html5ever::tokenizer::Attribute; use html5ever::tree_builder::{TreeSink, QuirksMode, NodeOrText, AppendNode, AppendText}; struct Sink { - next_id: uint, - names: HashMap, + next_id: usize, + names: HashMap, } impl Sink { - fn get_id(&mut self) -> uint { + fn get_id(&mut self) -> usize { let id = self.next_id; self.next_id += 1; id @@ -38,13 +38,13 @@ impl Sink { } impl TreeSink for Sink { - type Handle = uint; + type Handle = usize; fn parse_error(&mut self, msg: CowString<'static>) { println!("Parse error: {}", msg); } - fn get_document(&mut self) -> uint { + fn get_document(&mut self) -> usize { 0 } @@ -52,28 +52,28 @@ impl TreeSink for Sink { println!("Set quirks mode to {:?}", mode); } - fn same_node(&self, x: uint, y: uint) -> bool { + fn same_node(&self, x: usize, y: usize) -> bool { x == y } - fn elem_name(&self, target: uint) -> QualName { + fn elem_name(&self, target: usize) -> QualName { self.names.get(&target).expect("not an element").clone() } - fn create_element(&mut self, name: QualName, _attrs: Vec) -> uint { + fn create_element(&mut self, name: QualName, _attrs: Vec) -> usize { let id = self.get_id(); println!("Created {:?} as {}", name, id); self.names.insert(id, name); id } - fn create_comment(&mut self, text: String) -> uint { + fn create_comment(&mut self, text: String) -> usize { let id = self.get_id(); println!("Created comment \"{}\" as {}", text.escape_default(), id); id } - fn append(&mut self, parent: uint, child: NodeOrText) { + fn append(&mut self, parent: usize, child: NodeOrText) { match child { AppendNode(n) => println!("Append node {} to {}", n, parent), @@ -83,8 +83,8 @@ impl TreeSink for Sink { } fn append_before_sibling(&mut self, - sibling: uint, - new_node: NodeOrText) -> Result<(), NodeOrText> { + sibling: usize, + new_node: NodeOrText) -> Result<(), NodeOrText> { match new_node { AppendNode(n) => println!("Append node {} before {}", n, sibling), @@ -101,18 +101,18 @@ impl TreeSink for Sink { println!("Append doctype: {} {} {}", name, public_id, system_id); } - fn add_attrs_if_missing(&mut self, target: uint, attrs: Vec) { + fn add_attrs_if_missing(&mut self, target: usize, attrs: Vec) { println!("Add missing attributes to {}:", target); for attr in attrs.into_iter() { println!(" {:?} = {}", attr.name, attr.value); } } - fn remove_from_parent(&mut self, target: uint) { + fn remove_from_parent(&mut self, target: usize) { println!("Remove {} from parent", target); } - fn mark_script_already_started(&mut self, node: uint) { + fn mark_script_already_started(&mut self, node: usize) { println!("Mark script {} as already started", node); } } diff --git a/examples/tokenize.rs b/examples/tokenize.rs index 79f3dbd5..b7cad825 100644 --- a/examples/tokenize.rs +++ b/examples/tokenize.rs @@ -7,11 +7,11 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(unstable)] +#![feature(core, io)] extern crate html5ever; -use std::io; +use std::old_io as io; use std::default::Default; use html5ever::tokenizer::{TokenSink, Token, TokenizerOpts, ParseError}; diff --git a/macros/src/lib.rs b/macros/src/lib.rs index c33d01cb..ec458ec2 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -11,12 +11,12 @@ #![crate_type="dylib"] #![feature(plugin_registrar, quote, old_orphan_check)] +#![feature(rustc_private, std_misc, core, hash, collections, path, io)] #![deny(warnings)] -#![allow(unstable)] extern crate syntax; extern crate rustc; -extern crate serialize; +extern crate "serialize" as rustc_serialize; use rustc::plugin::Registry; diff --git a/macros/src/named_entities.rs b/macros/src/named_entities.rs index f1780cb3..63cccc42 100644 --- a/macros/src/named_entities.rs +++ b/macros/src/named_entities.rs @@ -9,14 +9,14 @@ #![allow(unused_imports)] // for quotes -use std::io; +use std::old_io as io; use std::path; use std::str::FromStr; -use serialize::json; -use serialize::json::Json; -use serialize::Decodable; use std::collections::HashMap; +use rustc_serialize::json; +use rustc_serialize::json::Json; +use rustc_serialize::Decodable; use syntax::codemap::Span; use syntax::ast::{Path, ExprLit, Lit_, TokenTree, TtToken}; use syntax::parse::token; @@ -25,7 +25,7 @@ use syntax::ext::source_util::expand_file; // A struct matching the entries in entities.json. // Simplifies JSON parsing because we can use Decodable. -#[derive(Decodable)] +#[derive(RustcDecodable)] struct CharRef { codepoints: Vec, //characters: String, // Present in the file but we don't need it diff --git a/src/lib.rs b/src/lib.rs index d2039e1b..aa4ed242 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -11,11 +11,13 @@ #![crate_type="dylib"] #![feature(plugin, int_uint, box_syntax)] +#![feature(core, hash, collections, alloc)] +#![cfg_attr(not(for_c), feature(rustc_private, io))] +#![cfg_attr(for_c, feature(libc))] #![deny(warnings)] -#![allow(unused_parens, unstable)] +#![allow(unused_parens)] -// Don't implicitly pull in things from std::* -// This helps us make a C-friendly library. +// FIXME(#63): switch back to using std #![no_std] extern crate alloc; diff --git a/src/serialize/mod.rs b/src/serialize/mod.rs index a0d3fbe0..5d5cb9e8 100644 --- a/src/serialize/mod.rs +++ b/src/serialize/mod.rs @@ -9,7 +9,7 @@ use core::prelude::*; -use std::io::{Writer, IoResult}; +use std::old_io::{Writer, IoResult}; use core::default::Default; use collections::vec::Vec; diff --git a/src/sink/owned_dom.rs b/src/sink/owned_dom.rs index 4ea02fd8..f5964371 100644 --- a/src/sink/owned_dom.rs +++ b/src/sink/owned_dom.rs @@ -7,9 +7,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![experimental="This module uses unsafe code, has not been thoroughly \ - audited, and the performance gains vs. RcDom have not \ - been demonstrated"] +#![unstable(feature="string_cache_namespace", + reason="This module uses unsafe code, has not been thoroughly \ + audited, and the performance gains vs. RcDom have not \ + been demonstrated")] //! A simple DOM where every node is owned by its parent. //! @@ -37,7 +38,7 @@ use alloc::boxed::Box; use collections::vec::Vec; use collections::string::String; use std::string::CowString; -use std::io::{Writer, IoResult}; +use std::old_io::{Writer, IoResult}; use std::collections::HashSet; use std::ops::{Deref, DerefMut}; diff --git a/src/sink/rcdom.rs b/src/sink/rcdom.rs index 48f4104e..5465cc57 100644 --- a/src/sink/rcdom.rs +++ b/src/sink/rcdom.rs @@ -28,7 +28,7 @@ use alloc::rc::{Rc, Weak}; use collections::vec::Vec; use collections::string::String; use std::string::CowString; -use std::io::{Writer, IoResult}; +use std::old_io::{Writer, IoResult}; use std::ops::DerefMut; use string_cache::QualName; diff --git a/tests/html5ever-external-test.rs b/tests/html5ever-external-test.rs index 585b4ae2..44249eed 100644 --- a/tests/html5ever-external-test.rs +++ b/tests/html5ever-external-test.rs @@ -11,7 +11,7 @@ #![crate_type="bin"] #![feature(plugin)] -#![allow(unstable)] +#![feature(rustc_private, core, collections, io, os, path, std_misc, test)] extern crate test; extern crate serialize; @@ -22,7 +22,8 @@ extern crate string_cache_macros; extern crate html5ever; -use std::{io, os}; +use std::old_io as io; +use std::os; use std::str::FromStr; use std::collections::HashSet; use test::test_main; diff --git a/tests/tokenizer.rs b/tests/tokenizer.rs index d02484f6..cd925c30 100644 --- a/tests/tokenizer.rs +++ b/tests/tokenizer.rs @@ -32,12 +32,12 @@ use string_cache::{Atom, QualName}; // Return all ways of splitting the string into at most n // possibly-empty pieces. -fn splits(s: &str, n: uint) -> Vec> { +fn splits(s: &str, n: usize) -> Vec> { if n == 1 { return vec!(vec!(s.to_string())); } - let mut points: Vec = s.char_indices().map(|(n,_)| n).collect(); + let mut points: Vec = s.char_indices().map(|(n,_)| n).collect(); points.push(s.len()); // do this with iterators? diff --git a/tests/tree_builder.rs b/tests/tree_builder.rs index c637da69..76c47738 100644 --- a/tests/tree_builder.rs +++ b/tests/tree_builder.rs @@ -9,7 +9,7 @@ use util::foreach_html5lib_test; -use std::io; +use std::old_io as io; use std::iter::repeat; use std::mem::replace; use std::default::Default; @@ -65,7 +65,7 @@ fn parse_tests>(mut lines: It) -> Vec().as_slice()); @@ -127,7 +127,7 @@ fn make_test( tests: &mut Vec, ignores: &HashSet, path_str: &str, - idx: uint, + idx: usize, fields: HashMap) { let get_field = |&:key| { diff --git a/tests/util.rs b/tests/util.rs index 54b356ff..2db65bb9 100644 --- a/tests/util.rs +++ b/tests/util.rs @@ -7,7 +7,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::io; +use std::old_io as io; use std::path::Path; pub fn foreach_html5lib_test(