Skip to content

Commit bb62eac

Browse files
Don't ignore warnings in html5ever/src/tree_builder (#551)
* remove unnecessary references Signed-off-by: Simon Wülker <[email protected]> * remove unused imports Signed-off-by: Simon Wülker <[email protected]> * Restrict visibility of unreachable public items This addresses the clippy::unreachable_pub lint Signed-off-by: Simon Wülker <[email protected]> * Replace .filter(..).next() calls with .find(..) Signed-off-by: Simon Wülker <[email protected]> * Remove unneeded "mut" qualifiers Signed-off-by: Simon Wülker <[email protected]> * Don't call .map with functions returning () This fixes a clippy lint Signed-off-by: Simon Wülker <[email protected]> * Replace trivial matches These can all either use if-let branches or the matches! macro Signed-off-by: Simon Wülker <[email protected]> * ignore clippy warnings in autogenerated code Signed-off-by: Simon Wülker <[email protected]> * Elide lifetimes where possible Signed-off-by: Simon Wülker <[email protected]> * Remove empty string literals in println! Signed-off-by: Simon Wülker <[email protected]> * Use Option::as_ref/as_deref where possible Signed-off-by: Simon Wülker <[email protected]> * Remove unneeded () returns Signed-off-by: Simon Wülker <[email protected]> * Remove unneeded field names Signed-off-by: Simon Wülker <[email protected]> * Simplify pop_until_current a bit This also fixes a clippy warning Signed-off-by: Simon Wülker <[email protected]> * Ignore some variants that are never constructed This is necessary to allow html5ever to build (due to #[deny(warnings)]. We might want to remove these in the future, but I'm not sure whether they're necessary. * Format `html5ever/src/tree_builder/mod.rs` Signed-off-by: Martin Robinson <[email protected]> --------- Signed-off-by: Simon Wülker <[email protected]> Signed-off-by: Martin Robinson <[email protected]> Co-authored-by: Martin Robinson <[email protected]>
1 parent e6f0018 commit bb62eac

File tree

6 files changed

+145
-145
lines changed

6 files changed

+145
-145
lines changed

html5ever/src/macros.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ macro_rules! unwrap_or_else {
1515
}
1616

1717
macro_rules! unwrap_or_return {
18+
($opt:expr) => {
19+
unwrap_or_else!($opt, {
20+
return;
21+
})
22+
};
1823
($opt:expr, $retval:expr) => {
1924
unwrap_or_else!($opt, { return $retval })
2025
};

html5ever/src/tree_builder/data.rs

Lines changed: 39 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::tendril::StrTendril;
1212
use crate::tokenizer::Doctype;
1313

1414
// These should all be lowercase, for ASCII-case-insensitive matching.
15-
static QUIRKY_PUBLIC_PREFIXES: &'static [&'static str] = &[
15+
static QUIRKY_PUBLIC_PREFIXES: &[&str] = &[
1616
"-//advasoft ltd//dtd html 3.0 aswedit + extensions//",
1717
"-//as//dtd html 3.0 aswedit + extensions//",
1818
"-//ietf//dtd html 2.0 level 1//",
@@ -69,35 +69,35 @@ static QUIRKY_PUBLIC_PREFIXES: &'static [&'static str] = &[
6969
"-//webtechs//dtd mozilla html//",
7070
];
7171

72-
static QUIRKY_PUBLIC_MATCHES: &'static [&'static str] = &[
72+
static QUIRKY_PUBLIC_MATCHES: &[&str] = &[
7373
"-//w3o//dtd w3 html strict 3.0//en//",
7474
"-/w3c/dtd html 4.0 transitional/en",
7575
"html",
7676
];
7777

78-
static QUIRKY_SYSTEM_MATCHES: &'static [&'static str] =
78+
static QUIRKY_SYSTEM_MATCHES: &[&str] =
7979
&["http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd"];
8080

