Skip to content

Commit 13b4bb1

Browse files
committed
Clean up after if chain removal
1 parent 9681b4a commit 13b4bb1

File tree

230 files changed

+1455
-1848
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+1455
-1848
lines changed

clippy_lints/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ cargo_metadata = "0.15.3"
1414
clippy_config = { path = "../clippy_config" }
1515
clippy_utils = { path = "../clippy_utils" }
1616
declare_clippy_lint = { path = "../declare_clippy_lint" }
17-
if_chain = "1.0"
1817
itertools = "0.10.1"
1918
quine-mc_cluskey = "0.2"
2019
regex-syntax = "0.7"

clippy_lints/src/attrs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sug
55
use clippy_utils::is_from_proc_macro;
66
use clippy_utils::macros::{is_panic, macro_backtrace};
77
use clippy_utils::source::{first_line_of_span, is_present_in_source, snippet_opt, without_block_comments};
8-
use if_chain::if_chain;
98
use rustc_ast::token::{Token, TokenKind};
109
use rustc_ast::tokenstream::TokenTree;
1110
use rustc_ast::{

clippy_lints/src/blocks_in_if_conditions.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use clippy_utils::ty::implements_trait;
44
use clippy_utils::visitors::{for_each_expr, Descend};
55
use clippy_utils::{get_parent_expr, higher};
66
use core::ops::ControlFlow;
7-
use if_chain::if_chain;
87
use rustc_errors::Applicability;
98
use rustc_hir::{BlockCheckMode, Expr, ExprKind};
109
use rustc_lint::{LateContext, LateLintPass, LintContext};

clippy_lints/src/booleans.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then};
22
use clippy_utils::eq_expr_value;
33
use clippy_utils::source::snippet_opt;
44
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item};
5-
use if_chain::if_chain;
65
use rustc_ast::ast::LitKind;
76
use rustc_errors::Applicability;
87
use rustc_hir::intravisit::{walk_expr, FnKind, Visitor};

clippy_lints/src/borrow_deref_ref.rs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,25 +54,25 @@ impl<'tcx> LateLintPass<'tcx> for BorrowDerefRef {
5454
&& !addrof_target.span.from_expansion()
5555
&& let ExprKind::Unary(UnOp::Deref, deref_target) = addrof_target.kind
5656
&& !deref_target.span.from_expansion()
57-
&& !matches!(deref_target.kind, ExprKind::Unary(UnOp::Deref, ..) )
57+
&& !matches!(deref_target.kind, ExprKind::Unary(UnOp::Deref, ..))
5858
&& let ref_ty = cx.typeck_results().expr_ty(deref_target)
5959
&& let ty::Ref(_, inner_ty, Mutability::Not) = ref_ty.kind()
6060
&& !is_from_proc_macro(cx, e)
6161
{
62-
63-
if let Some(parent_expr) = get_parent_expr(cx, e){
64-
if matches!(parent_expr.kind, ExprKind::Unary(UnOp::Deref, ..)) &&
65-
!is_lint_allowed(cx, DEREF_ADDROF, parent_expr.hir_id) {
62+
if let Some(parent_expr) = get_parent_expr(cx, e) {
63+
if matches!(parent_expr.kind, ExprKind::Unary(UnOp::Deref, ..))
64+
&& !is_lint_allowed(cx, DEREF_ADDROF, parent_expr.hir_id)
65+
{
6666
return;
6767
}
6868

6969
// modification to `&mut &*x` is different from `&mut x`
70-
if matches!(deref_target.kind, ExprKind::Path(..)
71-
| ExprKind::Field(..)
72-
| ExprKind::Index(..)
73-
| ExprKind::Unary(UnOp::Deref, ..))
74-
&& matches!(parent_expr.kind, ExprKind::AddrOf(_, Mutability::Mut, _)) {
75-
return;
70+
if matches!(
71+
deref_target.kind,
72+
ExprKind::Path(..) | ExprKind::Field(..) | ExprKind::Index(..) | ExprKind::Unary(UnOp::Deref, ..)
73+
) && matches!(parent_expr.kind, ExprKind::AddrOf(_, Mutability::Mut, _))
74+
{
75+
return;
7676
}
7777
}
7878

@@ -86,12 +86,12 @@ impl<'tcx> LateLintPass<'tcx> for BorrowDerefRef {
8686
e.span,
8787
"if you would like to reborrow, try removing `&*`",
8888
snippet_opt(cx, deref_target.span).unwrap(),
89-
Applicability::MachineApplicable
89+
Applicability::MachineApplicable,
9090
);
9191

9292
// has deref trait -> give 2 help
9393
// doesn't have deref trait -> give 1 help
94-
if let Some(deref_trait_id) = cx.tcx.lang_items().deref_trait(){
94+
if let Some(deref_trait_id) = cx.tcx.lang_items().deref_trait() {
9595
if !implements_trait(cx, *inner_ty, deref_trait_id, &[]) {
9696
return;
9797
}
@@ -100,16 +100,11 @@ impl<'tcx> LateLintPass<'tcx> for BorrowDerefRef {
100100
diag.span_suggestion(
101101
e.span,
102102
"if you would like to deref, try using `&**`",
103-
format!(
104-
"&**{}",
105-
&snippet_opt(cx, deref_target.span).unwrap(),
106-
),
107-
Applicability::MaybeIncorrect
103+
format!("&**{}", &snippet_opt(cx, deref_target.span).unwrap()),
104+
Applicability::MaybeIncorrect,
108105
);
109-
110-
}
106+
},
111107
);
112-
113108
}
114109
}
115110
}

clippy_lints/src/cargo/multiple_crate_versions.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
33
use cargo_metadata::{DependencyKind, Metadata, Node, Package, PackageId};
44
use clippy_utils::diagnostics::span_lint;
5-
use if_chain::if_chain;
65
use itertools::Itertools;
76
use rustc_hir::def_id::LOCAL_CRATE;
87
use rustc_lint::LateContext;
@@ -16,9 +15,13 @@ pub(super) fn check(cx: &LateContext<'_>, metadata: &Metadata) {
1615
packages.sort_by(|a, b| a.name.cmp(&b.name));
1716

1817
if let Some(resolve) = &metadata.resolve
19-
&& let Some(local_id) = packages
20-
.iter()
21-
.find_map(|p| if p.name == local_name.as_str() { Some(&p.id) } else { None })
18+
&& let Some(local_id) = packages.iter().find_map(|p| {
19+
if p.name == local_name.as_str() {
20+
Some(&p.id)
21+
} else {
22+
None
23+
}
24+
})
2225
{
2326
for (name, group) in &packages.iter().group_by(|p| p.name.clone()) {
2427
let group: Vec<&Package> = group.collect();

clippy_lints/src/cargo/wildcard_dependencies.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use cargo_metadata::Metadata;
22
use clippy_utils::diagnostics::span_lint;
3-
use if_chain::if_chain;
43
use rustc_lint::LateContext;
54
use rustc_span::source_map::DUMMY_SP;
65

clippy_lints/src/casts/cast_sign_loss.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use clippy_utils::consts::{constant, Constant};
22
use clippy_utils::diagnostics::span_lint;
33
use clippy_utils::{method_chain_args, sext};
4-
use if_chain::if_chain;
54
use rustc_hir::{Expr, ExprKind};
65
use rustc_lint::LateContext;
76
use rustc_middle::ty::{self, Ty};

clippy_lints/src/casts/cast_slice_different_sizes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use clippy_config::msrvs::{self, Msrv};
22
use clippy_utils::diagnostics::span_lint_and_then;
33
use clippy_utils::source;
4-
use if_chain::if_chain;
54
use rustc_ast::Mutability;
65
use rustc_hir::{Expr, ExprKind, Node};
76
use rustc_lint::LateContext;

clippy_lints/src/casts/cast_slice_from_raw_parts.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use clippy_config::msrvs::{self, Msrv};
22
use clippy_utils::diagnostics::span_lint_and_sugg;
33
use clippy_utils::source::snippet_with_context;
4-
use if_chain::if_chain;
54
use rustc_errors::Applicability;
65
use rustc_hir::def_id::DefId;
76
use rustc_hir::{Expr, ExprKind};
@@ -37,7 +36,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
3736
{
3837
let func = match rpk {
3938
RawPartsKind::Immutable => "from_raw_parts",
40-
RawPartsKind::Mutable => "from_raw_parts_mut"
39+
RawPartsKind::Mutable => "from_raw_parts_mut",
4140
};
4241
let span = expr.span;
4342
let mut applicability = Applicability::MachineApplicable;
@@ -50,7 +49,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &Expr<'_>, cast_expr: &Expr<'_>,
5049
&format!("casting the result of `{func}` to {cast_to}"),
5150
"replace with",
5251
format!("core::ptr::slice_{func}({ptr}, {len})"),
53-
applicability
52+
applicability,
5453
);
5554
}
5655
}

0 commit comments

Comments
 (0)