Skip to content

Commit eb6190b

Browse files
committed
fix: use expr_ty(expr)
1 parent d3a35c9 commit eb6190b

File tree

2 files changed

+2
-11
lines changed

2 files changed

+2
-11
lines changed

clippy_lints/src/methods/manual_is_variant_and.rs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ use clippy_utils::source::snippet;
44
use clippy_utils::ty::is_type_diagnostic_item;
55
use rustc_errors::Applicability;
66
use rustc_lint::LateContext;
7-
use rustc_middle::ty;
8-
use rustc_middle::ty::Ty;
97
use rustc_span::{sym, Span};
108

119
use super::MANUAL_IS_VARIANT_AND;
@@ -16,7 +14,6 @@ pub(super) fn check<'tcx>(
1614
map_recv: &'tcx rustc_hir::Expr<'_>,
1715
map_arg: &'tcx rustc_hir::Expr<'_>,
1816
map_span: Span,
19-
unwrap_recv: &'tcx rustc_hir::Expr<'_>,
2017
msrv: &Msrv,
2118
) {
2219
// Don't lint if:
@@ -34,13 +31,7 @@ pub(super) fn check<'tcx>(
3431
}
3532

3633
// 3. the caller of `unwrap_or_default` is neither `Option<bool>` nor `Result<bool, _>`
37-
// - we don't need to check the type of AdtDef here as we know from 2 that it must be either
38-
// `Option` or `Result`.
39-
let map_arg_return_bool = match cx.typeck_results().expr_ty(unwrap_recv).kind() {
40-
ty::Adt(_, args) => args.first().and_then(|garg| garg.as_type()).is_some_and(Ty::is_bool),
41-
_ => false,
42-
};
43-
if !map_arg_return_bool {
34+
if !cx.typeck_results().expr_ty(expr).is_bool() {
4435
return;
4536
}
4637

clippy_lints/src/methods/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4622,7 +4622,7 @@ impl Methods {
46224622
},
46234623
("unwrap_or_default", []) => {
46244624
if let Some(("map", m_recv, [arg], span, _)) = method_call(recv) {
4625-
manual_is_variant_and::check(cx, expr, m_recv, arg, span, recv, &self.msrv);
4625+
manual_is_variant_and::check(cx, expr, m_recv, arg, span, &self.msrv);
46264626
}
46274627
unnecessary_literal_unwrap::check(cx, expr, recv, name, args);
46284628
},

0 commit comments

Comments
 (0)