81-
static LIMITED_QUIRKY_PUBLIC_PREFIXES: &'static [&'static str] = &[
81+
static LIMITED_QUIRKY_PUBLIC_PREFIXES: &[&str] = &[
8282
"-//w3c//dtd xhtml 1.0 frameset//",
8383
"-//w3c//dtd xhtml 1.0 transitional//",
8484
];
8585

86-
static HTML4_PUBLIC_PREFIXES: &'static [&'static str] = &[
86+
static HTML4_PUBLIC_PREFIXES: &[&str] = &[
8787
"-//w3c//dtd html 4.01 frameset//",
8888
"-//w3c//dtd html 4.01 transitional//",
8989
];
9090

91-
pub fn doctype_error_and_quirks(doctype: &Doctype, iframe_srcdoc: bool) -> (bool, QuirksMode) {
92-
fn opt_string_as_slice<'t>(x: &'t Option<String>) -> Option<&'t str> {
93-
x.as_ref().map(|y| &y[..])
91+
pub(crate) fn doctype_error_and_quirks(
92+
doctype: &Doctype,
93+
iframe_srcdoc: bool,
94+
) -> (bool, QuirksMode) {
95+
fn opt_string_as_slice(x: &Option<String>) -> Option<&str> {
96+
x.as_deref()
9497
}
9598

96-
fn opt_tendril_as_slice<'t>(x: &'t Option<StrTendril>) -> Option<&'t str> {
97-
match *x {
98-
Some(ref t) => Some(t),
99-
None => None,
100-
}
99+
fn opt_tendril_as_slice(x: &Option<StrTendril>) -> Option<&str> {
100+
x.as_deref()
101101
}
102102

103103
fn opt_to_ascii_lower(x: Option<&str>) -> Option<String> {
@@ -108,34 +108,33 @@ pub fn doctype_error_and_quirks(doctype: &Doctype, iframe_srcdoc: bool) -> (bool
108108
let public = opt_tendril_as_slice(&doctype.public_id);
109109
let system = opt_tendril_as_slice(&doctype.system_id);
110110

111-
let err = match (name, public, system) {
111+
let err = !matches!(
112+
(name, public, system),
112113
(Some("html"), None, None)
113-
| (Some("html"), None, Some("about:legacy-compat"))
114-
| (Some("html"), Some("-//W3C//DTD HTML 4.0//EN"), None)
115-
| (
116-
Some("html"),
117-
Some("-//W3C//DTD HTML 4.0//EN"),
118-
Some("http://www.w3.org/TR/REC-html40/strict.dtd"),
119-
)
120-
| (Some("html"), Some("-//W3C//DTD HTML 4.01//EN"), None)
121-
| (
122-
Some("html"),
123-
Some("-//W3C//DTD HTML 4.01//EN"),
124-
Some("http://www.w3.org/TR/html4/strict.dtd"),
125-
)
126-
| (
127-
Some("html"),
128-
Some("-//W3C//DTD XHTML 1.0 Strict//EN"),
129-
Some("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"),
130-
)
131-
| (
132-
Some("html"),
133-
Some("-//W3C//DTD XHTML 1.1//EN"),
134-
Some("http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"),
135-
) => false,
136-
137-
_ => true,
138-
};
114+
| (Some("html"), None, Some("about:legacy-compat"))
115+
| (Some("html"), Some("-//W3C//DTD HTML 4.0//EN"), None)
116+
| (
117+
Some("html"),
118+
Some("-//W3C//DTD HTML 4.0//EN"),
119+
Some("http://www.w3.org/TR/REC-html40/strict.dtd"),
120+
)
121+
| (Some("html"), Some("-//W3C//DTD HTML 4.01//EN"), None)
122+
| (
123+
Some("html"),
124+
Some("-//W3C//DTD HTML 4.01//EN"),
125+
Some("http://www.w3.org/TR/html4/strict.dtd"),
126+
)
127+
| (
128+
Some("html"),
129+
Some("-//W3C//DTD XHTML 1.0 Strict//EN"),
130+
Some("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"),
131+
)
132+
| (
133+
Some("html"),
134+
Some("-//W3C//DTD XHTML 1.1//EN"),
135+
Some("http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"),
136+
)
137+
);
139138

140139
// FIXME: We could do something asymptotically faster here.
141140
// But there aren't many strings, and this happens at most once per parse.

0 commit comments

Comments
 (0)