mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 09:03:18 +00:00
fallout
This commit is contained in:
parent
d6c0435c81
commit
07ace32ac9
3 changed files with 45 additions and 68 deletions
|
@ -54,8 +54,7 @@ impl LateLintPass for CollapsibleIf {
|
|||
|
||||
fn check_if(cx: &LateContext, e: &Expr) {
|
||||
if let ExprIf(ref check, ref then, ref else_) = e.node {
|
||||
match *else_ {
|
||||
Some(ref else_) => {
|
||||
if let Some(ref else_) = *else_ {
|
||||
if_let_chain! {[
|
||||
let ExprBlock(ref block) = else_.node,
|
||||
block.stmts.is_empty(),
|
||||
|
@ -72,9 +71,7 @@ fn check_if(cx: &LateContext, e: &Expr) {
|
|||
snippet_block(cx, else_.span, "..")));
|
||||
});
|
||||
}}
|
||||
}
|
||||
None => {
|
||||
if let Some(&Expr{ node: ExprIf(ref check_inner, ref content, None), span: sp, ..}) =
|
||||
} else if let Some(&Expr{ node: ExprIf(ref check_inner, ref content, None), span: sp, ..}) =
|
||||
single_stmt_of_block(then) {
|
||||
if e.span.expn_id != sp.expn_id {
|
||||
return;
|
||||
|
@ -91,8 +88,6 @@ fn check_if(cx: &LateContext, e: &Expr) {
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn requires_brackets(e: &Expr) -> bool {
|
||||
|
|
|
@ -33,28 +33,20 @@ impl LateLintPass for UnnecessaryMutPassed {
|
|||
let borrowed_table = cx.tcx.tables.borrow();
|
||||
match e.node {
|
||||
ExprCall(ref fn_expr, ref arguments) => {
|
||||
match borrowed_table.node_types.get(&fn_expr.id) {
|
||||
Some(function_type) => {
|
||||
let function_type = borrowed_table.node_types
|
||||
.get(&fn_expr.id)
|
||||
.expect("A function with an unknown type is called. \
|
||||
If this happened, the compiler would have \
|
||||
aborted the compilation long ago");
|
||||
if let ExprPath(_, ref path) = fn_expr.node {
|
||||
check_arguments(cx, &arguments, function_type, &format!("{}", path));
|
||||
}
|
||||
}
|
||||
None => unreachable!(), // A function with unknown type is called.
|
||||
// If this happened the compiler would have aborted the
|
||||
// compilation long ago.
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
ExprMethodCall(ref name, _, ref arguments) => {
|
||||
let method_call = MethodCall::expr(e.id);
|
||||
match borrowed_table.method_map.get(&method_call) {
|
||||
Some(method_type) => {
|
||||
let method_type = borrowed_table.method_map.get(&method_call).expect("This should never happen.");
|
||||
check_arguments(cx, &arguments, method_type.ty, &format!("{}", name.node.as_str()))
|
||||
}
|
||||
None => unreachable!(), // Just like above, this should never happen.
|
||||
};
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
18
src/utils.rs
18
src/utils.rs
|
@ -657,20 +657,10 @@ pub fn is_expn_of(cx: &LateContext, mut span: Span, name: &str) -> Option<Span>
|
|||
(ei.callee.name(), ei.call_site)
|
||||
})
|
||||
});
|
||||
|
||||
return match span_name_span {
|
||||
Some((mac_name, new_span)) => {
|
||||
if mac_name.as_str() == name {
|
||||
Some(new_span)
|
||||
match span_name_span {
|
||||
Some((mac_name, new_span)) if mac_name.as_str() == name => return Some(new_span),
|
||||
None => return None,
|
||||
Some((_, new_span)) => span = new_span,
|
||||
}
|
||||
else {
|
||||
span = new_span;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
None => {
|
||||
None
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue