Skip to content

Commit 5464039

Browse files
barun511ada4a
andcommitted
Dogfood fixes
Co-authored-by: Ada Alakbarova <ada.alakbarova@proton.me>
1 parent 7fd47ce commit 5464039

6 files changed

Lines changed: 17 additions & 33 deletions

File tree

clippy_dev/src/serve.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ fn is_metadata_outdated(time: SystemTime) -> bool {
8585
dir.map_while(|e| log_err_and_continue(e, ".".as_ref())).any(|e| {
8686
let name = e.file_name();
8787
let name_bytes = name.as_encoded_bytes();
88-
if (name_bytes.starts_with(b"clippy_lints") && name_bytes != b"clippy_lints_internal")
89-
|| name_bytes == b"clippy_config"
90-
{
91-
WalkDir::new(&name)
88+
((name_bytes.starts_with(b"clippy_lints") && name_bytes != b"clippy_lints_internal")
89+
|| name_bytes == b"clippy_config")
90+
&& WalkDir::new(&name)
9291
.into_iter()
9392
.map_while(|e| log_err_and_continue(e, name.as_ref()))
9493
.filter(|e| e.file_type().is_file())
@@ -97,8 +96,5 @@ fn is_metadata_outdated(time: SystemTime) -> bool {
9796
.and_then(|m| log_err_and_continue(m.modified(), e.path()))
9897
})
9998
.any(|ftime| time < ftime)
100-
} else {
101-
false
102-
}
10399
})
104100
}

clippy_lints/src/functions/must_use.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,8 @@ fn is_mutable_pat(cx: &LateContext<'_>, pat: &hir::Pat<'_>, tys: &mut DefIdSet)
255255
if let hir::PatKind::Wild = pat.kind {
256256
return false; // ignore `_` patterns
257257
}
258-
if cx.tcx.has_typeck_results(pat.hir_id.owner.def_id) {
259-
is_mutable_ty(cx, cx.tcx.typeck(pat.hir_id.owner.def_id).pat_ty(pat), tys)
260-
} else {
261-
false
262-
}
258+
cx.tcx.has_typeck_results(pat.hir_id.owner.def_id)
259+
&& is_mutable_ty(cx, cx.tcx.typeck(pat.hir_id.owner.def_id).pat_ty(pat), tys)
263260
}
264261

265262
fn is_mutable_ty<'tcx>(cx: &LateContext<'tcx>, ty: Ty<'tcx>, tys: &mut DefIdSet) -> bool {

clippy_lints/src/literal_representation.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,11 +351,7 @@ impl LiteralDigitGrouping {
351351
}
352352

353353
let group_sizes: Vec<usize> = num_lit.integer.split('_').map(str::len).collect();
354-
if UUID_GROUP_LENS.len() == group_sizes.len() {
355-
iter::zip(&UUID_GROUP_LENS, &group_sizes).all(|(&a, &b)| a == b)
356-
} else {
357-
false
358-
}
354+
UUID_GROUP_LENS.len() == group_sizes.len() && iter::zip(&UUID_GROUP_LENS, &group_sizes).all(|(&a, &b)| a == b)
359355
}
360356

361357
/// Given the sizes of the digit groups of both integral and fractional

clippy_lints/src/no_effect.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,11 +254,9 @@ fn has_no_effect(cx: &LateContext<'_>, expr: &Expr<'_>) -> bool {
254254
cx.qpath_res(qpath, callee.hir_id),
255255
Res::Def(DefKind::Struct | DefKind::Variant | DefKind::Ctor(..), ..)
256256
);
257-
if def_matched || is_range_literal(expr) {
258-
!expr_ty_has_significant_drop(cx, expr) && args.iter().all(|arg| has_no_effect(cx, arg))
259-
} else {
260-
false
261-
}
257+
(def_matched || is_range_literal(expr))
258+
&& !expr_ty_has_significant_drop(cx, expr)
259+
&& args.iter().all(|arg| has_no_effect(cx, arg))
262260
} else {
263261
false
264262
}

clippy_lints/src/unit_types/unit_arg.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,12 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
4040
.into_iter()
4141
.chain(args)
4242
.filter(|arg| {
43-
if cx.typeck_results().expr_ty(arg).is_unit() && !utils::is_unit_literal(arg) {
44-
!matches!(
43+
cx.typeck_results().expr_ty(arg).is_unit()
44+
&& !utils::is_unit_literal(arg)
45+
&& !matches!(
4546
&arg.kind,
4647
ExprKind::Match(.., MatchSource::TryDesugar(_)) | ExprKind::Path(..)
4748
)
48-
} else {
49-
false
50-
}
5149
})
5250
.collect::<Vec<_>>();
5351
if !args_to_recover.is_empty() && !is_from_proc_macro(cx, expr) {

clippy_utils/src/hir_utils.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -852,12 +852,11 @@ impl HirEqInterExpr<'_, '_, '_> {
852852
}
853853

854854
fn eq_path_parameters(&mut self, left: &GenericArgs<'_>, right: &GenericArgs<'_>) -> bool {
855-
if left.parenthesized == right.parenthesized {
856-
over(left.args, right.args, |l, r| self.eq_generic_arg(l, r)) // FIXME(flip1995): may not work
857-
&& over(left.constraints, right.constraints, |l, r| self.eq_assoc_eq_constraint(l, r))
858-
} else {
859-
false
860-
}
855+
left.parenthesized == right.parenthesized
856+
&& over(left.args, right.args, |l, r| self.eq_generic_arg(l, r)) // FIXME(flip1995): may not work
857+
&& over(left.constraints, right.constraints, |l, r| {
858+
self.eq_assoc_eq_constraint(l, r)
859+
})
861860
}
862861

863862
pub fn eq_path_segments<'tcx>(

0 commit comments

Comments
 (0)