Skip to content

Commit c9a7003

Browse files
committed
Clean up warnings
1 parent aa08186 commit c9a7003

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

data-url/src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ impl<'a> FragmentIdentifier<'a> {
104104
// Ignore ASCII tabs or newlines like the URL parser would
105105
b'\t' | b'\n' | b'\r' => continue,
106106
// https://url.spec.whatwg.org/#fragment-percent-encode-set
107-
b'\0'...b' ' | b'"' | b'<' | b'>' | b'`' | b'\x7F'...b'\xFF' => {
107+
b'\0'..=b' ' | b'"' | b'<' | b'>' | b'`' | b'\x7F'..=b'\xFF' => {
108108
percent_encode(byte, &mut string)
109109
}
110110
// Printable ASCII
@@ -183,7 +183,7 @@ fn parse_header(from_colon_to_comma: &str) -> (mime::Mime, bool) {
183183
b'\t' | b'\n' | b'\r' => continue,
184184

185185
// https://url.spec.whatwg.org/#c0-control-percent-encode-set
186-
b'\0'...b'\x1F' | b'\x7F'...b'\xFF' => percent_encode(byte, &mut string),
186+
b'\0'..=b'\x1F' | b'\x7F'..=b'\xFF' => percent_encode(byte, &mut string),
187187

188188
// Bytes other than the C0 percent-encode set that are percent-encoded
189189
// by the URL parser in the query state.

data-url/src/mime.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ fn contains(parameters: &[(String, String)], name: &str) -> bool {
116116
fn valid_value(s: &str) -> bool {
117117
s.chars().all(|c| {
118118
// <https://mimesniff.spec.whatwg.org/#http-quoted-string-token-code-point>
119-
matches!(c, '\t' | ' '...'~' | '\u{80}'...'\u{FF}')
119+
matches!(c, '\t' | ' '..='~' | '\u{80}'..='\u{FF}')
120120
}) && !s.is_empty()
121121
}
122122

src/parser.rs

+5-9
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ macro_rules! simple_enum_error {
6262
__FutureProof,
6363
}
6464

65-
impl Error for ParseError {
66-
fn description(&self) -> &str {
65+
impl fmt::Display for ParseError {
66+
fn fmt(&self, fmt: &mut Formatter<'_>) -> fmt::Result {
6767
match *self {
6868
$(
69-
ParseError::$name => $description,
69+
ParseError::$name => fmt.write_str($description),
7070
)+
7171
ParseError::__FutureProof => {
7272
unreachable!("Don't abuse the FutureProof!");
@@ -77,6 +77,8 @@ macro_rules! simple_enum_error {
7777
}
7878
}
7979

80+
impl Error for ParseError {}
81+
8082
simple_enum_error! {
8183
EmptyHost => "empty host",
8284
IdnaError => "invalid international domain name",
@@ -90,12 +92,6 @@ simple_enum_error! {
9092
Overflow => "URLs more than 4 GB are not supported",
9193
}
9294

93-
impl fmt::Display for ParseError {
94-
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
95-
fmt::Display::fmt(self.description(), f)
96-
}
97-
}
98-
9995
impl From<::idna::Errors> for ParseError {
10096
fn from(_: ::idna::Errors) -> ParseError {
10197
ParseError::IdnaError

tests/data.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn run_parsing(input: &str, base: &str, expected: Result<ExpectedAttributes, ()>
6161
{
6262
$(
6363
assert_eq!(expected.$attr, quirks::$attr(&url));
64-
)+;
64+
)+
6565
}
6666
}
6767
}

0 commit comments

Comments
 (0)