Skip to content

Commit 61f691f

Browse files
committed
Fix adjacent code
1 parent 428844e commit 61f691f

29 files changed

+51
-50
lines changed

clippy.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
avoid-breaking-exported-api = false
22

3+
initializer-suggestions = "machine-applicable"
4+
35
[[disallowed-methods]]
46
path = "rustc_lint::context::LintContext::lint"
57
reason = "this function does not add a link to our documentation, please use the `clippy_utils::diagnostics::span_lint*` functions instead"

clippy_dev/src/fmt.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,8 @@ fn fmt_conf(check: bool) -> Result<(), Error> {
179179
#[expect(clippy::drain_collect)]
180180
fields.push(ClippyConf {
181181
name,
182-
lints: lints.drain(..).collect(),
183182
attrs: &conf[attrs_start..attrs_end],
183+
lints: lints.drain(..).collect(),
184184
field: conf[field_start..i].trim_end(),
185185
});
186186
attrs_start = i;
@@ -191,8 +191,8 @@ fn fmt_conf(check: bool) -> Result<(), Error> {
191191
#[expect(clippy::drain_collect)]
192192
fields.push(ClippyConf {
193193
name,
194-
lints: lints.drain(..).collect(),
195194
attrs: &conf[attrs_start..attrs_end],
195+
lints: lints.drain(..).collect(),
196196
field: conf[field_start..i].trim_end(),
197197
});
198198
attrs_start = i;
@@ -220,8 +220,8 @@ fn fmt_conf(check: bool) -> Result<(), Error> {
220220
}
221221
fields.push(ClippyConf {
222222
name,
223-
lints,
224223
attrs: &conf[attrs_start..attrs_end],
224+
lints,
225225
field: conf[field_start..].trim_end(),
226226
});
227227

clippy_lints/src/arbitrary_source_item_ordering.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,8 +428,8 @@ impl<'tcx> LateLintPass<'tcx> for ArbitrarySourceItemOrdering {
428428

429429
// Makes a note of the current item for comparison with the next.
430430
cur_t = Some(CurItem {
431-
order: module_level_order,
432431
item,
432+
order: module_level_order,
433433
name: get_item_name(item),
434434
});
435435
}

clippy_lints/src/doc/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -770,8 +770,8 @@ fn check_attrs(cx: &LateContext<'_>, valid_idents: &FxHashSet<String>, attrs: &[
770770
parser.into_offset_iter(),
771771
&doc,
772772
Fragments {
773-
fragments: &fragments,
774773
doc: &doc,
774+
fragments: &fragments,
775775
},
776776
))
777777
}

clippy_lints/src/entry.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -678,12 +678,12 @@ fn find_insert_calls<'tcx>(
678678
map: contains_expr.map,
679679
key: contains_expr.key,
680680
ctxt: expr.span.ctxt(),
681-
edits: Vec::new(),
682-
is_map_used: false,
683681
allow_insert_closure: true,
684682
can_use_entry: true,
685683
in_tail_pos: true,
686684
is_single_insert: true,
685+
is_map_used: false,
686+
edits: Vec::new(),
687687
loops: Vec::new(),
688688
locals: HirIdSet::default(),
689689
};

clippy_lints/src/implied_bounds_in_impls.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ fn collect_supertrait_bounds<'tcx>(cx: &LateContext<'tcx>, bounds: GenericBounds
243243
&& !predicates.is_empty()
244244
{
245245
Some(ImplTraitBound {
246+
span: bound.span(),
246247
predicates,
248+
trait_def_id,
247249
args: path.args.map_or([].as_slice(), |p| p.args),
248250
constraints: path.args.map_or([].as_slice(), |p| p.constraints),
249-
trait_def_id,
250-
span: bound.span(),
251251
})
252252
} else {
253253
None

clippy_lints/src/loops/infinite_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ pub(super) fn check<'tcx>(
3838
cx,
3939
label,
4040
inner_labels: label.into_iter().collect(),
41-
is_finite: false,
4241
loop_depth: 0,
42+
is_finite: false,
4343
};
4444
loop_visitor.visit_block(loop_block);
4545

