mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-16 01:38:09 +00:00
Revert "Fix cases of match_wildcard_for_single_variants lint when it is spanned on Option"
This reverts commit 4948307977
.
This commit is contained in:
parent
1c59cd5f21
commit
10313a2631
7 changed files with 9 additions and 13 deletions
|
@ -139,7 +139,6 @@ impl Constant {
|
|||
.find(|r| r.map_or(true, |o| o != Ordering::Equal))
|
||||
.unwrap_or_else(|| Some(l.len().cmp(&r.len()))),
|
||||
(&Self::Repeat(ref lv, ref ls), &Self::Repeat(ref rv, ref rs)) => {
|
||||
#[allow(clippy::match_wildcard_for_single_variants)]
|
||||
match Self::partial_cmp(tcx, cmp_type, lv, rv) {
|
||||
Some(Equal) => Some(ls.cmp(rs)),
|
||||
x => x,
|
||||
|
@ -355,14 +354,14 @@ impl<'c, 'cc> ConstEvalLateContext<'c, 'cc> {
|
|||
(Some(Constant::Vec(vec)), Some(Constant::Int(index))) => match vec.get(index as usize) {
|
||||
Some(Constant::F32(x)) => Some(Constant::F32(*x)),
|
||||
Some(Constant::F64(x)) => Some(Constant::F64(*x)),
|
||||
Some(_) | None => None,
|
||||
_ => None,
|
||||
},
|
||||
(Some(Constant::Vec(vec)), _) => {
|
||||
if !vec.is_empty() && vec.iter().all(|x| *x == vec[0]) {
|
||||
match vec.get(0) {
|
||||
Some(Constant::F32(x)) => Some(Constant::F32(*x)),
|
||||
Some(Constant::F64(x)) => Some(Constant::F64(*x)),
|
||||
Some(_) | None => None,
|
||||
_ => None,
|
||||
}
|
||||
} else {
|
||||
None
|
||||
|
@ -533,7 +532,7 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
|
|||
})
|
||||
.collect::<Option<Vec<Constant>>>()
|
||||
.map(Constant::Vec),
|
||||
Some(_) | None => None,
|
||||
_ => None,
|
||||
},
|
||||
ty::Float(FloatTy::F64) => match miri_to_const(len) {
|
||||
Some(Constant::Int(len)) => alloc
|
||||
|
@ -547,7 +546,7 @@ pub fn miri_to_const(result: &ty::Const<'_>) -> Option<Constant> {
|
|||
})
|
||||
.collect::<Option<Vec<Constant>>>()
|
||||
.map(Constant::Vec),
|
||||
Some(_) | None => None,
|
||||
_ => None,
|
||||
},
|
||||
// FIXME: implement other array type conversions.
|
||||
_ => None,
|
||||
|
|
|
@ -95,12 +95,12 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BoxedLocal {
|
|||
fn is_argument(map: rustc_middle::hir::map::Map<'_>, id: HirId) -> bool {
|
||||
match map.find(id) {
|
||||
Some(Node::Binding(_)) => (),
|
||||
Some(_) | None => return false,
|
||||
_ => return false,
|
||||
}
|
||||
|
||||
match map.find(map.get_parent_node(id)) {
|
||||
Some(Node::Param(_)) => true,
|
||||
Some(_) | None => false,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -410,7 +410,7 @@ fn is_zero(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> bool {
|
|||
Some(Constant::Int(i)) => i == 0,
|
||||
Some(Constant::F32(f)) => f == 0.0,
|
||||
Some(Constant::F64(f)) => f == 0.0,
|
||||
Some(_) | None => false,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2154,7 +2154,7 @@ fn is_loop_nested(cx: &LateContext<'_, '_>, loop_expr: &Expr<'_>, iter_expr: &Ex
|
|||
}
|
||||
},
|
||||
Some(Node::Stmt(_)) => (),
|
||||
Some(_) | None => {
|
||||
_ => {
|
||||
return false;
|
||||
},
|
||||
}
|
||||
|
|
|
@ -509,7 +509,7 @@ fn is_allowed<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr<'_>) -> boo
|
|||
Constant::F64(f) => *f == 0.0 || (*f).is_infinite(),
|
||||
_ => false,
|
||||
}),
|
||||
Some(_) | None => false,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ struct OperandInfo {
|
|||
}
|
||||
|
||||
fn analyze_operand(operand: &Expr<'_>, cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option<OperandInfo> {
|
||||
#[allow(clippy::match_wildcard_for_single_variants)]
|
||||
match constant(cx, cx.tables, operand) {
|
||||
Some((Constant::Int(v), _)) => match cx.tables.expr_ty(expr).kind {
|
||||
ty::Int(ity) => {
|
||||
|
|
|
@ -370,7 +370,6 @@ pub fn trait_ref_of_method<'tcx>(cx: &LateContext<'_, 'tcx>, hir_id: HirId) -> O
|
|||
|
||||
/// Checks whether this type implements `Drop`.
|
||||
pub fn has_drop<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
|
||||
#[allow(clippy::match_wildcard_for_single_variants)]
|
||||
match ty.ty_adt_def() {
|
||||
Some(def) => def.has_dtor(cx.tcx),
|
||||
_ => false,
|
||||
|
@ -445,7 +444,6 @@ pub fn is_entrypoint_fn(cx: &LateContext<'_, '_>, def_id: DefId) -> bool {
|
|||
/// Gets the name of the item the expression is in, if available.
|
||||
pub fn get_item_name(cx: &LateContext<'_, '_>, expr: &Expr<'_>) -> Option<Name> {
|
||||
let parent_id = cx.tcx.hir().get_parent_item(expr.hir_id);
|
||||
#[allow(clippy::match_wildcard_for_single_variants)]
|
||||
match cx.tcx.hir().find(parent_id) {
|
||||
Some(
|
||||
Node::Item(Item { ident, .. })
|
||||
|
|
Loading…
Reference in a new issue