simplify some unused lints code
This commit is contained in:
parent
de3d640f59
commit
989f480297
@ -65,9 +65,8 @@ fn check_stmt(&mut self, cx: &LateContext, s: &hir::Stmt) {
|
||||
ty::Adt(def, _) => {
|
||||
if def.variants.is_empty() {
|
||||
return;
|
||||
} else {
|
||||
check_must_use(cx, def.did, s.span, "")
|
||||
}
|
||||
check_must_use(cx, def.did, s.span, "")
|
||||
},
|
||||
_ => false,
|
||||
};
|
||||
@ -337,21 +336,13 @@ fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) {
|
||||
AssignOp(.., ref value) => (value, "assigned value", false),
|
||||
// either function/method call, or something this lint doesn't care about
|
||||
ref call_or_other => {
|
||||
let args_to_check;
|
||||
let call_kind;
|
||||
match *call_or_other {
|
||||
Call(_, ref args) => {
|
||||
call_kind = "function";
|
||||
args_to_check = &args[..];
|
||||
},
|
||||
MethodCall(_, ref args) => {
|
||||
call_kind = "method";
|
||||
// first "argument" is self (which sometimes needs parens)
|
||||
args_to_check = &args[1..];
|
||||
}
|
||||
let (args_to_check, call_kind) = match *call_or_other {
|
||||
Call(_, ref args) => (&args[..], "function"),
|
||||
// first "argument" is self (which sometimes needs parens)
|
||||
MethodCall(_, ref args) => (&args[1..], "method"),
|
||||
// actual catch-all arm
|
||||
_ => { return; }
|
||||
}
|
||||
};
|
||||
// Don't lint if this is a nested macro expansion: otherwise, the lint could
|
||||
// trigger in situations that macro authors shouldn't have to care about, e.g.,
|
||||
// when a parenthesized token tree matched in one macro expansion is matched as
|
||||
@ -372,16 +363,11 @@ fn check_expr(&mut self, cx: &EarlyContext, e: &ast::Expr) {
|
||||
}
|
||||
|
||||
fn check_stmt(&mut self, cx: &EarlyContext, s: &ast::Stmt) {
|
||||
let (value, msg) = match s.node {
|
||||
ast::StmtKind::Local(ref local) => {
|
||||
match local.init {
|
||||
Some(ref value) => (value, "assigned value"),
|
||||
None => return,
|
||||
}
|
||||
if let ast::StmtKind::Local(ref local) = s.node {
|
||||
if let Some(ref value) = local.init {
|
||||
self.check_unused_parens_core(cx, &value, "assigned value", false);
|
||||
}
|
||||
_ => return,
|
||||
};
|
||||
self.check_unused_parens_core(cx, &value, msg, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -414,9 +400,8 @@ fn check_use_tree(&self, cx: &EarlyContext, use_tree: &ast::UseTree, item: &ast:
|
||||
let orig_ident = items[0].0.prefix.segments.last().unwrap().ident;
|
||||
if orig_ident.name == keywords::SelfValue.name() {
|
||||
return;
|
||||
} else {
|
||||
node_ident = rename.unwrap_or(orig_ident);
|
||||
}
|
||||
node_ident = rename.unwrap_or(orig_ident);
|
||||
}
|
||||
ast::UseTreeKind::Glob => {
|
||||
node_ident = ast::Ident::from_str("*");
|
||||
|
Loading…
Reference in New Issue
Block a user