clippy_lints/src/macro_metavars_in_unsafe.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,11 +220,10 @@ impl<'tcx> LateLintPass<'tcx> for ExprMetavarsInUnsafe {
220220
// `check_stmt_post` on `(Late)LintPass`, which we'd need to detect when we're leaving a macro span
221221

222222
let mut vis = BodyVisitor {
223-
#[expect(clippy::bool_to_int_with_if)] // obfuscates the meaning
224-
expn_depth: if body.value.span.from_expansion() { 1 } else { 0 },
225223
macro_unsafe_blocks: Vec::new(),
224+
expn_depth: if body.value.span.from_expansion() { 1 } else { 0 },
225+
cx,
226226
lint: self,
227-
cx
228227
};
229228
vis.visit_body(body);
230229
}

clippy_lints/src/methods/needless_collect.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -469,14 +469,14 @@ fn detect_iter_and_into_iters<'tcx: 'a, 'a>(
469469
captured_ids: HirIdSet,
470470
) -> Option<Vec<IterFunction>> {
471471
let mut visitor = IterFunctionVisitor {
472-
uses: Vec::new(),
473-
target: id,
474-
seen_other: false,
475-
cx,
476-
current_mutably_captured_ids: HirIdSet::default(),
477472
illegal_mutable_capture_ids: captured_ids,
473+
current_mutably_captured_ids: HirIdSet::default(),
474+
cx,
475+
uses: Vec::new(),
478476
hir_id_uses_map: FxHashMap::default(),
479477
current_statement_hir_id: None,
478+
seen_other: false,
479+
target: id,
480480
};
481481
visitor.visit_block(block);
482482
if visitor.seen_other {

clippy_lints/src/methods/str_splitn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,8 @@ fn parse_iter_usage<'tcx>(
293293
{
294294
Some(IterUsage {
295295
kind: IterUsageKind::NextTuple,
296-
span: e.span,
297296
unwrap_kind: None,
297+
span: e.span,
298298
})
299299
} else {
300300
None

clippy_lints/src/methods/unnecessary_fold.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,30 +124,30 @@ pub(super) fn check(
124124
match lit.node {
125125
ast::LitKind::Bool(false) => {
126126
check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Or, Replacement {
127+
method_name: "any",
127128
has_args: true,
128129
has_generic_return: false,
129-
method_name: "any",
130130
});
131131
},
132132
ast::LitKind::Bool(true) => {
133133
check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::And, Replacement {
134+
method_name: "all",
134135
has_args: true,
135136
has_generic_return: false,
136-
method_name: "all",
137137
});
138138
},
139139
ast::LitKind::Int(Pu128(0), _) => {
140140
check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Add, Replacement {
141+
method_name: "sum",
141142
has_args: false,
142143
has_generic_return: needs_turbofish(cx, expr),
143-
method_name: "sum",
144144
});
145145
},
146146
ast::LitKind::Int(Pu128(1), _) => {
147147
check_fold_with_op(cx, expr, acc, fold_span, hir::BinOpKind::Mul, Replacement {
148+
method_name: "product",
148149
has_args: false,
149150
has_generic_return: needs_turbofish(cx, expr),
150-
method_name: "product",
151151
});
152152
},
153153
_ => (),

clippy_lints/src/needless_continue.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,11 @@ fn check_and_warn(cx: &EarlyContext<'_>, expr: &ast::Expr) {
349349
for (i, stmt) in loop_block.stmts.iter().enumerate() {
350350
with_if_expr(stmt, |if_expr, cond, then_block, else_expr| {
351351
let data = &LintData {
352-
stmt_idx: i,
353352
if_expr,
354353
if_cond: cond,
355354
if_block: then_block,
356355
else_expr,
356+
stmt_idx: i,
357357
loop_block,
358358
};
359359
if needless_continue_in_else(else_expr, label) {

clippy_lints/src/non_expressive_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,10 +270,10 @@ impl SimilarNamesNameVisitor<'_, '_, '_> {
270270
return;
271271
}
272272
self.0.names.push(ExistingName {
273-
exemptions: get_exemptions(interned_name).unwrap_or(&[]),
274273
interned: ident.name,
275274
span: ident.span,
276275
len: count,
276+
exemptions: get_exemptions(interned_name).unwrap_or(&[]),
277277
});
278278
}
279279

clippy_lints/src/operators/arithmetic_side_effects.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ impl ArithmeticSideEffects {
4747
Self {
4848
allowed_binary,
4949
allowed_unary,
50+
const_span: None,
5051
disallowed_int_methods: [
5152
sym::saturating_div,
5253
sym::wrapping_div,
@@ -55,7 +56,6 @@ impl ArithmeticSideEffects {
5556
]
5657
.into_iter()
5758
.collect(),
58-
const_span: None,
5959
expr_span: None,
6060
}
6161
}

clippy_lints/src/pathbuf_init_then_push.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,11 +143,11 @@ impl<'tcx> LateLintPass<'tcx> for PathbufThenPush<'tcx> {
143143
self.searcher = Some(PathbufPushSearcher {
144144
local_id: id,
145145
lhs_is_let: true,
146-
name: name.name,
147146
let_ty_span: local.ty.map(|ty| ty.span),
148-
err_span: local.span,
149147
init_val: *init_expr,
150148
arg: None,
149+
name: name.name,
150+
err_span: local.span,
151151
});
152152
}
153153
}
@@ -165,10 +165,10 @@ impl<'tcx> LateLintPass<'tcx> for PathbufThenPush<'tcx> {
165165
local_id: id,
166166
lhs_is_let: false,
167167
let_ty_span: None,
168-
name: name.ident.name,
169-
err_span: expr.span,
170168
init_val: *right,
171169
arg: None,
170+
name: name.ident.name,
171+
err_span: expr.span,
172172
});
173173
}
174174
}

