fixed array bounds checking
This commit is contained in:
parent
a57f21945b
commit
97e9299a10
@ -38,11 +38,16 @@ impl LateLintPass for OkIfLetPass {
|
||||
let MatchSource::IfLetDesugar { .. } = *source, //test if it is an If Let
|
||||
let ExprMethodCall(_, _, ref result_types) = op.node, //check is expr.ok() has type Result<T,E>.ok()
|
||||
let PatKind::TupleStruct(ref x, ref y, _) = body[0].pats[0].node, //get operation
|
||||
let Some(some_expr_string) = snippet_opt(cx, y[0].span),
|
||||
let Some(_) = method_chain_args(op, &["ok"]) //test to see if using ok() methoduse std::marker::Sized;
|
||||
|
||||
], {
|
||||
let is_result_type = match_type(cx, cx.tcx.expr_ty(&result_types[0]), &paths::RESULT);
|
||||
let mut some_expr_string = String::from("");
|
||||
if y.len() > 0 {
|
||||
if let Some(x) = snippet_opt(cx, y[0].span) {
|
||||
some_expr_string = x;
|
||||
}
|
||||
}
|
||||
if print::path_to_string(x) == "Some" && is_result_type {
|
||||
span_help_and_lint(cx, IF_LET_SOME_RESULT, expr.span,
|
||||
"Matching on `Some` with `ok()` is redundant",
|
||||
|
Loading…
Reference in New Issue
Block a user