From 1e24afcfd014e1eff9020c07fed66f991ef166f0 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Sun, 21 Nov 2021 14:42:00 -0500 Subject: [PATCH 1/2] Don't run bench for 1.41.0. --- .github/workflows/main.yml | 3 +++ html5ever/Cargo.toml | 2 ++ xml5ever/Cargo.toml | 2 ++ 3 files changed, 7 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b303b947..e18e7760 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -24,7 +24,10 @@ jobs: run: git submodule update --init - name: Cargo bench + if: matrix.version != '1.41.0' run: cargo bench --all + env: + RUSTFLAGS: --cfg bench - name: Test "rustc-test/capture" feature if: matrix.version == 'nightly' diff --git a/html5ever/Cargo.toml b/html5ever/Cargo.toml index 3caf8c61..2096f5a7 100644 --- a/html5ever/Cargo.toml +++ b/html5ever/Cargo.toml @@ -18,6 +18,8 @@ markup5ever = { version = "0.10", path = "../markup5ever" } [dev-dependencies] typed-arena = "1.3.0" + +[target.'cfg(bench)'.dev-dependencies] criterion = "0.3" [build-dependencies] diff --git a/xml5ever/Cargo.toml b/xml5ever/Cargo.toml index 0547d69d..cb7d548c 100644 --- a/xml5ever/Cargo.toml +++ b/xml5ever/Cargo.toml @@ -23,6 +23,8 @@ markup5ever = {version = "0.10", path = "../markup5ever" } [dev-dependencies] rustc-test = "0.3" + +[target.'cfg(bench)'.dev-dependencies] criterion = "0.3" [[bench]] From 97254c86f8e5892fdc118a2695846bec946d40f7 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Sun, 21 Nov 2021 15:39:39 -0500 Subject: [PATCH 2/2] Fix macro semicolon warnings. --- html5ever/src/tokenizer/mod.rs | 50 +++++++++++++++--------------- xml5ever/src/tokenizer/mod.rs | 56 +++++++++++++++++----------------- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/html5ever/src/tokenizer/mod.rs b/html5ever/src/tokenizer/mod.rs index 267fdf3e..9fc2b61b 100644 --- a/html5ever/src/tokenizer/mod.rs +++ b/html5ever/src/tokenizer/mod.rs @@ -575,30 +575,30 @@ impl Tokenizer { // Shorthand for common state machine behaviors. macro_rules! shorthand ( - ( $me:ident : emit $c:expr ) => ( $me.emit_char($c); ); - ( $me:ident : create_tag $kind:ident $c:expr ) => ( $me.create_tag($kind, $c); ); - ( $me:ident : push_tag $c:expr ) => ( $me.current_tag_name.push_char($c); ); - ( $me:ident : discard_tag ) => ( $me.discard_tag(); ); - ( $me:ident : discard_char $input:expr ) => ( $me.discard_char($input); ); - ( $me:ident : push_temp $c:expr ) => ( $me.temp_buf.push_char($c); ); - ( $me:ident : emit_temp ) => ( $me.emit_temp_buf(); ); - ( $me:ident : clear_temp ) => ( $me.clear_temp_buf(); ); - ( $me:ident : create_attr $c:expr ) => ( $me.create_attribute($c); ); - ( $me:ident : push_name $c:expr ) => ( $me.current_attr_name.push_char($c); ); - ( $me:ident : push_value $c:expr ) => ( $me.current_attr_value.push_char($c); ); - ( $me:ident : append_value $c:expr ) => ( $me.current_attr_value.push_tendril($c); ); - ( $me:ident : push_comment $c:expr ) => ( $me.current_comment.push_char($c); ); - ( $me:ident : append_comment $c:expr ) => ( $me.current_comment.push_slice($c); ); - ( $me:ident : emit_comment ) => ( $me.emit_current_comment(); ); - ( $me:ident : clear_comment ) => ( $me.current_comment.clear(); ); - ( $me:ident : create_doctype ) => ( $me.current_doctype = Doctype::new(); ); - ( $me:ident : push_doctype_name $c:expr ) => ( option_push(&mut $me.current_doctype.name, $c); ); - ( $me:ident : push_doctype_id $k:ident $c:expr ) => ( option_push($me.doctype_id($k), $c); ); - ( $me:ident : clear_doctype_id $k:ident ) => ( $me.clear_doctype_id($k); ); - ( $me:ident : force_quirks ) => ( $me.current_doctype.force_quirks = true; ); - ( $me:ident : emit_doctype ) => ( $me.emit_current_doctype(); ); - ( $me:ident : error ) => ( $me.bad_char_error(); ); - ( $me:ident : error_eof ) => ( $me.bad_eof_error(); ); + ( $me:ident : emit $c:expr ) => ( $me.emit_char($c) ); + ( $me:ident : create_tag $kind:ident $c:expr ) => ( $me.create_tag($kind, $c) ); + ( $me:ident : push_tag $c:expr ) => ( $me.current_tag_name.push_char($c) ); + ( $me:ident : discard_tag ) => ( $me.discard_tag() ); + ( $me:ident : discard_char $input:expr ) => ( $me.discard_char($input) ); + ( $me:ident : push_temp $c:expr ) => ( $me.temp_buf.push_char($c) ); + ( $me:ident : emit_temp ) => ( $me.emit_temp_buf() ); + ( $me:ident : clear_temp ) => ( $me.clear_temp_buf() ); + ( $me:ident : create_attr $c:expr ) => ( $me.create_attribute($c) ); + ( $me:ident : push_name $c:expr ) => ( $me.current_attr_name.push_char($c) ); + ( $me:ident : push_value $c:expr ) => ( $me.current_attr_value.push_char($c) ); + ( $me:ident : append_value $c:expr ) => ( $me.current_attr_value.push_tendril($c) ); + ( $me:ident : push_comment $c:expr ) => ( $me.current_comment.push_char($c) ); + ( $me:ident : append_comment $c:expr ) => ( $me.current_comment.push_slice($c) ); + ( $me:ident : emit_comment ) => ( $me.emit_current_comment() ); + ( $me:ident : clear_comment ) => ( $me.current_comment.clear() ); + ( $me:ident : create_doctype ) => ( $me.current_doctype = Doctype::new() ); + ( $me:ident : push_doctype_name $c:expr ) => ( option_push(&mut $me.current_doctype.name, $c) ); + ( $me:ident : push_doctype_id $k:ident $c:expr ) => ( option_push($me.doctype_id($k), $c) ); + ( $me:ident : clear_doctype_id $k:ident ) => ( $me.clear_doctype_id($k) ); + ( $me:ident : force_quirks ) => ( $me.current_doctype.force_quirks = true ); + ( $me:ident : emit_doctype ) => ( $me.emit_current_doctype() ); + ( $me:ident : error ) => ( $me.bad_char_error() ); + ( $me:ident : error_eof ) => ( $me.bad_eof_error() ); ); // Tracing of tokenizer actions. This adds significant bloat and compile time, @@ -644,7 +644,7 @@ macro_rules! go ( ( $me:ident : eof ) => ({ $me.emit_eof(); return ProcessResult::Suspend; }); // If nothing else matched, it's a single command - ( $me:ident : $($cmd:tt)+ ) => ( sh_trace!($me: $($cmd)+); ); + ( $me:ident : $($cmd:tt)+ ) => ( sh_trace!($me: $($cmd)+) ); // or nothing. ( $me:ident : ) => (()); diff --git a/xml5ever/src/tokenizer/mod.rs b/xml5ever/src/tokenizer/mod.rs index 97b10669..51222bc7 100644 --- a/xml5ever/src/tokenizer/mod.rs +++ b/xml5ever/src/tokenizer/mod.rs @@ -517,33 +517,33 @@ impl XmlTokenizer { // Shorthand for common state machine behaviors. macro_rules! shorthand ( - ( $me:ident : emit $c:expr ) => ( $me.emit_char($c); ); - ( $me:ident : create_tag $kind:ident $c:expr ) => ( $me.create_tag($kind, $c); ); - ( $me:ident : push_tag $c:expr ) => ( $me.current_tag_name.push_char($c); ); - ( $me:ident : discard_tag $input:expr ) => ( $me.discard_tag($input); ); - ( $me:ident : discard_char ) => ( $me.discard_char(); ); - ( $me:ident : push_temp $c:expr ) => ( $me.temp_buf.push_char($c); ); - ( $me:ident : emit_temp ) => ( $me.emit_temp_buf(); ); - ( $me:ident : clear_temp ) => ( $me.clear_temp_buf(); ); - ( $me:ident : create_attr $c:expr ) => ( $me.create_attribute($c); ); - ( $me:ident : push_name $c:expr ) => ( $me.current_attr_name.push_char($c); ); - ( $me:ident : push_value $c:expr ) => ( $me.current_attr_value.push_char($c); ); - ( $me:ident : append_value $c:expr ) => ( $me.current_attr_value.push_tendril($c); ); - ( $me:ident : push_comment $c:expr ) => ( $me.current_comment.push_char($c); ); - ( $me:ident : append_comment $c:expr ) => ( $me.current_comment.push_slice($c); ); - ( $me:ident : emit_comment ) => ( $me.emit_current_comment(); ); - ( $me:ident : clear_comment ) => ( $me.current_comment.clear(); ); - ( $me:ident : create_doctype ) => ( $me.current_doctype = Doctype::new(); ); - ( $me:ident : push_doctype_name $c:expr ) => ( option_push(&mut $me.current_doctype.name, $c); ); - ( $me:ident : push_doctype_id $k:ident $c:expr ) => ( option_push($me.doctype_id($k), $c); ); - ( $me:ident : clear_doctype_id $k:ident ) => ( $me.clear_doctype_id($k); ); - ( $me:ident : emit_doctype ) => ( $me.emit_current_doctype(); ); - ( $me:ident : error ) => ( $me.bad_char_error(); ); - ( $me:ident : error_eof ) => ( $me.bad_eof_error(); ); - ( $me:ident : create_pi $c:expr ) => ( $me.create_pi($c); ); - ( $me:ident : push_pi_target $c:expr ) => ( $me.current_pi_target.push_char($c); ); - ( $me:ident : push_pi_data $c:expr ) => ( $me.current_pi_data.push_char($c); ); - ( $me:ident : set_empty_tag ) => ( $me.set_empty_tag(); ); + ( $me:ident : emit $c:expr ) => ( $me.emit_char($c) ); + ( $me:ident : create_tag $kind:ident $c:expr ) => ( $me.create_tag($kind, $c) ); + ( $me:ident : push_tag $c:expr ) => ( $me.current_tag_name.push_char($c) ); + ( $me:ident : discard_tag $input:expr ) => ( $me.discard_tag($input) ); + ( $me:ident : discard_char ) => ( $me.discard_char() ); + ( $me:ident : push_temp $c:expr ) => ( $me.temp_buf.push_char($c) ); + ( $me:ident : emit_temp ) => ( $me.emit_temp_buf() ); + ( $me:ident : clear_temp ) => ( $me.clear_temp_buf() ); + ( $me:ident : create_attr $c:expr ) => ( $me.create_attribute($c) ); + ( $me:ident : push_name $c:expr ) => ( $me.current_attr_name.push_char($c) ); + ( $me:ident : push_value $c:expr ) => ( $me.current_attr_value.push_char($c) ); + ( $me:ident : append_value $c:expr ) => ( $me.current_attr_value.push_tendril($c) ); + ( $me:ident : push_comment $c:expr ) => ( $me.current_comment.push_char($c) ); + ( $me:ident : append_comment $c:expr ) => ( $me.current_comment.push_slice($c) ); + ( $me:ident : emit_comment ) => ( $me.emit_current_comment() ); + ( $me:ident : clear_comment ) => ( $me.current_comment.clear() ); + ( $me:ident : create_doctype ) => ( $me.current_doctype = Doctype::new() ); + ( $me:ident : push_doctype_name $c:expr ) => ( option_push(&mut $me.current_doctype.name, $c) ); + ( $me:ident : push_doctype_id $k:ident $c:expr ) => ( option_push($me.doctype_id($k), $c) ); + ( $me:ident : clear_doctype_id $k:ident ) => ( $me.clear_doctype_id($k) ); + ( $me:ident : emit_doctype ) => ( $me.emit_current_doctype() ); + ( $me:ident : error ) => ( $me.bad_char_error() ); + ( $me:ident : error_eof ) => ( $me.bad_eof_error() ); + ( $me:ident : create_pi $c:expr ) => ( $me.create_pi($c) ); + ( $me:ident : push_pi_target $c:expr ) => ( $me.current_pi_target.push_char($c) ); + ( $me:ident : push_pi_data $c:expr ) => ( $me.current_pi_data.push_char($c) ); + ( $me:ident : set_empty_tag ) => ( $me.set_empty_tag() ); ); // Tracing of tokenizer actions. This adds significant bloat and compile time, @@ -615,7 +615,7 @@ macro_rules! go ( ( $me:ident : eof ) => ({ $me.emit_eof(); return false; }); // If nothing else matched, it's a single command - ( $me:ident : $($cmd:tt)+ ) => ( sh_trace!($me: $($cmd)+); ); + ( $me:ident : $($cmd:tt)+ ) => ( sh_trace!($me: $($cmd)+) ); // or nothing. ( $me:ident : ) => (());