aboutsummaryrefslogtreecommitdiffstats
path: root/askama_shared/src/generator.rs
diff options
context:
space:
mode:
authorLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-01-22 17:29:19 +0100
committerLibravatar Dirkjan Ochtman <dirkjan@ochtman.nl>2018-01-22 17:29:51 +0100
commit6a50939ec2b41b842e3f4d2b71c5792ca4db269b (patch)
tree2e163d1b80df21281cb795f4e1cdea8ff0c520fd /askama_shared/src/generator.rs
parente238032a7441d5174fd62038bc530fa8aa3a90f6 (diff)
downloadaskama-6a50939ec2b41b842e3f4d2b71c5792ca4db269b.tar.gz
askama-6a50939ec2b41b842e3f4d2b71c5792ca4db269b.tar.bz2
askama-6a50939ec2b41b842e3f4d2b71c5792ca4db269b.zip
Cleanup warnings generated by clippy
Diffstat (limited to '')
-rw-r--r--askama_shared/src/generator.rs22
1 files changed, 14 insertions, 8 deletions
diff --git a/askama_shared/src/generator.rs b/askama_shared/src/generator.rs
index ac2f4be..7462af9 100644
--- a/askama_shared/src/generator.rs
+++ b/askama_shared/src/generator.rs
@@ -49,7 +49,7 @@ impl<'a> State<'a> {
_ => {},
}
}
- for (&(scope, name), ref m) in imported {
+ for (&(scope, name), m) in imported {
macros.insert((Some(scope), name), m);
}
State {
@@ -81,7 +81,7 @@ fn trait_name_for_path(base: &Option<&Expr>, path: &Path) -> String {
res
}
-fn get_parent_type<'a>(ast: &'a syn::DeriveInput) -> Option<&'a syn::Type> {
+fn get_parent_type(ast: &syn::DeriveInput) -> Option<&syn::Type> {
match ast.data {
syn::Data::Struct(syn::DataStruct {
fields: syn::Fields::Named(ref fields),
@@ -322,7 +322,7 @@ impl<'a> Generator<'a> {
Node::Cond(ref conds, ref ws) => {
self.write_cond(state, conds, ws);
},
- Node::Match(ref ws1, ref expr, ref inter, ref arms, ref ws2) => {
+ Node::Match(ref ws1, ref expr, inter, ref arms, ref ws2) => {
self.write_match(state, ws1, expr, inter, arms, ws2);
},
Node::Loop(ref ws1, ref var, ref iter, ref body, ref ws2) => {
@@ -437,10 +437,10 @@ impl<'a> Generator<'a> {
},
None => self.write("_"),
};
- if params.len() > 0 {
+ if !params.is_empty() {
self.write("(");
for (i, param) in params.iter().enumerate() {
- if let MatchParameter::Name(ref p) = *param {
+ if let MatchParameter::Name(p) = *param {
self.locals.insert(p);
}
if i > 0 {
@@ -484,7 +484,7 @@ impl<'a> Generator<'a> {
fn write_call(&mut self, state: &'a State, ws: &WS, scope: Option<&str>, name: &str,
args: &[Expr]) {
let def = state.macros.get(&(scope, name)).unwrap_or_else(|| {
- if let Some(ref s) = scope {
+ if let Some(s) = scope {
panic!(format!("macro '{}::{}' not found", s, name));
} else {
panic!(format!("macro '{}' not found", name));
@@ -749,7 +749,7 @@ impl<'a> Generator<'a> {
DisplayWrap::Unwrapped
}
- fn visit_array(&mut self, elements: &Vec<Expr>) -> DisplayWrap {
+ fn visit_array(&mut self, elements: &[Expr]) -> DisplayWrap {
self.write("[");
for (i, el) in elements.iter().enumerate() {
if i > 0 {
@@ -761,7 +761,7 @@ impl<'a> Generator<'a> {
DisplayWrap::Unwrapped
}
- fn visit_path(&mut self, path: &Vec<&str>) -> DisplayWrap {
+ fn visit_path(&mut self, path: &[&str]) -> DisplayWrap {
for (i, part) in path.iter().enumerate() {
if i > 0 {
self.write("::");
@@ -898,14 +898,20 @@ impl<'a, T: 'a> SetChain<'a, T> where T: cmp::Eq + hash::Hash {
}
}
+#[derive(Clone)]
enum AstLevel {
Top,
Nested,
}
+impl Copy for AstLevel {}
+
+#[derive(Clone)]
enum DisplayWrap {
Wrapped,
Unwrapped,
}
+impl Copy for DisplayWrap {}
+
type MacroMap<'a> = HashMap<(Option<&'a str>, &'a str), &'a Macro<'a>>;