Skip to content

Commit 83f1454

Browse files
committed
Fix function and variable names
1 parent aee4f1f commit 83f1454

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

clippy_lints/src/bool_assert_comparison.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -40,23 +40,23 @@ fn is_bool_lit(e: &Expr<'_>) -> bool {
4040
) && !e.span.from_expansion()
4141
}
4242

43-
fn impl_not_trait_with_bool_out(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> bool {
43+
fn is_impl_not_trait_with_bool_out(cx: &LateContext<'tcx>, e: &'tcx Expr<'_>) -> bool {
4444
let ty = cx.typeck_results().expr_ty(e);
4545

4646
cx.tcx
4747
.lang_items()
4848
.not_trait()
49-
.filter(|id| implements_trait(cx, ty, *id, &[]))
50-
.and_then(|id| {
51-
cx.tcx.associated_items(id).find_by_name_and_kind(
49+
.filter(|trait_id| implements_trait(cx, ty, *trait_id, &[]))
50+
.and_then(|trait_id| {
51+
cx.tcx.associated_items(trait_id).find_by_name_and_kind(
5252
cx.tcx,
5353
Ident::from_str("Output"),
5454
ty::AssocKind::Type,
55-
id,
55+
trait_id,
5656
)
5757
})
58-
.map_or(false, |item| {
59-
let proj = cx.tcx.mk_projection(item.def_id, cx.tcx.mk_substs_trait(ty, &[]));
58+
.map_or(false, |assoc_item| {
59+
let proj = cx.tcx.mk_projection(assoc_item.def_id, cx.tcx.mk_substs_trait(ty, &[]));
6060
let nty = cx.tcx.normalize_erasing_regions(cx.param_env, proj);
6161

6262
nty.is_bool()
@@ -82,7 +82,7 @@ impl<'tcx> LateLintPass<'tcx> for BoolAssertComparison {
8282
return;
8383
}
8484

85-
if !impl_not_trait_with_bool_out(cx, a) || !impl_not_trait_with_bool_out(cx, b) {
85+
if !is_impl_not_trait_with_bool_out(cx, a) || !is_impl_not_trait_with_bool_out(cx, b) {
8686
// At this point the expression which is not a boolean
8787
// literal does not implement Not trait with a bool output,
8888
// so we cannot suggest to rewrite our code

tests/ui/bool_assert_comparison.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,44 @@ macro_rules! b {
1616
// Implements the Not trait but with an output type
1717
// that's not bool. Should not suggest a rewrite
1818
#[derive(Debug)]
19-
enum A {
19+
enum ImplNotTraitWithoutBool {
2020
VariantX(bool),
2121
VariantY(u32),
2222
}
2323

24-
impl PartialEq<bool> for A {
24+
impl PartialEq<bool> for ImplNotTraitWithoutBool {
2525
fn eq(&self, other: &bool) -> bool {
2626
match *self {
27-
A::VariantX(b) => b == *other,
27+
ImplNotTraitWithoutBool::VariantX(b) => b == *other,
2828
_ => false,
2929
}
3030
}
3131
}
3232

33-
impl Not for A {
33+
impl Not for ImplNotTraitWithoutBool {
3434
type Output = Self;
3535

3636
fn not(self) -> Self::Output {
3737
match self {
38-
A::VariantX(b) => A::VariantX(!b),
39-
A::VariantY(0) => A::VariantY(1),
40-
A::VariantY(_) => A::VariantY(0),
38+
ImplNotTraitWithoutBool::VariantX(b) => ImplNotTraitWithoutBool::VariantX(!b),
39+
ImplNotTraitWithoutBool::VariantY(0) => ImplNotTraitWithoutBool::VariantY(1),
40+
ImplNotTraitWithoutBool::VariantY(_) => ImplNotTraitWithoutBool::VariantY(0),
4141
}
4242
}
4343
}
4444

4545
// This type implements the Not trait with an Output of
4646
// type bool. Using assert!(..) must be suggested
4747
#[derive(Debug)]
48-
struct B;
48+
struct ImplNotTraitWithBool;
4949

50-
impl PartialEq<bool> for B {
50+
impl PartialEq<bool> for ImplNotTraitWithBool {
5151
fn eq(&self, other: &bool) -> bool {
5252
false
5353
}
5454
}
5555

56-
impl Not for B {
56+
impl Not for ImplNotTraitWithBool {
5757
type Output = bool;
5858

5959
fn not(self) -> Self::Output {
@@ -62,8 +62,8 @@ impl Not for B {
6262
}
6363

6464
fn main() {
65-
let a = A::VariantX(true);
66-
let b = B {};
65+
let a = ImplNotTraitWithoutBool::VariantX(true);
66+
let b = ImplNotTraitWithBool;
6767

6868
assert_eq!("a".len(), 1);
6969
assert_eq!("a".is_empty(), false);

0 commit comments

Comments
 (0)