aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Bardi Harborow <bardi@bardiharborow.com>2019-07-12 04:43:41 +1000
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2019-07-11 21:49:56 +0200
commit5a4ac0fe462faf2a3ba3b3f4334863cdb4bbf45a (patch)
tree1751b688ca625f5933df76b47747a685510f3909
parent4bd29679c022a56b9fa8790d9095cdf8b0ee19b8 (diff)
downloadaskama-5a4ac0fe462faf2a3ba3b3f4334863cdb4bbf45a.tar.gz
askama-5a4ac0fe462faf2a3ba3b3f4334863cdb4bbf45a.tar.bz2
askama-5a4ac0fe462faf2a3ba3b3f4334863cdb4bbf45a.zip
Implement selected clippy recommendations.
-rw-r--r--askama_derive/src/generator.rs2
-rw-r--r--askama_derive/src/input.rs11
-rw-r--r--askama_derive/src/parser.rs2
-rw-r--r--askama_shared/src/lib.rs2
4 files changed, 7 insertions, 10 deletions
diff --git a/askama_derive/src/generator.rs b/askama_derive/src/generator.rs
index aa91de0..7757016 100644
--- a/askama_derive/src/generator.rs
+++ b/askama_derive/src/generator.rs
@@ -109,7 +109,7 @@ impl<'a> Generator<'a> {
);
// Make sure the compiler understands that the generated code depends on the template files.
- for (path, _) in self.contexts {
+ for path in self.contexts.keys() {
// Skip the fake path of templates defined in rust source.
let path_is_valid = match self.input.source {
Source::Path(_) => true,
diff --git a/askama_derive/src/input.rs b/askama_derive/src/input.rs
index 0cc852c..0bf6093 100644
--- a/askama_derive/src/input.rs
+++ b/askama_derive/src/input.rs
@@ -4,7 +4,6 @@ use quote::ToTokens;
use askama_shared::{Config, Syntax};
-use std::io::{self, Write};
use std::path::PathBuf;
use syn;
@@ -146,12 +145,10 @@ impl<'a> TemplateInput<'a> {
};
if parent.is_some() {
- io::stderr()
- .write_fmt(format_args!(
- " --> in struct {}\n = use of deprecated field '_parent'\n",
- ast.ident
- ))
- .unwrap();
+ eprint!(
+ " --> in struct {}\n = use of deprecated field '_parent'\n",
+ ast.ident
+ );
}
// Validate syntax
diff --git a/askama_derive/src/parser.rs b/askama_derive/src/parser.rs
index a37a112..b8fa94d 100644
--- a/askama_derive/src/parser.rs
+++ b/askama_derive/src/parser.rs
@@ -117,7 +117,7 @@ fn split_ws_parts(s: &[u8]) -> Node {
(&s[..start], &s[start..], &s[0..0])
} else {
let end = end.unwrap();
- (&s[..start], &s[start..end + 1], &s[end + 1..])
+ (&s[..start], &s[start..=end], &s[end + 1..])
}
};
Node::Lit(
diff --git a/askama_shared/src/lib.rs b/askama_shared/src/lib.rs
index ffc0351..918e356 100644
--- a/askama_shared/src/lib.rs
+++ b/askama_shared/src/lib.rs
@@ -55,7 +55,7 @@ impl<'a> Config<'a> {
for raw_s in raw_syntaxes {
let name = raw_s.name;
- if let Some(_) = syntaxes.insert(name.to_string(), Syntax::from(raw_s)) {
+ if syntaxes.insert(name.to_string(), Syntax::from(raw_s)).is_some() {
panic!("syntax \"{}\" is already defined", name)
}
}