Skip to content

Commit 29a7057

Browse files
committed
Fix adjacent code
1 parent add771f commit 29a7057

40 files changed

+78
-78
lines changed

clippy_dev/src/bless.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn update_reference_file(test_output_entry: &DirEntry, ignore_timestamp: bool) {
4343
if test_output_file != reference_file {
4444
// If a test run caused an output file to change, update the reference file
4545
println!("updating {}", reference_file_path.display());
46-
fs::copy(test_output_path, &reference_file_path).expect("Could not update reference file");
46+
fs::copy(test_output_path, reference_file_path).expect("Could not update reference file");
4747
}
4848
}
4949

clippy_dev/src/fmt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ fn exec(
169169
if !context.check && !success {
170170
let stderr = std::str::from_utf8(&output.stderr).unwrap_or("");
171171
return Err(CliError::CommandFailed(
172-
format_command(&program, &dir, args),
172+
format_command(program, dir, args),
173173
String::from(stderr),
174174
));
175175
}
@@ -207,7 +207,7 @@ fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> {
207207
Err(CliError::RustfmtNotInstalled)
208208
} else {
209209
Err(CliError::CommandFailed(
210-
format_command(program, &dir, args),
210+
format_command(program, dir, args),
211211
std::str::from_utf8(&output.stderr).unwrap_or("").to_string(),
212212
))
213213
}

clippy_dev/src/new_lint.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ fn create_test(lint: &LintData<'_>) -> io::Result<()> {
9898
fs::create_dir(&test_dir)?;
9999

100100
create_project_layout(lint.name, &test_dir, "fail", "Content that triggers the lint goes here")?;
101-
create_project_layout(lint.name, &test_dir, "pass", "This file should not trigger the lint")?;
101+
create_project_layout(lint.name, test_dir, "pass", "This file should not trigger the lint")?;
102102

103103
println!("Generated test directories: `{relative_test_dir}/pass`, `{relative_test_dir}/fail`");
104104
} else {

clippy_dev/src/serve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ fn mtime(path: impl AsRef<Path>) -> SystemTime {
4949
.into_iter()
5050
.flatten()
5151
.flatten()
52-
.map(|entry| mtime(&entry.path()))
52+
.map(|entry| mtime(entry.path()))
5353
.max()
5454
.unwrap_or(SystemTime::UNIX_EPOCH)
5555
} else {

clippy_lints/src/casts/cast_slice_different_sizes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ pub(super) fn check<'tcx>(cx: &LateContext<'tcx>, expr: &Expr<'tcx>, msrv: Optio
5454

5555
diag.span_suggestion(
5656
expr.span,
57-
&format!("replace with `ptr::slice_from_raw_parts{mutbl_fn_str}`"),
57+
format!("replace with `ptr::slice_from_raw_parts{mutbl_fn_str}`"),
5858
sugg,
5959
rustc_errors::Applicability::HasPlaceholders,
6060
);

clippy_lints/src/disallowed_methods.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl<'tcx> LateLintPass<'tcx> for DisallowedMethods {
106106
reason: Some(reason), ..
107107
} = conf
108108
{
109-
diag.note(&format!("{} (from clippy.toml)", reason));
109+
diag.note(format!("{} (from clippy.toml)", reason));
110110
}
111111
});
112112
}

