Clippyfied the library.

This commit is contained in:
Sergio Benitez 2016-08-26 22:05:33 -07:00
parent c058694bd0
commit 2fe13b2fe8
4 changed files with 13 additions and 14 deletions

View File

@ -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,
};
}

View File

@ -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()

View File

@ -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,

View File

@ -151,15 +151,14 @@ pub trait MetaItemExt {
fn expect_list<'a>(&'a self, ecx: &ExtCtxt, msg: &str) -> &'a Vec<P<MetaItem>>;
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