Fix clippy warnings

This commit is contained in:
Fabrice Reix 2023-08-31 11:31:44 +02:00
parent 1ddda4c86b
commit da233dbd7a
No known key found for this signature in database
GPG Key ID: BF5213154B2E7155
10 changed files with 20 additions and 20 deletions

View File

@ -41,7 +41,7 @@ mod tests {
#[test]
fn eval_html_escape() {
let tests = vec![
let tests = [
("foo", "foo"),
("<tag>", "&lt;tag&gt;"),
("foo & bar", "foo &amp; bar"),

View File

@ -684,7 +684,7 @@ fn get_redirect_url(location: &str, base_url: &str) -> String {
fn get_redirect_method(response_status: u32, original_method: Method) -> Method {
// This replicates curl's behavior
match response_status {
301 | 302 | 303 => Method("GET".to_string()),
301..=303 => Method("GET".to_string()),
// Could be only 307 and 308, but curl does this for all 3xx
// codes not converted to GET above.
_ => original_method,

View File

@ -264,7 +264,7 @@ pub mod tests {
#[test]
fn test_uncompress_brotli() {
let data = vec![
let data = [
0x21, 0x2c, 0x00, 0x04, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x57, 0x6f, 0x72, 0x6c,
0x64, 0x21, 0x03,
];
@ -273,7 +273,7 @@ pub mod tests {
#[test]
fn test_uncompress_gzip() {
let data = vec![
let data = [
0x1f, 0x8b, 0x08, 0x08, 0xa7, 0x52, 0x85, 0x5f, 0x00, 0x03, 0x64, 0x61, 0x74, 0x61,
0x2e, 0x74, 0x78, 0x74, 0x00, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x08, 0xcf, 0x2f,
0xca, 0x49, 0x51, 0x04, 0x00, 0xa3, 0x1c, 0x29, 0x1c, 0x0c, 0x00, 0x00, 0x00,
@ -283,7 +283,7 @@ pub mod tests {
#[test]
fn test_uncompress_zlib() {
let data = vec![
let data = [
0x78, 0x9c, 0xf3, 0x48, 0xcd, 0xc9, 0xc9, 0x57, 0x08, 0xcf, 0x2f, 0xca, 0x49, 0x51,
0x04, 0x00, 0x1c, 0x49, 0x04, 0x3e,
];
@ -292,7 +292,7 @@ pub mod tests {
#[test]
fn test_uncompress_error() {
let data = vec![0x21];
let data = [0x21];
assert_eq!(
uncompress_brotli(&data[..]).err().unwrap(),
HttpError::CouldNotUncompressResponse {

View File

@ -850,7 +850,7 @@ pub mod tests {
value: FilterValue::HtmlEscape,
};
let tests = vec![
let tests = [
("foo", "foo"),
("<tag>", "&lt;tag&gt;"),
("foo & bar", "foo &amp; bar"),
@ -882,7 +882,7 @@ pub mod tests {
value: FilterValue::HtmlUnescape,
};
let tests = vec![
let tests = [
("foo", "foo"),
("&lt;tag&gt;", "<tag>"),
("foo &amp; bar", "foo & bar"),

View File

@ -100,7 +100,7 @@ fn any_char(reader: &mut Reader) -> ParseResult<'static, (char, String, Pos)> {
},
}),
Some(c) => {
if vec!['\\', '\x08', '\n', '\x0c', '\r', '\t'].contains(&c) {
if ['\\', '\x08', '\n', '\x0c', '\r', '\t'].contains(&c) {
Err(error::Error {
pos: start.pos,
recoverable: true,

View File

@ -1128,7 +1128,7 @@ mod tests {
}
);
let mut reader = Reader::new(r#"/a\/b/"#);
let mut reader = Reader::new(r"/a\/b/");
assert_eq!(
regex(&mut reader).unwrap(),
Regex {
@ -1136,19 +1136,19 @@ mod tests {
}
);
let mut reader = Reader::new(r#"/a\.b/"#);
let mut reader = Reader::new(r"/a\.b/");
assert_eq!(
regex(&mut reader).unwrap(),
Regex {
inner: regex::Regex::new(r#"a\.b"#).unwrap()
inner: regex::Regex::new(r"a\.b").unwrap()
}
);
let mut reader = Reader::new(r#"/\d{4}-\d{2}-\d{2}/"#);
let mut reader = Reader::new(r"/\d{4}-\d{2}-\d{2}/");
assert_eq!(
regex(&mut reader).unwrap(),
Regex {
inner: regex::Regex::new(r#"\d{4}-\d{2}-\d{2}"#).unwrap()
inner: regex::Regex::new(r"\d{4}-\d{2}-\d{2}").unwrap()
}
);
}
@ -1237,7 +1237,7 @@ mod tests {
}
);
let mut reader = Reader::new(r#"file, tmp/filename\ with\ spaces.txt;"#);
let mut reader = Reader::new(r"file, tmp/filename\ with\ spaces.txt;");
assert_eq!(
file(&mut reader).unwrap(),
File {
@ -1281,7 +1281,7 @@ mod tests {
}
);
let mut reader = Reader::new(r#"file, tmp/filename\ with\ unescaped .txt;"#);
let mut reader = Reader::new(r"file, tmp/filename\ with\ unescaped .txt;");
let error = file(&mut reader).err().unwrap();
assert_eq!(
error.pos,

View File

@ -251,7 +251,7 @@ fn any_char(except: Vec<char>, reader: &mut Reader) -> ParseResult<'static, (cha
}),
Some(c) => {
if except.contains(&c)
|| vec!['\\', '\x08', '\n', '\x0c', '\r', '\t'].contains(&c)
|| ['\\', '\x08', '\n', '\x0c', '\r', '\t'].contains(&c)
{
Err(Error {
pos: start.pos,

View File

@ -75,7 +75,7 @@ pub fn url(reader: &mut Reader) -> ParseResult<'static, Template> {
None => break,
Some(c) => {
if c.is_alphanumeric()
| vec![
| [
':', '/', '.', '-', '?', '=', '&', '_', '%', '*', ',', '@',
'~', '+', '!', '$', '\'', '(', ')', ';', '[', ']',
]

View File

@ -57,7 +57,7 @@ pub fn parse(reader: &mut Reader) -> ParseResult<'static, String> {
}
fn is_valid(s: &str) -> bool {
matches!(parser::parse(s), Ok(_))
parser::parse(s).is_ok()
}
#[cfg(test)]

View File

@ -143,7 +143,7 @@ mod test {
assert_eq!(args::split(r#"AAA $'BBB'"#).unwrap(), expected);
let expected = vec!["'".to_string()];
assert_eq!(args::split(r#"$'\''"#).unwrap(), expected);
assert_eq!(args::split(r"$'\''").unwrap(), expected);
}
#[test]