diff --git a/lib/src/rocket.rs b/lib/src/rocket.rs index 48745271..b5494a53 100644 --- a/lib/src/rocket.rs +++ b/lib/src/rocket.rs @@ -54,10 +54,10 @@ impl Rocket { let outcome = (route.handler)(&request).respond(res); info_!("{} {}", White.paint("Outcome:"), outcome); + // Get the result if we failed so we can try again. res = match outcome { - Outcome::Complete => return, - Outcome::FailStop => return, - Outcome::FailForward(r) => r + Outcome::FailForward(r) => r, + Outcome::Complete | Outcome::FailStop => return, }; } diff --git a/macros/src/derive_form.rs b/macros/src/derive_form.rs index f41ff89e..561304fa 100644 --- a/macros/src/derive_form.rs +++ b/macros/src/derive_form.rs @@ -162,7 +162,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct // placed into the final struct. They start out as `None` and are changed // to Some when a parse completes, or some default value if the parse was // unsuccessful and default() returns Some. - for &(ref ident, ref ty) in &fields_and_types { + for &(ref ident, ty) in &fields_and_types { stmts.push(quote_stmt!(cx, let mut $ident: ::std::option::Option<$ty> = None; ).unwrap()); @@ -199,7 +199,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct // This looks complicated but just generates the boolean condition checking // that each parameter actually is Some() or has a default value. let mut failure_conditions = vec![]; - for (i, &(ref ident, ref ty)) in (&fields_and_types).iter().enumerate() { + for (i, &(ref ident, ty)) in (&fields_and_types).iter().enumerate() { if i > 0 { failure_conditions.push(quote_tokens!(cx, ||)); } @@ -211,7 +211,7 @@ fn from_form_substructure(cx: &mut ExtCtxt, trait_span: Span, substr: &Substruct // The fields of the struct, which are just the let bindings declared above // or the default value. let mut result_fields = vec![]; - for &(ref ident, ref ty) in &fields_and_types { + for &(ref ident, ty) in &fields_and_types { result_fields.push(quote_tokens!(cx, $ident: $ident.unwrap_or_else(|| <$ty as ::rocket::form::FromFormValue>::default().unwrap() diff --git a/macros/src/meta_item_parser.rs b/macros/src/meta_item_parser.rs index 2185743b..046ae89e 100644 --- a/macros/src/meta_item_parser.rs +++ b/macros/src/meta_item_parser.rs @@ -30,7 +30,7 @@ impl<'a, 'c> MetaItemParser<'a, 'c> { ctxt: ctxt, meta_item: meta_item, annotated: annotated, - span: span.clone(), + span: *span, } } @@ -101,7 +101,7 @@ impl<'s, 'a, 'c> Iterator for ParamIter<'s, 'a, 'c> { param_span.hi = self.span.lo + BytePos((end + 1) as u32); // Check for nonemptiness and that the characters are correct. - if param.len() == 0 { + if param.is_empty() { self.ctxt.span_err(param_span, "Parameter names cannot be empty."); None } else if param.contains(|c: char| !c.is_alphanumeric()) { @@ -216,7 +216,7 @@ impl<'a, 'c> RouteDecoratorExt for MetaItemParser<'a, 'c> { self.ctxt.span_err(data.v_span, &msg); None } - }).unwrap_or(KVSpanned::dummy(ContentType::any())); + }).unwrap_or_else(|| KVSpanned::dummy(ContentType::any())); RouteParams { method: method, diff --git a/macros/src/utils.rs b/macros/src/utils.rs index 30d2f201..18e1b5f2 100644 --- a/macros/src/utils.rs +++ b/macros/src/utils.rs @@ -151,15 +151,14 @@ pub trait MetaItemExt { fn expect_list<'a>(&'a self, ecx: &ExtCtxt, msg: &str) -> &'a Vec>; fn expect_word<'a>(&'a self, ecx: &ExtCtxt, msg: &str) -> &'a str; fn is_word(&self) -> bool; - fn name<'a>(&'a self) -> &'a str; + fn name(&self) -> &str; } impl MetaItemExt for MetaItem { - fn name<'a>(&'a self) -> &'a str { + fn name(&self) -> &str { let interned_name = match self.node { - MetaItemKind::Word(ref s) => s, - MetaItemKind::List(ref s, _) => s, - MetaItemKind::NameValue(ref s, _) => s + MetaItemKind::Word(ref s) | MetaItemKind::List(ref s, _) + | MetaItemKind::NameValue(ref s, _) => s, }; &*interned_name