mirror of https://github.com/rwf2/Rocket.git
Clippyfied the library.
This commit is contained in:
parent
c058694bd0
commit
2fe13b2fe8
|
@ -54,10 +54,10 @@ impl Rocket {
|
||||||
let outcome = (route.handler)(&request).respond(res);
|
let outcome = (route.handler)(&request).respond(res);
|
||||||
info_!("{} {}", White.paint("Outcome:"), outcome);
|
info_!("{} {}", White.paint("Outcome:"), outcome);
|
||||||
|
|
||||||
|
// Get the result if we failed so we can try again.
|
||||||
res = match outcome {
|
res = match outcome {
|
||||||
Outcome::Complete => return,
|
Outcome::FailForward(r) => r,
|
||||||
Outcome::FailStop => return,
|
Outcome::Complete | Outcome::FailStop => return,
|
||||||
Outcome::FailForward(r) => r
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
// 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
|
// to Some when a parse completes, or some default value if the parse was
|
||||||
// unsuccessful and default() returns Some.
|
// 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,
|
stmts.push(quote_stmt!(cx,
|
||||||
let mut $ident: ::std::option::Option<$ty> = None;
|
let mut $ident: ::std::option::Option<$ty> = None;
|
||||||
).unwrap());
|
).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
|
// This looks complicated but just generates the boolean condition checking
|
||||||
// that each parameter actually is Some() or has a default value.
|
// that each parameter actually is Some() or has a default value.
|
||||||
let mut failure_conditions = vec![];
|
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 {
|
if i > 0 {
|
||||||
failure_conditions.push(quote_tokens!(cx, ||));
|
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
|
// The fields of the struct, which are just the let bindings declared above
|
||||||
// or the default value.
|
// or the default value.
|
||||||
let mut result_fields = vec![];
|
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,
|
result_fields.push(quote_tokens!(cx,
|
||||||
$ident: $ident.unwrap_or_else(||
|
$ident: $ident.unwrap_or_else(||
|
||||||
<$ty as ::rocket::form::FromFormValue>::default().unwrap()
|
<$ty as ::rocket::form::FromFormValue>::default().unwrap()
|
||||||
|
|
|
@ -30,7 +30,7 @@ impl<'a, 'c> MetaItemParser<'a, 'c> {
|
||||||
ctxt: ctxt,
|
ctxt: ctxt,
|
||||||
meta_item: meta_item,
|
meta_item: meta_item,
|
||||||
annotated: annotated,
|
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);
|
param_span.hi = self.span.lo + BytePos((end + 1) as u32);
|
||||||
|
|
||||||
// Check for nonemptiness and that the characters are correct.
|
// 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.");
|
self.ctxt.span_err(param_span, "Parameter names cannot be empty.");
|
||||||
None
|
None
|
||||||
} else if param.contains(|c: char| !c.is_alphanumeric()) {
|
} 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);
|
self.ctxt.span_err(data.v_span, &msg);
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}).unwrap_or(KVSpanned::dummy(ContentType::any()));
|
}).unwrap_or_else(|| KVSpanned::dummy(ContentType::any()));
|
||||||
|
|
||||||
RouteParams {
|
RouteParams {
|
||||||
method: method,
|
method: method,
|
||||||
|
|
|
@ -151,15 +151,14 @@ pub trait MetaItemExt {
|
||||||
fn expect_list<'a>(&'a self, ecx: &ExtCtxt, msg: &str) -> &'a Vec<P<MetaItem>>;
|
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 expect_word<'a>(&'a self, ecx: &ExtCtxt, msg: &str) -> &'a str;
|
||||||
fn is_word(&self) -> bool;
|
fn is_word(&self) -> bool;
|
||||||
fn name<'a>(&'a self) -> &'a str;
|
fn name(&self) -> &str;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl MetaItemExt for MetaItem {
|
impl MetaItemExt for MetaItem {
|
||||||
fn name<'a>(&'a self) -> &'a str {
|
fn name(&self) -> &str {
|
||||||
let interned_name = match self.node {
|
let interned_name = match self.node {
|
||||||
MetaItemKind::Word(ref s) => s,
|
MetaItemKind::Word(ref s) | MetaItemKind::List(ref s, _)
|
||||||
MetaItemKind::List(ref s, _) => s,
|
| MetaItemKind::NameValue(ref s, _) => s,
|
||||||
MetaItemKind::NameValue(ref s, _) => s
|
|
||||||
};
|
};
|
||||||
|
|
||||||
&*interned_name
|
&*interned_name
|
||||||
|
|
Loading…
Reference in New Issue