Skip to content

Commit 9925600

Browse files
committed
dogfood inverse bool_to_int_with_if
1 parent 1eb4180 commit 9925600

File tree

3 files changed

+4
-7
lines changed

3 files changed

+4
-7
lines changed

clippy_lints/src/dereference.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,10 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing {
297297
if !is_lint_allowed(cx, EXPLICIT_DEREF_METHODS, expr.hir_id)
298298
&& position.lint_explicit_deref() =>
299299
{
300+
let ty_changed_count = usize::from(!deref_method_same_type(expr_ty, typeck.expr_ty(sub_expr)));
300301
self.state = Some((
301302
State::DerefMethod {
302-
ty_changed_count: if deref_method_same_type(expr_ty, typeck.expr_ty(sub_expr)) {
303-
0
304-
} else {
305-
1
306-
},
303+
ty_changed_count,
307304
is_final_ufcs: matches!(expr.kind, ExprKind::Call(..)),
308305
target_mut,
309306
},

clippy_lints/src/methods/unnecessary_to_owned.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn check_other_call_arg<'tcx>(
269269
// We can't add an `&` when the trait is `Deref` because `Target = &T` won't match
270270
// `Target = T`.
271271
if n_refs > 0 || is_copy(cx, receiver_ty) || trait_predicate.def_id() != deref_trait_id;
272-
let n_refs = max(n_refs, if is_copy(cx, receiver_ty) { 0 } else { 1 });
272+
let n_refs = max(n_refs, usize::from(!is_copy(cx, receiver_ty)));
273273
if let Some(receiver_snippet) = snippet_opt(cx, receiver.span);
274274
then {
275275
span_lint_and_sugg(

tests/ui/len_without_is_empty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ impl AsyncLen {
274274
}
275275

276276
pub async fn len(&self) -> usize {
277-
if self.async_task().await { 0 } else { 1 }
277+
usize::from(!self.async_task().await)
278278
}
279279

280280
pub async fn is_empty(&self) -> bool {

0 commit comments

Comments
 (0)