Skip to content

Commit 3500a56

Browse files
committed
Fix adjacent code
1 parent 3b1f8b1 commit 3500a56

File tree

12 files changed

+19
-27
lines changed

12 files changed

+19
-27
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ pub fn try_rename_dir(old_name: &Path, new_name: &Path) -> bool {
633633

634634
#[track_caller]
635635
pub fn run_exit_on_err(path: &(impl AsRef<Path> + ?Sized), cmd: &mut Command) {
636-
match expect_action(cmd.status(), ErrAction::Run, path.as_ref()).code() {
636+
match expect_action(cmd.status(), ErrAction::Run, path).code() {
637637
Some(0) => {},
638638
Some(n) => process::exit(n),
639639
None => {
@@ -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
@@ -396,13 +396,9 @@ impl<'a> PatState<'a> {
396396
PatKind::Tuple(pats, _) => self.add_product_pat(cx, pats),
397397
PatKind::Slice(head, _, tail) => self.add_product_pat(cx, head.iter().chain(tail)),
398398

399-
PatKind::TupleStruct(ref path, pats, _) => self.add_struct_pats(
400-
cx,
401-
pat,
402-
path,
403-
if let [pat] = pats { Some(pat) } else { None },
404-
pats.iter(),
405-
),
399+
PatKind::TupleStruct(ref path, pats, _) => {
400+
self.add_struct_pats(cx, pat, path, if let [pat] = pats { Some(pat) } else { None }, pats)
401+
},
406402
PatKind::Struct(ref path, pats, _) => self.add_struct_pats(
407403
cx,
408404
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
@@ -180,9 +180,9 @@ fn used_underscore_items<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
180180
cx,
181181
USED_UNDERSCORE_ITEMS,
182182
expr.span,
183-
"used underscore-prefixed item".to_string(),
183+
"used underscore-prefixed item",
184184
|diag| {
185-
diag.span_note(definition_span, "item is defined here".to_string());
185+
diag.span_note(definition_span, "item is defined here");
186186
},
187187
);
188188
}
@@ -225,9 +225,9 @@ fn used_underscore_binding<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
225225
cx,
226226
USED_UNDERSCORE_BINDING,
227227
expr.span,
228-
"used underscore-prefixed binding".to_string(),
228+
"used underscore-prefixed binding",
229229
|diag| {
230-
diag.span_note(definition_span, "binding is defined here".to_string());
230+
diag.span_note(definition_span, "binding is defined here");
231231
},
232232
);
233233
}

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
@@ -62,12 +62,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantPubCrate {
6262
span,
6363
format!("pub(crate) {descr} inside private module"),
6464
|diag| {
65-
diag.span_suggestion(
66-
item.vis_span,
67-
"consider using",
68-
"pub".to_string(),
69-
Applicability::MachineApplicable,
70-
);
65+
diag.span_suggestion(item.vis_span, "consider using", "pub", Applicability::MachineApplicable);
7166
},
7267
);
7368
}

0 commit comments

Comments
 (0)