clippy_lints/src/significant_drop_tightening.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ impl<'tcx> Visitor<'tcx> for StmtsChecker<'_, '_, '_, '_, 'tcx> {
288288
}
289289
{
290290
let mut apa = AuxParamsAttr {
291-
first_bind_ident: ident,
292291
first_block_hir_id: self.ap.curr_block_hir_id,
293292
first_block_span: self.ap.curr_block_span,
293+
first_bind_ident: ident,
294294
first_method_span: {
295295
let expr_or_init = expr_or_init(self.cx, expr);
296296
if let hir::ExprKind::MethodCall(_, local_expr, _, span) = expr_or_init.kind {
@@ -401,8 +401,8 @@ impl Default for AuxParamsAttr {
401401
counter: 0,
402402
has_expensive_expr_after_last_attr: false,
403403
first_block_hir_id: HirId::INVALID,
404-
first_bind_ident: Ident::empty(),
405404
first_block_span: DUMMY_SP,
405+
first_bind_ident: Ident::empty(),
406406
first_method_span: DUMMY_SP,
407407
first_stmt_span: DUMMY_SP,
408408
last_bind_ident: Ident::empty(),

clippy_lints/src/swap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,9 +384,9 @@ impl<'tcx> IndexBinding<'_, 'tcx> {
384384

385385
fn is_used_after_swap(&mut self, idx_ident: Ident) -> bool {
386386
let mut v = IndexBindingVisitor {
387-
found_used: false,
388-
suggest_span: self.suggest_span,
389387
idx: idx_ident,
388+
suggest_span: self.suggest_span,
389+
found_used: false,
390390
};
391391

392392
for stmt in self.block.stmts {

clippy_lints/src/types/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,8 +388,8 @@ impl<'tcx> LateLintPass<'tcx> for Types {
388388

389389
self.check_fn_decl(cx, decl, CheckTyContext {
390390
is_in_trait_impl,
391-
is_exported,
392391
in_body: matches!(fn_kind, FnKind::Closure),
392+
is_exported,
393393
..CheckTyContext::default()
394394
});
395395
}

clippy_lints/src/unused_async.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,18 @@ impl<'tcx> LateLintPass<'tcx> for UnusedAsync {
120120
let mut visitor = AsyncFnVisitor {
121121
cx,
122122
found_await: false,
123-
async_depth: 0,
124123
await_in_async_block: None,
124+
async_depth: 0,
125125
};
126126
walk_fn(&mut visitor, fn_kind, fn_decl, body.id(), def_id);
127127
if !visitor.found_await {
128128
// Don't lint just yet, but store the necessary information for later.
129129
// The actual linting happens in `check_crate_post`, once we've found all
130130
// uses of local async functions that do require asyncness to pass typeck
131131
self.unused_async_fns.push(UnusedAsyncFn {
132-
await_in_async_block: visitor.await_in_async_block,
133-
fn_span: span,
134132
def_id,
133+
fn_span: span,
134+
await_in_async_block: visitor.await_in_async_block,
135135
});
136136
}
137137
}

clippy_lints/src/unwrap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,9 @@ impl<'tcx> UnwrappableVariablesVisitor<'_, 'tcx> {
245245
let prev_len = self.unwrappables.len();
246246
for unwrap_info in collect_unwrap_info(self.cx, if_expr, cond, branch, else_branch, true) {
247247
let mut delegate = MutationVisitor {
248-
tcx: self.cx.tcx,
249248
is_mutated: false,
250249
local_id: unwrap_info.local_id,
250+
tcx: self.cx.tcx,
251251
};
252252

253253
let vis = ExprUseVisitor::for_clippy(self.cx, cond.hir_id.owner.def_id, &mut delegate);
@@ -397,8 +397,8 @@ impl<'tcx> LateLintPass<'tcx> for Unwrap {
397397
}
398398

399399
let mut v = UnwrappableVariablesVisitor {
400-
cx,
401400
unwrappables: Vec::new(),
401+
cx,
402402
};
403403

404404
walk_fn(&mut v, kind, decl, body.id(), fn_id);

clippy_lints/src/vec_init_then_push.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ impl<'tcx> LateLintPass<'tcx> for VecInitThenPush {
166166
local_id: id,
167167
init,
168168
lhs_is_let: true,
169-
name: name.name,
170169
let_ty_span: local.ty.map(|ty| ty.span),
170+
name: name.name,
171171
err_span: local.span,
172172
found: 0,
173173
last_push_expr: init_expr.hir_id,
@@ -206,8 +206,8 @@ impl<'tcx> LateLintPass<'tcx> for VecInitThenPush {
206206
&& name.ident.as_str() == "push"
207207
{
208208
self.searcher = Some(VecPushSearcher {
209-
found: searcher.found + 1,
210209
err_span: searcher.err_span.to(stmt.span),
210+
found: searcher.found + 1,
211211
last_push_expr: expr.hir_id,
212212
..searcher
213213
});

clippy_lints/src/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,8 @@ impl Write {
248248
pub fn new(conf: &'static Conf, format_args: FormatArgsStorage) -> Self {
249249
Self {
250250
format_args,
251-
allow_print_in_tests: conf.allow_print_in_tests,
252251
in_debug_impl: false,
252+
allow_print_in_tests: conf.allow_print_in_tests,
253253
}
254254
}
255255
}

clippy_lints/src/zombie_processes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,8 @@ fn check<'tcx>(cx: &LateContext<'tcx>, spawn_expr: &'tcx Expr<'tcx>, emit_sugges
226226
};
227227

228228
let mut vis = ExitPointFinder {
229-
cx,
230229
state: ExitPointState::WalkUpTo(spawn_expr.hir_id),
230+
cx,
231231
};
232232
if let Break(ExitCallFound) = vis.visit_block(block) {
233233
// Visitor found an unconditional `exit()` call, so don't lint.

clippy_utils/src/higher.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,8 @@ impl<'hir> IfOrIfLet<'hir> {
196196
if let ExprKind::DropTemps(new_cond) = cond.kind {
197197
return Some(Self {
198198
cond: new_cond,
199-
r#else,
200199
then,
200+
r#else,
201201
});
202202
}
203203
if let ExprKind::Let(..) = cond.kind {

clippy_utils/src/hir_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,8 +780,8 @@ impl<'a, 'tcx> SpanlessHash<'a, 'tcx> {
780780
Self {
781781
cx,
782782
maybe_typeck_results: cx.maybe_typeck_results(),
783-
path_check: PathCheck::default(),
784783
s: FxHasher::default(),
784+
path_check: PathCheck::default(),
785785
}
786786
}
787787

0 commit comments

Comments
 (0)