Fix some more clippy warnings
This commit is contained in:
parent
388ef34904
commit
bfecb18771
16 changed files with 71 additions and 97 deletions
|
@ -1369,10 +1369,9 @@ impl TypeAliasBounds {
|
|||
hir::QPath::TypeRelative(ref ty, _) => {
|
||||
// If this is a type variable, we found a `T::Assoc`.
|
||||
match ty.kind {
|
||||
hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => match path.res {
|
||||
Res::Def(DefKind::TyParam, _) => true,
|
||||
_ => false,
|
||||
},
|
||||
hir::TyKind::Path(hir::QPath::Resolved(None, ref path)) => {
|
||||
matches!(path.res, Res::Def(DefKind::TyParam, _))
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
@ -2381,10 +2380,9 @@ impl<'tcx> LateLintPass<'tcx> for InvalidValue {
|
|||
return Some(InitKind::Zeroed);
|
||||
} else if cx.tcx.is_diagnostic_item(sym::mem_uninitialized, def_id) {
|
||||
return Some(InitKind::Uninit);
|
||||
} else if cx.tcx.is_diagnostic_item(sym::transmute, def_id) {
|
||||
if is_zero(&args[0]) {
|
||||
return Some(InitKind::Zeroed);
|
||||
}
|
||||
} else if cx.tcx.is_diagnostic_item(sym::transmute, def_id) && is_zero(&args[0])
|
||||
{
|
||||
return Some(InitKind::Zeroed);
|
||||
}
|
||||
}
|
||||
} else if let hir::ExprKind::MethodCall(_, _, ref args, _) = expr.kind {
|
||||
|
@ -2880,7 +2878,7 @@ impl<'tcx> LateLintPass<'tcx> for ClashingExternDeclarations {
|
|||
fn check_foreign_item(&mut self, cx: &LateContext<'tcx>, this_fi: &hir::ForeignItem<'_>) {
|
||||
trace!("ClashingExternDeclarations: check_foreign_item: {:?}", this_fi);
|
||||
if let ForeignItemKind::Fn(..) = this_fi.kind {
|
||||
let tcx = *&cx.tcx;
|
||||
let tcx = cx.tcx;
|
||||
if let Some(existing_hid) = self.insert(tcx, this_fi) {
|
||||
let existing_decl_ty = tcx.type_of(tcx.hir().local_def_id(existing_hid));
|
||||
let this_decl_ty = tcx.type_of(tcx.hir().local_def_id(this_fi.hir_id));
|
||||
|
|
|
@ -320,7 +320,7 @@ impl<'tcx> LateLintPass<'tcx> for NonSnakeCase {
|
|||
.with_hi(lit.span.hi() - BytePos(right as u32)),
|
||||
)
|
||||
})
|
||||
.unwrap_or_else(|| lit.span);
|
||||
.unwrap_or(lit.span);
|
||||
|
||||
Some(Ident::new(name, sp))
|
||||
} else {
|
||||
|
|
|
@ -544,15 +544,15 @@ impl<'tcx> LateLintPass<'tcx> for TypeLimits {
|
|||
}
|
||||
|
||||
fn is_comparison(binop: hir::BinOp) -> bool {
|
||||
match binop.node {
|
||||
matches!(
|
||||
binop.node,
|
||||
hir::BinOpKind::Eq
|
||||
| hir::BinOpKind::Lt
|
||||
| hir::BinOpKind::Le
|
||||
| hir::BinOpKind::Ne
|
||||
| hir::BinOpKind::Ge
|
||||
| hir::BinOpKind::Gt => true,
|
||||
_ => false,
|
||||
}
|
||||
| hir::BinOpKind::Lt
|
||||
| hir::BinOpKind::Le
|
||||
| hir::BinOpKind::Ne
|
||||
| hir::BinOpKind::Ge
|
||||
| hir::BinOpKind::Gt
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1233,15 +1233,10 @@ impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
|
|||
}
|
||||
|
||||
fn is_internal_abi(&self, abi: SpecAbi) -> bool {
|
||||
if let SpecAbi::Rust
|
||||
| SpecAbi::RustCall
|
||||
| SpecAbi::RustIntrinsic
|
||||
| SpecAbi::PlatformIntrinsic = abi
|
||||
{
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
matches!(
|
||||
abi,
|
||||
SpecAbi::Rust | SpecAbi::RustCall | SpecAbi::RustIntrinsic | SpecAbi::PlatformIntrinsic
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -752,14 +752,11 @@ impl UnusedDelimLint for UnusedParens {
|
|||
&& value.attrs.is_empty()
|
||||
&& !value.span.from_expansion()
|
||||
&& (ctx != UnusedDelimsCtx::LetScrutineeExpr
|
||||
|| match inner.kind {
|
||||
ast::ExprKind::Binary(
|
||||
|| !matches!(inner.kind, ast::ExprKind::Binary(
|
||||
rustc_span::source_map::Spanned { node, .. },
|
||||
_,
|
||||
_,
|
||||
) if node.lazy() => false,
|
||||
_ => true,
|
||||
})
|
||||
) if node.lazy()))
|
||||
{
|
||||
self.emit_unused_delims_expr(cx, value, ctx, left_pos, right_pos)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue