From ee4dbf0d8d7c81a3d77fa5b87a60152291e70fc7 Mon Sep 17 00:00:00 2001 From: Dirkjan Ochtman Date: Fri, 4 Nov 2022 21:35:43 +0100 Subject: chore: apply clippy suggestions for 1.65 --- askama/src/filters/json.rs | 4 +- askama/src/filters/mod.rs | 120 ++++++++++++++++++++++---------------------- askama/src/filters/yaml.rs | 4 +- askama/src/lib.rs | 2 +- askama_derive/src/config.rs | 2 +- testing/tests/filters.rs | 2 +- testing/tests/matches.rs | 2 +- testing/tests/operators.rs | 2 +- testing/tests/simple.rs | 2 +- 9 files changed, 70 insertions(+), 70 deletions(-) diff --git a/askama/src/filters/json.rs b/askama/src/filters/json.rs index e94e50c..03e624a 100644 --- a/askama/src/filters/json.rs +++ b/askama/src/filters/json.rs @@ -31,8 +31,8 @@ mod tests { fn test_json() { assert_eq!(json(true).unwrap(), "true"); assert_eq!(json("foo").unwrap(), r#""foo""#); - assert_eq!(json(&true).unwrap(), "true"); - assert_eq!(json(&"foo").unwrap(), r#""foo""#); + assert_eq!(json(true).unwrap(), "true"); + assert_eq!(json("foo").unwrap(), r#""foo""#); assert_eq!( json(&vec!["foo", "bar"]).unwrap(), r#"[ diff --git a/askama/src/filters/mod.rs b/askama/src/filters/mod.rs index 7312cd5..c581967 100644 --- a/askama/src/filters/mod.rs +++ b/askama/src/filters/mod.rs @@ -411,61 +411,61 @@ mod tests { fn test_urlencoding() { // Unreserved (https://tools.ietf.org/html/rfc3986.html#section-2.3) // alpha / digit - assert_eq!(urlencode(&"AZaz09").unwrap(), "AZaz09"); - assert_eq!(urlencode_strict(&"AZaz09").unwrap(), "AZaz09"); + assert_eq!(urlencode("AZaz09").unwrap(), "AZaz09"); + assert_eq!(urlencode_strict("AZaz09").unwrap(), "AZaz09"); // other - assert_eq!(urlencode(&"_.-~").unwrap(), "_.-~"); - assert_eq!(urlencode_strict(&"_.-~").unwrap(), "_.-~"); + assert_eq!(urlencode("_.-~").unwrap(), "_.-~"); + assert_eq!(urlencode_strict("_.-~").unwrap(), "_.-~"); // Reserved (https://tools.ietf.org/html/rfc3986.html#section-2.2) // gen-delims - assert_eq!(urlencode(&":/?#[]@").unwrap(), "%3A/%3F%23%5B%5D%40"); + assert_eq!(urlencode(":/?#[]@").unwrap(), "%3A/%3F%23%5B%5D%40"); assert_eq!( - urlencode_strict(&":/?#[]@").unwrap(), + urlencode_strict(":/?#[]@").unwrap(), "%3A%2F%3F%23%5B%5D%40" ); // sub-delims assert_eq!( - urlencode(&"!$&'()*+,;=").unwrap(), + urlencode("!$&'()*+,;=").unwrap(), "%21%24%26%27%28%29%2A%2B%2C%3B%3D" ); assert_eq!( - urlencode_strict(&"!$&'()*+,;=").unwrap(), + urlencode_strict("!$&'()*+,;=").unwrap(), "%21%24%26%27%28%29%2A%2B%2C%3B%3D" ); // Other assert_eq!( - urlencode(&"žŠďŤňĚáÉóŮ").unwrap(), + urlencode("žŠďŤňĚáÉóŮ").unwrap(), "%C5%BE%C5%A0%C4%8F%C5%A4%C5%88%C4%9A%C3%A1%C3%89%C3%B3%C5%AE" ); assert_eq!( - urlencode_strict(&"žŠďŤňĚáÉóŮ").unwrap(), + urlencode_strict("žŠďŤňĚáÉóŮ").unwrap(), "%C5%BE%C5%A0%C4%8F%C5%A4%C5%88%C4%9A%C3%A1%C3%89%C3%B3%C5%AE" ); // Ferris - assert_eq!(urlencode(&"🦀").unwrap(), "%F0%9F%A6%80"); - assert_eq!(urlencode_strict(&"🦀").unwrap(), "%F0%9F%A6%80"); + assert_eq!(urlencode("🦀").unwrap(), "%F0%9F%A6%80"); + assert_eq!(urlencode_strict("🦀").unwrap(), "%F0%9F%A6%80"); } #[test] fn test_linebreaks() { assert_eq!( - linebreaks(&"Foo\nBar Baz").unwrap(), + linebreaks("Foo\nBar Baz").unwrap(), "

Foo
Bar Baz

" ); assert_eq!( - linebreaks(&"Foo\nBar\n\nBaz").unwrap(), + linebreaks("Foo\nBar\n\nBaz").unwrap(), "

Foo
Bar

Baz

" ); } #[test] fn test_linebreaksbr() { - assert_eq!(linebreaksbr(&"Foo\nBar").unwrap(), "Foo
Bar"); + assert_eq!(linebreaksbr("Foo\nBar").unwrap(), "Foo
Bar"); assert_eq!( - linebreaksbr(&"Foo\nBar\n\nBaz").unwrap(), + linebreaksbr("Foo\nBar\n\nBaz").unwrap(), "Foo
Bar

Baz" ); } @@ -473,72 +473,72 @@ mod tests { #[test] fn test_paragraphbreaks() { assert_eq!( - paragraphbreaks(&"Foo\nBar Baz").unwrap(), + paragraphbreaks("Foo\nBar Baz").unwrap(), "

Foo\nBar Baz

" ); assert_eq!( - paragraphbreaks(&"Foo\nBar\n\nBaz").unwrap(), + paragraphbreaks("Foo\nBar\n\nBaz").unwrap(), "

Foo\nBar

Baz

" ); assert_eq!( - paragraphbreaks(&"Foo\n\n\n\n\nBar\n\nBaz").unwrap(), + paragraphbreaks("Foo\n\n\n\n\nBar\n\nBaz").unwrap(), "

Foo

\nBar

Baz

" ); } #[test] fn test_lower() { - assert_eq!(lower(&"Foo").unwrap(), "foo"); - assert_eq!(lower(&"FOO").unwrap(), "foo"); - assert_eq!(lower(&"FooBar").unwrap(), "foobar"); - assert_eq!(lower(&"foo").unwrap(), "foo"); + assert_eq!(lower("Foo").unwrap(), "foo"); + assert_eq!(lower("FOO").unwrap(), "foo"); + assert_eq!(lower("FooBar").unwrap(), "foobar"); + assert_eq!(lower("foo").unwrap(), "foo"); } #[test] fn test_upper() { - assert_eq!(upper(&"Foo").unwrap(), "FOO"); - assert_eq!(upper(&"FOO").unwrap(), "FOO"); - assert_eq!(upper(&"FooBar").unwrap(), "FOOBAR"); - assert_eq!(upper(&"foo").unwrap(), "FOO"); + assert_eq!(upper("Foo").unwrap(), "FOO"); + assert_eq!(upper("FOO").unwrap(), "FOO"); + assert_eq!(upper("FooBar").unwrap(), "FOOBAR"); + assert_eq!(upper("foo").unwrap(), "FOO"); } #[test] fn test_trim() { - assert_eq!(trim(&" Hello\tworld\t").unwrap(), "Hello\tworld"); + assert_eq!(trim(" Hello\tworld\t").unwrap(), "Hello\tworld"); } #[test] fn test_truncate() { - assert_eq!(truncate(&"hello", 2).unwrap(), "he..."); + assert_eq!(truncate("hello", 2).unwrap(), "he..."); let a = String::from("您好"); assert_eq!(a.len(), 6); assert_eq!(String::from("您").len(), 3); - assert_eq!(truncate(&"您好", 1).unwrap(), "您..."); - assert_eq!(truncate(&"您好", 2).unwrap(), "您..."); - assert_eq!(truncate(&"您好", 3).unwrap(), "您..."); - assert_eq!(truncate(&"您好", 4).unwrap(), "您好..."); - assert_eq!(truncate(&"您好", 6).unwrap(), "您好"); - assert_eq!(truncate(&"您好", 7).unwrap(), "您好"); + assert_eq!(truncate("您好", 1).unwrap(), "您..."); + assert_eq!(truncate("您好", 2).unwrap(), "您..."); + assert_eq!(truncate("您好", 3).unwrap(), "您..."); + assert_eq!(truncate("您好", 4).unwrap(), "您好..."); + assert_eq!(truncate("您好", 6).unwrap(), "您好"); + assert_eq!(truncate("您好", 7).unwrap(), "您好"); let s = String::from("🤚a🤚"); assert_eq!(s.len(), 9); assert_eq!(String::from("🤚").len(), 4); - assert_eq!(truncate(&"🤚a🤚", 1).unwrap(), "🤚..."); - assert_eq!(truncate(&"🤚a🤚", 2).unwrap(), "🤚..."); - assert_eq!(truncate(&"🤚a🤚", 3).unwrap(), "🤚..."); - assert_eq!(truncate(&"🤚a🤚", 4).unwrap(), "🤚..."); - assert_eq!(truncate(&"🤚a🤚", 5).unwrap(), "🤚a..."); - assert_eq!(truncate(&"🤚a🤚", 6).unwrap(), "🤚a🤚..."); - assert_eq!(truncate(&"🤚a🤚", 9).unwrap(), "🤚a🤚"); - assert_eq!(truncate(&"🤚a🤚", 10).unwrap(), "🤚a🤚"); + assert_eq!(truncate("🤚a🤚", 1).unwrap(), "🤚..."); + assert_eq!(truncate("🤚a🤚", 2).unwrap(), "🤚..."); + assert_eq!(truncate("🤚a🤚", 3).unwrap(), "🤚..."); + assert_eq!(truncate("🤚a🤚", 4).unwrap(), "🤚..."); + assert_eq!(truncate("🤚a🤚", 5).unwrap(), "🤚a..."); + assert_eq!(truncate("🤚a🤚", 6).unwrap(), "🤚a🤚..."); + assert_eq!(truncate("🤚a🤚", 9).unwrap(), "🤚a🤚"); + assert_eq!(truncate("🤚a🤚", 10).unwrap(), "🤚a🤚"); } #[test] fn test_indent() { - assert_eq!(indent(&"hello", 2).unwrap(), "hello"); - assert_eq!(indent(&"hello\n", 2).unwrap(), "hello\n"); - assert_eq!(indent(&"hello\nfoo", 2).unwrap(), "hello\n foo"); + assert_eq!(indent("hello", 2).unwrap(), "hello"); + assert_eq!(indent("hello\n", 2).unwrap(), "hello\n"); + assert_eq!(indent("hello\nfoo", 2).unwrap(), "hello\n foo"); assert_eq!( - indent(&"hello\nfoo\n bar", 4).unwrap(), + indent("hello\nfoo\n bar", 4).unwrap(), "hello\n foo\n bar" ); } @@ -610,15 +610,15 @@ mod tests { #[test] fn test_capitalize() { - assert_eq!(capitalize(&"foo").unwrap(), "Foo".to_string()); - assert_eq!(capitalize(&"f").unwrap(), "F".to_string()); - assert_eq!(capitalize(&"fO").unwrap(), "Fo".to_string()); - assert_eq!(capitalize(&"").unwrap(), "".to_string()); - assert_eq!(capitalize(&"FoO").unwrap(), "Foo".to_string()); - assert_eq!(capitalize(&"foO BAR").unwrap(), "Foo bar".to_string()); - assert_eq!(capitalize(&"äØÄÅÖ").unwrap(), "Äøäåö".to_string()); - assert_eq!(capitalize(&"ß").unwrap(), "SS".to_string()); - assert_eq!(capitalize(&"ßß").unwrap(), "SSß".to_string()); + assert_eq!(capitalize("foo").unwrap(), "Foo".to_string()); + assert_eq!(capitalize("f").unwrap(), "F".to_string()); + assert_eq!(capitalize("fO").unwrap(), "Fo".to_string()); + assert_eq!(capitalize("").unwrap(), "".to_string()); + assert_eq!(capitalize("FoO").unwrap(), "Foo".to_string()); + assert_eq!(capitalize("foO BAR").unwrap(), "Foo bar".to_string()); + assert_eq!(capitalize("äØÄÅÖ").unwrap(), "Äøäåö".to_string()); + assert_eq!(capitalize("ß").unwrap(), "SS".to_string()); + assert_eq!(capitalize("ßß").unwrap(), "SSß".to_string()); } #[test] @@ -631,9 +631,9 @@ mod tests { #[test] fn test_wordcount() { - assert_eq!(wordcount(&"").unwrap(), 0); - assert_eq!(wordcount(&" \n\t").unwrap(), 0); - assert_eq!(wordcount(&"foo").unwrap(), 1); - assert_eq!(wordcount(&"foo bar").unwrap(), 2); + assert_eq!(wordcount("").unwrap(), 0); + assert_eq!(wordcount(" \n\t").unwrap(), 0); + assert_eq!(wordcount("foo").unwrap(), 1); + assert_eq!(wordcount("foo bar").unwrap(), 2); } } diff --git a/askama/src/filters/yaml.rs b/askama/src/filters/yaml.rs index ada0ca8..9f4c802 100644 --- a/askama/src/filters/yaml.rs +++ b/askama/src/filters/yaml.rs @@ -24,8 +24,8 @@ mod tests { fn test_yaml() { assert_eq!(yaml(Html, true).unwrap().to_string(), "true\n"); assert_eq!(yaml(Html, "foo").unwrap().to_string(), "foo\n"); - assert_eq!(yaml(Html, &true).unwrap().to_string(), "true\n"); - assert_eq!(yaml(Html, &"foo").unwrap().to_string(), "foo\n"); + assert_eq!(yaml(Html, true).unwrap().to_string(), "true\n"); + assert_eq!(yaml(Html, "foo").unwrap().to_string(), "foo\n"); assert_eq!( yaml(Html, &vec!["foo", "bar"]).unwrap().to_string(), "- foo\n- bar\n" diff --git a/askama/src/lib.rs b/askama/src/lib.rs index 3af9751..29a64b4 100644 --- a/askama/src/lib.rs +++ b/askama/src/lib.rs @@ -163,7 +163,7 @@ impl fmt::Display for dyn DynTemplate { } #[cfg(test)] -#[allow(clippy::blacklisted_name)] +#[allow(clippy::disallowed_names)] mod tests { use std::fmt; diff --git a/askama_derive/src/config.rs b/askama_derive/src/config.rs index 14d4323..2e71ba2 100644 --- a/askama_derive/src/config.rs +++ b/askama_derive/src/config.rs @@ -300,7 +300,7 @@ static DEFAULT_ESCAPERS: &[(&[&str], &str)] = &[ ]; #[cfg(test)] -#[allow(clippy::blacklisted_name)] +#[allow(clippy::disallowed_names)] mod tests { use std::env; use std::path::{Path, PathBuf}; diff --git a/testing/tests/filters.rs b/testing/tests/filters.rs index 7973f45..b171e49 100644 --- a/testing/tests/filters.rs +++ b/testing/tests/filters.rs @@ -1,4 +1,4 @@ -#![allow(clippy::blacklisted_name)] +#![allow(clippy::disallowed_names)] #[cfg(feature = "serde-json")] #[macro_use] diff --git a/testing/tests/matches.rs b/testing/tests/matches.rs index 35c1204..05fd03b 100644 --- a/testing/tests/matches.rs +++ b/testing/tests/matches.rs @@ -1,4 +1,4 @@ -#![allow(clippy::blacklisted_name)] +#![allow(clippy::disallowed_names)] use askama::Template; diff --git a/testing/tests/operators.rs b/testing/tests/operators.rs index 05c1dab..a63efbe 100644 --- a/testing/tests/operators.rs +++ b/testing/tests/operators.rs @@ -1,4 +1,4 @@ -#![allow(clippy::blacklisted_name)] +#![allow(clippy::disallowed_names)] use askama::Template; diff --git a/testing/tests/simple.rs b/testing/tests/simple.rs index dcd324e..44439c5 100644 --- a/testing/tests/simple.rs +++ b/testing/tests/simple.rs @@ -1,4 +1,4 @@ -#![allow(clippy::blacklisted_name)] +#![allow(clippy::disallowed_names)] use askama::Template; -- cgit