Skip to content

Commit 9cc8da2

Browse files
committed
Fix adjacent code
1 parent 037f698 commit 9cc8da2

File tree

9 files changed

+24
-28
lines changed

9 files changed

+24
-28
lines changed

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_dev/src/update_lints.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn generate_lint_files(
128128
for (lint_group, lints) in Lint::by_lint_group(usable_lints.into_iter().chain(internal_lints)) {
129129
let content = gen_lint_group_list(&lint_group, lints.iter());
130130
process_file(
131-
&format!("clippy_lints/src/lib.register_{lint_group}.rs"),
131+
format!("clippy_lints/src/lib.register_{lint_group}.rs"),
132132
update_mode,
133133
&content,
134134
);

clippy_lints/src/lib.rs

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

418418
let msrv = conf.msrv.as_ref().and_then(|s| {
419419
parse_msrv(s, None, None).or_else(|| {
420-
sess.err(&format!(
420+
sess.err(format!(
421421
"error reading Clippy's configuration file. `{s}` is not a valid Rust version"
422422
));
423423
None
@@ -433,7 +433,7 @@ fn read_msrv(conf: &Conf, sess: &Session) -> Option<RustcVersion> {
433433
.and_then(|v| parse_msrv(&v, None, None));
434434
let clippy_msrv = conf.msrv.as_ref().and_then(|s| {
435435
parse_msrv(s, None, None).or_else(|| {
436-
sess.err(&format!(
436+
sess.err(format!(
437437
"error reading Clippy's configuration file. `{s}` is not a valid Rust version"
438438
));
439439
None
@@ -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 `{clippy_msrv}` from `clippy.toml`"
449449
));
450450
}
@@ -473,7 +473,7 @@ pub fn read_conf(sess: &Session) -> Conf {
473473
let TryConf { conf, errors, warnings } = utils::conf::read(&file_name);
474474
// all conf errors are non-fatal, we just use the default conf in case of error
475475
for error in errors {
476-
sess.err(&format!(
476+
sess.err(format!(
477477
"error reading Clippy's configuration file `{}`: {}",
478478
file_name.display(),
479479
format_error(error)

clippy_lints/src/nonstandard_macro_braces.rs

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

clippy_utils/src/attrs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ pub fn get_unique_inner_attr(sess: &Session, attrs: &[ast::Attribute], name: &'s
136136
.emit();
137137
},
138138
ast::AttrStyle::Outer => {
139-
sess.span_err(attr.span, &format!("`{name}` cannot be an outer attribute"));
139+
sess.span_err(attr.span, format!("`{name}` cannot be an outer attribute"));
140140
},
141141
}
142142
}

clippy_utils/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub fn parse_msrv(msrv: &str, sess: Option<&Session>, span: Option<Span>) -> Opt
125125
return Some(version);
126126
} else if let Some(sess) = sess {
127127
if let Some(span) = span {
128-
sess.span_err(span, &format!("`{msrv}` is not a valid Rust version"));
128+
sess.span_err(span, format!("`{msrv}` is not a valid Rust version"));
129129
}
130130
}
131131
None

lintcheck/src/main.rs

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ impl Crate {
345345
clippy_args.push(opt);
346346
}
347347
} else {
348-
clippy_args.extend(&["-Wclippy::pedantic", "-Wclippy::cargo"])
348+
clippy_args.extend(["-Wclippy::pedantic", "-Wclippy::cargo"])
349349
}
350350

351351
if lint_filter.is_empty() {
@@ -457,15 +457,11 @@ fn build_clippy() {
457457
/// Read a `lintcheck_crates.toml` file
458458
fn read_crates(toml_path: &Path) -> (Vec<CrateSource>, RecursiveOptions) {
459459
let toml_content: String =
460-
std::fs::read_to_string(&toml_path).unwrap_or_else(|_| panic!("Failed to read {}", toml_path.display()));
460+
std::fs::read_to_string(toml_path).unwrap_or_else(|_| panic!("Failed to read {}", toml_path.display()));
461461
let crate_list: SourceList =
462462
toml::from_str(&toml_content).unwrap_or_else(|e| panic!("Failed to parse {}: \n{}", toml_path.display(), e));
463463
// parse the hashmap of the toml file into a list of crates
464-
let tomlcrates: Vec<TomlCrate> = crate_list
465-
.crates
466-
.into_iter()
467-
.map(|(_cratename, tomlcrate)| tomlcrate)
468-
.collect();
464+
let tomlcrates: Vec<TomlCrate> = crate_list.crates.into_values().collect();
469465

470466
// flatten TomlCrates into CrateSources (one TomlCrates may represent several versions of a crate =>
471467
// multiple Cratesources)
@@ -602,10 +598,10 @@ fn main() {
602598
) {
603599
let shared_target_dir = "target/lintcheck/shared_target_dir";
604600
// if we get an Err here, the shared target dir probably does simply not exist
605-
if let Ok(metadata) = std::fs::metadata(&shared_target_dir) {
601+
if let Ok(metadata) = std::fs::metadata(shared_target_dir) {
606602
if metadata.is_dir() {
607603
println!("Clippy is newer than lint check logs, clearing lintcheck shared target dir...");
608-
std::fs::remove_dir_all(&shared_target_dir)
604+
std::fs::remove_dir_all(shared_target_dir)
609605
.expect("failed to remove target/lintcheck/shared_target_dir");
610606
}
611607
}
@@ -779,7 +775,7 @@ fn read_stats_from_file(file_path: &Path) -> HashMap<String, usize> {
779775
fn print_stats(old_stats: HashMap<String, usize>, new_stats: HashMap<&String, usize>, lint_filter: &Vec<String>) {
780776
let same_in_both_hashmaps = old_stats
781777
.iter()
782-
.filter(|(old_key, old_val)| new_stats.get::<&String>(&old_key) == Some(old_val))
778+
.filter(|(old_key, old_val)| new_stats.get::<&String>(old_key) == Some(old_val))
783779
.map(|(k, v)| (k.to_string(), *v))
784780
.collect::<Vec<(String, usize)>>();
785781

@@ -797,24 +793,24 @@ fn print_stats(old_stats: HashMap<String, usize>, new_stats: HashMap<&String, us
797793
// list all new counts (key is in new stats but not in old stats)
798794
new_stats_deduped
799795
.iter()
800-
.filter(|(new_key, _)| old_stats_deduped.get::<str>(&new_key).is_none())
796+
.filter(|(new_key, _)| old_stats_deduped.get::<str>(new_key).is_none())
801797
.for_each(|(new_key, new_value)| {
802798
println!("{} 0 => {}", new_key, new_value);
803799
});
804800

805801
// list all changed counts (key is in both maps but value differs)
806802
new_stats_deduped
807803
.iter()
808-
.filter(|(new_key, _new_val)| old_stats_deduped.get::<str>(&new_key).is_some())
804+
.filter(|(new_key, _new_val)| old_stats_deduped.get::<str>(new_key).is_some())
809805
.for_each(|(new_key, new_val)| {
810-
let old_val = old_stats_deduped.get::<str>(&new_key).unwrap();
806+
let old_val = old_stats_deduped.get::<str>(new_key).unwrap();
811807
println!("{} {} => {}", new_key, old_val, new_val);
812808
});
813809

814810
// list all gone counts (key is in old status but not in new stats)
815811
old_stats_deduped
816812
.iter()
817-
.filter(|(old_key, _)| new_stats_deduped.get::<&String>(&old_key).is_none())
813+
.filter(|(old_key, _)| new_stats_deduped.get::<&String>(old_key).is_none())
818814
.filter(|(old_key, _)| lint_filter.is_empty() || lint_filter.contains(old_key))
819815
.for_each(|(old_key, old_value)| {
820816
println!("{} {} => 0", old_key, old_value);
@@ -832,12 +828,12 @@ fn create_dirs(krate_download_dir: &Path, extract_dir: &Path) {
832828
panic!("cannot create lintcheck target dir");
833829
}
834830
});
835-
std::fs::create_dir(&krate_download_dir).unwrap_or_else(|err| {
831+
std::fs::create_dir(krate_download_dir).unwrap_or_else(|err| {
836832
if err.kind() != ErrorKind::AlreadyExists {
837833
panic!("cannot create crate download dir");
838834
}
839835
});
840-
std::fs::create_dir(&extract_dir).unwrap_or_else(|err| {
836+
std::fs::create_dir(extract_dir).unwrap_or_else(|err| {
841837
if err.kind() != ErrorKind::AlreadyExists {
842838
panic!("cannot create crate extraction dir");
843839
}
@@ -863,7 +859,7 @@ fn lintcheck_test() {
863859
"lintcheck/test_sources.toml",
864860
];
865861
let status = std::process::Command::new("cargo")
866-
.args(&args)
862+
.args(args)
867863
.current_dir("..") // repo root
868864
.status();
869865
//.output();

tests/compile-test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ fn run_ui_cargo() {
283283
env::set_current_dir(&src_path)?;
284284

285285
let cargo_toml_path = case.path().join("Cargo.toml");
286-
let cargo_content = fs::read(&cargo_toml_path)?;
286+
let cargo_content = fs::read(cargo_toml_path)?;
287287
let cargo_parsed: toml::Value = toml::from_str(
288288
std::str::from_utf8(&cargo_content).expect("`Cargo.toml` is not a valid utf-8 file!"),
289289
)

tests/versioncheck.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ fn check_that_clippy_has_the_same_major_version_as_rustc() {
4848
// `RUSTC_REAL` if Clippy is build in the Rust repo with `./x.py`.
4949
let rustc = std::env::var("RUSTC_REAL").unwrap_or_else(|_| "rustc".to_string());
5050
let rustc_version = String::from_utf8(
51-
std::process::Command::new(&rustc)
51+
std::process::Command::new(rustc)
5252
.arg("--version")
5353
.output()
5454
.expect("failed to run `rustc --version`")

0 commit comments

Comments
 (0)