Skip to content

Commit ac3f154

Browse files
committed
Fix adjacent code
1 parent b18d422 commit ac3f154

File tree

12 files changed

+18
-26
lines changed

12 files changed

+18
-26
lines changed

clippy_dev/src/new_lint.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ fn create_lint(lint: &LintData<'_>, enable_msrv: bool) -> io::Result<()> {
9595
} else {
9696
let lint_contents = get_lint_file_contents(lint, enable_msrv);
9797
let lint_path = format!("clippy_lints/src/{}.rs", lint.name);
98-
write_file(&lint_path, lint_contents.as_bytes())?;
98+
write_file(&lint_path, &lint_contents)?;
9999
println!("Generated lint file: `{lint_path}`");
100100

101101
Ok(())
@@ -433,7 +433,7 @@ fn create_lint_for_ty(lint: &LintData<'_>, enable_msrv: bool, ty: &str) -> io::R
433433
);
434434
}
435435

436-
write_file(lint_file_path.as_path(), lint_file_contents)?;
436+
write_file(&lint_file_path, lint_file_contents)?;
437437
println!("Generated lint file: `clippy_lints/src/{ty}/{}.rs`", lint.name);
438438
println!(
439439
"Be sure to add a call to `{}::check` in `clippy_lints/src/{ty}/mod.rs`!",

clippy_dev/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ pub fn split_args_for_threads(
693693
let mut cmd = (self.make_cmd)();
694694
let mut cmd_len = 0usize;
695695
for arg in self.args.by_ref().take(self.batch_size) {
696-
cmd.arg(arg.as_ref());
696+
cmd.arg(&arg);
697697
// `+ 8` to account for the `argv` pointer on unix.
698698
// Windows is complicated since the arguments are first converted to UTF-16ish,
699699
// but this needs to account for the space between arguments and whatever additional

clippy_lints/src/almost_complete_range.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl EarlyLintPass for AlmostCompleteRange {
6060
diag.span_suggestion(
6161
trim_span(cx.sess().source_map(), start.between(end)),
6262
"use an inclusive range",
63-
"..=".to_owned(),
63+
"..=",
6464
Applicability::MaybeIncorrect,
6565
);
6666
}

clippy_lints/src/matches/single_match.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,13 +395,9 @@ impl<'a> PatState<'a> {
395395
PatKind::Tuple(pats, _) => self.add_product_pat(cx, pats),
396396
PatKind::Slice(head, _, tail) => self.add_product_pat(cx, head.iter().chain(tail)),
397397

398-
PatKind::TupleStruct(ref path, pats, _) => self.add_struct_pats(
399-
cx,
400-
pat,
401-
path,
402-
if let [pat] = pats { Some(pat) } else { None },
403-
pats.iter(),
404-
),
398+
PatKind::TupleStruct(ref path, pats, _) => {
399+
self.add_struct_pats(cx, pat, path, if let [pat] = pats { Some(pat) } else { None }, pats)
400+
},
405401
PatKind::Struct(ref path, pats, _) => self.add_struct_pats(
406402
cx,
407403
pat,

clippy_lints/src/methods/open_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ fn check_open_options(cx: &LateContext<'_>, settings: &[(OpenOption, Argument, S
189189
diag.span_suggestion(
190190
create_span.shrink_to_hi(),
191191
"add",
192-
".truncate(true)".to_string(),
192+
".truncate(true)",
193193
rustc_errors::Applicability::MaybeIncorrect,
194194
)
195195
.help("if you intend to overwrite an existing file entirely, call `.truncate(true)`")

clippy_lints/src/methods/vec_resize_to_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub(super) fn check<'tcx>(
3939
db.span_suggestion(
4040
method_call_span,
4141
"...or you can empty the vector with",
42-
"clear()".to_string(),
42+
"clear()",
4343
Applicability::MaybeIncorrect,
4444
);
4545
},

clippy_lints/src/misc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ fn used_underscore_items<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
292292
cx,
293293
USED_UNDERSCORE_ITEMS,
294294
expr.span,
295-
"used underscore-prefixed item".to_string(),
295+
"used underscore-prefixed item",
296296
|diag| {
297-
diag.span_note(definition_span, "item is defined here".to_string());
297+
diag.span_note(definition_span, "item is defined here");
298298
},
299299
);
300300
}
@@ -337,9 +337,9 @@ fn used_underscore_binding<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
337337
cx,
338338
USED_UNDERSCORE_BINDING,
339339
expr.span,
340-
"used underscore-prefixed binding".to_string(),
340+
"used underscore-prefixed binding",
341341
|diag| {
342-
diag.span_note(definition_span, "binding is defined here".to_string());
342+
diag.span_note(definition_span, "binding is defined here");
343343
},
344344
);
345345
}

clippy_lints/src/misc_early/zero_prefixed_literal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pub(super) fn check(cx: &EarlyContext<'_>, lit_span: Span, lit_snip: &str) {
1616
diag.span_suggestion(
1717
lit_span,
1818
"if you mean to use a decimal constant, remove the `0` to avoid confusion",
19-
trimmed_lit_snip.to_string(),
19+
trimmed_lit_snip,
2020
Applicability::MaybeIncorrect,
2121
);
2222
// do not advise to use octal form if the literal cannot be expressed in base 8.

clippy_lints/src/needless_pass_by_ref_mut.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
279279
|diag| {
280280
diag.span_suggestion(
281281
sp,
282-
"consider changing to".to_string(),
282+
"consider changing to",
283283
format!("&{}", snippet(cx, cx.tcx.hir_span(inner_ty.ty.hir_id), "_"),),
284284
Applicability::Unspecified,
285285
);

clippy_lints/src/redundant_pub_crate.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
6363
span,
6464
format!("pub(crate) {descr} inside private module"),
6565
|diag| {
66-
diag.span_suggestion(
67-
item.vis_span,
68-
"consider using",
69-
"pub".to_string(),
70-
Applicability::MachineApplicable,
71-
);
66+
diag.span_suggestion(item.vis_span, "consider using", "pub", Applicability::MachineApplicable);
7267
},
7368
);
7469
}

0 commit comments

Comments
 (0)