clippy_lints/src/format_args.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ fn check_format_in_format_args(cx: &LateContext<'_>, call_site: Span, name: Symb
114114
call_site,
115115
&format!("`format!` in `{}!` args", name),
116116
|diag| {
117-
diag.help(&format!(
117+
diag.help(format!(
118118
"combine the `format!(..)` arguments with the outer `{}!(..)` call",
119119
name
120120
));

clippy_lints/src/large_enum_variant.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ impl<'tcx> LateLintPass<'tcx> for LargeEnumVariant {
134134
|diag| {
135135
diag.span_label(
136136
def.variants[variants_size[0].ind].span,
137-
&format!("this variant is {} bytes", variants_size[0].size),
137+
format!("this variant is {} bytes", variants_size[0].size),
138138
);
139139
diag.span_note(
140140
def.variants[variants_size[1].ind].span,
141-
&format!("and the second-largest variant is {} bytes:", variants_size[1].size),
141+
format!("and the second-largest variant is {} bytes:", variants_size[1].size),
142142
);
143143

144144
let fields = def.variants[variants_size[0].ind].data.fields();

clippy_lints/src/len_zero.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ fn check_for_is_empty<'tcx>(
364364
db.span_note(span, "`is_empty` defined here");
365365
}
366366
if let Some(self_kind) = self_kind {
367-
db.note(&output.expected_sig(self_kind));
367+
db.note(output.expected_sig(self_kind));
368368
}
369369
});
370370
}

clippy_lints/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ pub fn register_pre_expansion_lints(store: &mut rustc_lint::LintStore, sess: &Se
414414

415415
let msrv = conf.msrv.as_ref().and_then(|s| {
416416
parse_msrv(s, None, None).or_else(|| {
417-
sess.err(&format!(
417+
sess.err(format!(
418418
"error reading Clippy's configuration file. `{}` is not a valid Rust version",
419419
s
420420
));
@@ -432,7 +432,7 @@ fn read_msrv(conf: &Conf, sess: &Session) -> Option<RustcVersion> {
432432
.and_then(|v| parse_msrv(&v, None, None));
433433
let clippy_msrv = conf.msrv.as_ref().and_then(|s| {
434434
parse_msrv(s, None, None).or_else(|| {
435-
sess.err(&format!(
435+
sess.err(format!(
436436
"error reading Clippy's configuration file. `{}` is not a valid Rust version",
437437
s
438438
));
@@ -444,7 +444,7 @@ fn read_msrv(conf: &Conf, sess: &Session) -> Option<RustcVersion> {
444444
if let Some(clippy_msrv) = clippy_msrv {
445445
// if both files have an msrv, let's compare them and emit a warning if they differ
446446
if clippy_msrv != cargo_msrv {
447-
sess.warn(&format!(
447+
sess.warn(format!(
448448
"the MSRV in `clippy.toml` and `Cargo.toml` differ; using `{}` from `clippy.toml`",
449449
clippy_msrv
450450
));
@@ -465,7 +465,7 @@ pub fn read_conf(sess: &Session) -> Conf {
465465
Ok(Some(path)) => path,
466466
Ok(None) => return Conf::default(),
467467
Err(error) => {
468-
sess.struct_err(&format!("error finding Clippy's configuration file: {}", error))
468+
sess.struct_err(format!("error finding Clippy's configuration file: {}", error))
469469
.emit();
470470
return Conf::default();
471471
},

clippy_lints/src/loops/explicit_counter_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub(super) fn check<'tcx>(
8080
applicability,
8181
);
8282

83-
diag.note(&format!(
83+
diag.note(format!(
8484
"`{}` is of type `{}`, making it ineligible for `Iterator::enumerate`",
8585
name, int_name
8686
));

clippy_lints/src/manual_async_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualAsyncFn {
7777
let help = format!("make the function `async` and {}", ret_sugg);
7878
diag.span_suggestion(
7979
header_span,
80-
&help,
80+
help,
8181
format!("async {}{}", &header_snip[..ret_pos], ret_snip),
8282
Applicability::MachineApplicable
8383
);

clippy_lints/src/manual_strip.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl<'tcx> LateLintPass<'tcx> for ManualStrip {
109109

110110
let test_span = expr.span.until(then.span);
111111
span_lint_and_then(cx, MANUAL_STRIP, strippings[0], &format!("stripping a {} manually", kind_word), |diag| {
112-
diag.span_note(test_span, &format!("the {} was tested here", kind_word));
112+
diag.span_note(test_span, format!("the {} was tested here", kind_word));
113113
multispan_sugg(
114114
diag,
115115
&format!("try using the `strip_{}` method", kind_word),

clippy_lints/src/methods/inefficient_to_string.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn check<'tcx>(cx: &LateContext<'tcx>, expr: &hir::Expr<'_>, method_name: Sy
3030
expr.span,
3131
&format!("calling `to_string` on `{}`", arg_ty),
3232
|diag| {
33-
diag.help(&format!(
33+
diag.help(format!(
3434
"`{}` implements `ToString` through a slower blanket impl, but `{}` has a fast specialization of `ToString`",
3535
self_ty, deref_self_ty
3636
));

clippy_lints/src/methods/iter_skip_next.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub(super) fn check(cx: &LateContext<'_>, expr: &hir::Expr<'_>, recv: &hir::Expr
2929
application = Applicability::Unspecified;
3030
diag.span_help(
3131
pat.span,
32-
&format!("for this change `{}` has to be mutable", snippet(cx, pat.span, "..")),
32+
format!("for this change `{}` has to be mutable", snippet(cx, pat.span, "..")),
3333
);
3434
}
3535
}

clippy_lints/src/methods/option_map_unwrap_or.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ pub(super) fn check<'tcx>(
8585
suggestion.push((map_arg_span.with_hi(map_arg_span.lo()), format!("{}, ", unwrap_snippet)));
8686
}
8787

88-
diag.multipart_suggestion(&format!("use `{}` instead", suggest), suggestion, applicability);
88+
diag.multipart_suggestion(format!("use `{}` instead", suggest), suggestion, applicability);
8989
});
9090
}
9191
}

clippy_lints/src/methods/str_splitn.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ fn check_manual_split_once_indirect(
167167
};
168168
diag.span_suggestion_verbose(
169169
local.span,
170-
&format!("try `{r}split_once`"),
170+
format!("try `{r}split_once`"),
171171
format!("let ({lhs}, {rhs}) = {self_snip}.{r}split_once({pat_snip}){unwrap};"),
172172
app,
173173
);
@@ -181,7 +181,7 @@ fn check_manual_split_once_indirect(
181181
);
182182
diag.span_suggestion(
183183
second.span,
184-
&remove_msg,
184+
remove_msg,
185185
"",
186186
app,
187187
);

clippy_lints/src/methods/unnecessary_lazy_eval.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ pub(super) fn check<'tcx>(
5858
span_lint_and_then(cx, UNNECESSARY_LAZY_EVALUATIONS, expr.span, msg, |diag| {
5959
diag.span_suggestion(
6060
span,
61-
&format!("use `{}(..)` instead", simplify_using),
61+
format!("use `{}(..)` instead", simplify_using),
6262
format!("{}({})", simplify_using, snippet(cx, body_expr.span, "..")),
6363
applicability,
6464
);

clippy_lints/src/module_style.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ impl EarlyLintPass for ModStyle {
119119
Span::new(file.start_pos, file.start_pos, SyntaxContext::root(), None),
120120
|build| {
121121
let mut lint =
122-
build.build(&format!("`mod.rs` files are required, found `{}`", path.display()));
123-
lint.help(&format!("move `{}` to `{}`", path.display(), correct.display(),));
122+
build.build(format!("`mod.rs` files are required, found `{}`", path.display()));
123+
lint.help(format!("move `{}` to `{}`", path.display(), correct.display(),));
124124
lint.emit();
125125
},
126126
);
@@ -157,8 +157,8 @@ fn check_self_named_mod_exists(cx: &EarlyContext<'_>, path: &Path, file: &Source
157157
MOD_MODULE_FILES,
158158
Span::new(file.start_pos, file.start_pos, SyntaxContext::root(), None),
159159
|build| {
160-
let mut lint = build.build(&format!("`mod.rs` files are not allowed, found `{}`", path.display()));
161-
lint.help(&format!("move `{}` to `{}`", path.display(), mod_file.display(),));
160+
let mut lint = build.build(format!("`mod.rs` files are not allowed, found `{}`", path.display()));
161+
lint.help(format!("move `{}` to `{}`", path.display(), mod_file.display(),));
162162
lint.emit();
163163
},
164164
);

clippy_lints/src/needless_late_init.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ fn check<'tcx>(
287287

288288
diag.span_suggestion(
289289
assign.lhs_span,
290-
&format!("declare `{}` here", binding_name),
290+
format!("declare `{}` here", binding_name),
291291
let_snippet,
292292
Applicability::MachineApplicable,
293293
);
@@ -307,7 +307,7 @@ fn check<'tcx>(
307307

308308
diag.span_suggestion_verbose(
309309
usage.stmt.span.shrink_to_lo(),
310-
&format!("declare `{}` here", binding_name),
310+
format!("declare `{}` here", binding_name),
311311
format!("{} = ", let_snippet),
312312
applicability,
313313
);
@@ -338,7 +338,7 @@ fn check<'tcx>(
338338

339339
diag.span_suggestion_verbose(
340340
usage.stmt.span.shrink_to_lo(),
341-
&format!("declare `{}` here", binding_name),
341+
format!("declare `{}` here", binding_name),
342342
format!("{} = ", let_snippet),
343343
applicability,
344344
);

clippy_lints/src/nonstandard_macro_braces.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ impl<'de> Deserialize<'de> for MacroMatcher {
270270
.find(|b| b.0 == brace)
271271
.map(|(o, c)| ((*o).to_owned(), (*c).to_owned()))
272272
.ok_or_else(|| {
273-
de::Error::custom(&format!("expected one of `(`, `{{`, `[` found `{}`", brace))
273+
de::Error::custom(format!("expected one of `(`, `{{`, `[` found `{}`", brace))
274274
})?,
275275
})
276276
}

clippy_lints/src/octal_escapes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ fn check_lit(cx: &EarlyContext<'_>, lit: &Lit, span: Span, is_string: bool) {
125125
if is_string { "string" } else { "byte string" }
126126
),
127127
|diag| {
128-
diag.help(&format!(
128+
diag.help(format!(
129129
"octal escapes are not supported, `\\0` is always a null {}",
130130
if is_string { "character" } else { "byte" }
131131
));
@@ -139,7 +139,7 @@ fn check_lit(cx: &EarlyContext<'_>, lit: &Lit, span: Span, is_string: bool) {
139139
// suggestion 2: unambiguous null byte
140140
diag.span_suggestion(
141141
span,
142-
&format!(
142+
format!(
143143
"if the null {} is intended, disambiguate using",
144144
if is_string { "character" } else { "byte" }
145145
),

clippy_lints/src/operators/misrefactored_assign_op.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn lint_misrefactored_assign_op(
5050
let long = format!("{} = {}", snip_a, sugg::make_binop(op.into(), a, r));
5151
diag.span_suggestion(
5252
expr.span,
53-
&format!(
53+
format!(
5454
"did you mean `{} = {} {} {}` or `{}`? Consider replacing it with",
5555
snip_a,
5656
snip_a,

clippy_lints/src/same_name_method.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
108108
|diag| {
109109
diag.span_note(
110110
trait_method_span,
111-
&format!("existing `{}` defined here", method_name),
111+
format!("existing `{}` defined here", method_name),
112112
);
113113
},
114114
);
@@ -151,7 +151,7 @@ impl<'tcx> LateLintPass<'tcx> for SameNameMethod {
151151
// iterate on trait_spans?
152152
diag.span_note(
153153
trait_spans[0],
154-
&format!("existing `{}` defined here", method_name),
154+
format!("existing `{}` defined here", method_name),
155155
);
156156
},
157157
);

clippy_lints/src/swap.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ fn generate_swap_warning(cx: &LateContext<'_>, e1: &Expr<'_>, e2: &Expr<'_>, spa
130130
applicability,
131131
);
132132
if !is_xor_based {
133-
diag.note(&format!("or maybe you should use `{}::mem::replace`?", sugg));
133+
diag.note(format!("or maybe you should use `{}::mem::replace`?", sugg));
134134
}
135135
},
136136
);
@@ -211,7 +211,7 @@ fn check_suspicious_swap(cx: &LateContext<'_>, block: &Block<'_>) {
211211
Applicability::MaybeIncorrect,
212212
);
213213
diag.note(
214-
&format!("or maybe you should use `{}::mem::replace`?", sugg)
214+
format!("or maybe you should use `{}::mem::replace`?", sugg)
215215
);
216216
}
217217
});

clippy_lints/src/transmute/transmute_undefined_repr.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub(super) fn check<'tcx>(
7878
&format!("transmute from `{}` which has an undefined layout", from_ty_orig),
7979
|diag| {
8080
if from_ty_orig.peel_refs() != from_ty.peel_refs() {
81-
diag.note(&format!("the contained type `{}` has an undefined layout", from_ty));
81+
diag.note(format!("the contained type `{}` has an undefined layout", from_ty));
8282
}
8383
},
8484
);
@@ -92,7 +92,7 @@ pub(super) fn check<'tcx>(
9292
&format!("transmute to `{}` which has an undefined layout", to_ty_orig),
9393
|diag| {
9494
if to_ty_orig.peel_refs() != to_ty.peel_refs() {
95-
diag.note(&format!("the contained type `{}` has an undefined layout", to_ty));
95+
diag.note(format!("the contained type `{}` has an undefined layout", to_ty));
9696
}
9797
},
9898
);
@@ -121,16 +121,16 @@ pub(super) fn check<'tcx>(
121121
),
122122
|diag| {
123123
if let Some(same_adt_did) = same_adt_did {
124-
diag.note(&format!(
124+
diag.note(format!(
125125
"two instances of the same generic type (`{}`) may have different layouts",
126126
cx.tcx.item_name(same_adt_did)
127127
));
128128
} else {
129129
if from_ty_orig.peel_refs() != from_ty {
130-
diag.note(&format!("the contained type `{}` has an undefined layout", from_ty));
130+
diag.note(format!("the contained type `{}` has an undefined layout", from_ty));
131131
}
132132
if to_ty_orig.peel_refs() != to_ty {
133-
diag.note(&format!("the contained type `{}` has an undefined layout", to_ty));
133+
diag.note(format!("the contained type `{}` has an undefined layout", to_ty));
134134
}
135135
}
136136
},
@@ -148,7 +148,7 @@ pub(super) fn check<'tcx>(
148148
&format!("transmute from `{}` which has an undefined layout", from_ty_orig),
149149
|diag| {
150150
if from_ty_orig.peel_refs() != from_ty {
151-
diag.note(&format!("the contained type `{}` has an undefined layout", from_ty));
151+
diag.note(format!("the contained type `{}` has an undefined layout", from_ty));
152152
}
153153
},
154154
);
@@ -165,7 +165,7 @@ pub(super) fn check<'tcx>(
165165
&format!("transmute into `{}` which has an undefined layout", to_ty_orig),
166166
|diag| {
167167
if to_ty_orig.peel_refs() != to_ty {
168-
diag.note(&format!("the contained type `{}` has an undefined layout", to_ty));
168+
diag.note(format!("the contained type `{}` has an undefined layout", to_ty));
169169
}
170170
},
171171
);

0 commit comments

Comments
 (0)