dogfood inverse bool_to_int_with_if

This commit is contained in:
Jacob Kiesel 2022-09-14 00:27:56 -06:00 committed by Jacob Kiesel
parent 1eb41804a2
commit 9925600870
3 changed files with 4 additions and 7 deletions

View file

@ -297,13 +297,10 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing {
if !is_lint_allowed(cx, EXPLICIT_DEREF_METHODS, expr.hir_id)
&& position.lint_explicit_deref() =>
{
let ty_changed_count = usize::from(!deref_method_same_type(expr_ty, typeck.expr_ty(sub_expr)));
self.state = Some((
State::DerefMethod {
ty_changed_count: if deref_method_same_type(expr_ty, typeck.expr_ty(sub_expr)) {
0
} else {
1
},
ty_changed_count,
is_final_ufcs: matches!(expr.kind, ExprKind::Call(..)),
target_mut,
},

View file

@ -269,7 +269,7 @@ fn check_other_call_arg<'tcx>(
// We can't add an `&` when the trait is `Deref` because `Target = &T` won't match
// `Target = T`.
if n_refs > 0 || is_copy(cx, receiver_ty) || trait_predicate.def_id() != deref_trait_id;
let n_refs = max(n_refs, if is_copy(cx, receiver_ty) { 0 } else { 1 });
let n_refs = max(n_refs, usize::from(!is_copy(cx, receiver_ty)));
if let Some(receiver_snippet) = snippet_opt(cx, receiver.span);
then {
span_lint_and_sugg(

View file

@ -274,7 +274,7 @@ impl AsyncLen {
}
pub async fn len(&self) -> usize {
if self.async_task().await { 0 } else { 1 }
usize::from(!self.async_task().await)
}
pub async fn is_empty(&self) -> bool {