Skip to content

Commit cb6d126

Browse files
committed
a few more core lint fixes
1 parent e67b2bf commit cb6d126

File tree

6 files changed

+20
-25
lines changed

6 files changed

+20
-25
lines changed

src/driver.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
193193

194194
let xs: Vec<Cow<'static, str>> = vec![
195195
"the compiler unexpectedly panicked. this is a bug.".into(),
196-
format!("we would appreciate a bug report: {}", bug_report_url).into(),
197-
format!("Clippy version: {}", version_info).into(),
196+
format!("we would appreciate a bug report: {bug_report_url}").into(),
197+
format!("Clippy version: {version_info}").into(),
198198
];
199199

200200
for note in &xs {
@@ -290,7 +290,7 @@ pub fn main() {
290290

291291
if orig_args.iter().any(|a| a == "--version" || a == "-V") {
292292
let version_info = rustc_tools_util::get_version_info!();
293-
println!("{}", version_info);
293+
println!("{version_info}");
294294
exit(0);
295295
}
296296

src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,12 @@ You can use tool lints to allow or deny lints from your code, eg.:
3737
"#;
3838

3939
fn show_help() {
40-
println!("{}", CARGO_CLIPPY_HELP);
40+
println!("{CARGO_CLIPPY_HELP}");
4141
}
4242

4343
fn show_version() {
4444
let version_info = rustc_tools_util::get_version_info!();
45-
println!("{}", version_info);
45+
println!("{version_info}");
4646
}
4747

4848
pub fn main() {
@@ -133,7 +133,7 @@ impl ClippyCmd {
133133
let clippy_args: String = self
134134
.clippy_args
135135
.iter()
136-
.map(|arg| format!("{}__CLIPPY_HACKERY__", arg))
136+
.map(|arg| format!("{arg}__CLIPPY_HACKERY__"))
137137
.collect();
138138

139139
// Currently, `CLIPPY_TERMINAL_WIDTH` is used only to format "unknown field" error messages.

tests/compile-test.rs

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -111,15 +111,14 @@ static EXTERN_FLAGS: LazyLock<String> = LazyLock::new(|| {
111111
.collect();
112112
assert!(
113113
not_found.is_empty(),
114-
"dependencies not found in depinfo: {:?}\n\
114+
"dependencies not found in depinfo: {not_found:?}\n\
115115
help: Make sure the `-Z binary-dep-depinfo` rust flag is enabled\n\
116116
help: Try adding to dev-dependencies in Cargo.toml\n\
117117
help: Be sure to also add `extern crate ...;` to tests/compile-test.rs",
118-
not_found,
119118
);
120119
crates
121120
.into_iter()
122-
.map(|(name, path)| format!(" --extern {}={}", name, path))
121+
.map(|(name, path)| format!(" --extern {name}={path}"))
123122
.collect()
124123
});
125124

@@ -150,9 +149,8 @@ fn base_config(test_dir: &str) -> compiletest::Config {
150149
.map(|p| format!(" -L dependency={}", Path::new(p).join("deps").display()))
151150
.unwrap_or_default();
152151
config.target_rustcflags = Some(format!(
153-
"--emit=metadata -Dwarnings -Zui-testing -L dependency={}{}{}",
152+
"--emit=metadata -Dwarnings -Zui-testing -L dependency={}{host_libs}{}",
154153
deps_path.display(),
155-
host_libs,
156154
&*EXTERN_FLAGS,
157155
));
158156

@@ -239,7 +237,7 @@ fn run_ui_toml() {
239237
Ok(true) => {},
240238
Ok(false) => panic!("Some tests failed"),
241239
Err(e) => {
242-
panic!("I/O failure during tests: {:?}", e);
240+
panic!("I/O failure during tests: {e:?}");
243241
},
244242
}
245243
}
@@ -348,7 +346,7 @@ fn run_ui_cargo() {
348346
Ok(true) => {},
349347
Ok(false) => panic!("Some tests failed"),
350348
Err(e) => {
351-
panic!("I/O failure during tests: {:?}", e);
349+
panic!("I/O failure during tests: {e:?}");
352350
},
353351
}
354352
}
@@ -419,16 +417,15 @@ fn check_rustfix_coverage() {
419417
if rs_path.starts_with("tests/ui/crashes") {
420418
continue;
421419
}
422-
assert!(rs_path.starts_with("tests/ui/"), "{:?}", rs_file);
420+
assert!(rs_path.starts_with("tests/ui/"), "{rs_file:?}");
423421
let filename = rs_path.strip_prefix("tests/ui/").unwrap();
424422
assert!(
425423
RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS
426424
.binary_search_by_key(&filename, Path::new)
427425
.is_ok(),
428-
"`{}` runs `MachineApplicable` diagnostics but is missing a `run-rustfix` annotation. \
426+
"`{rs_file}` runs `MachineApplicable` diagnostics but is missing a `run-rustfix` annotation. \
429427
Please either add `// run-rustfix` at the top of the file or add the file to \
430428
`RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS` in `tests/compile-test.rs`.",
431-
rs_file,
432429
);
433430
}
434431
}
@@ -478,15 +475,13 @@ fn ui_cargo_toml_metadata() {
478475
.map(|component| component.as_os_str().to_string_lossy().replace('-', "_"))
479476
.any(|s| *s == name)
480477
|| path.starts_with(&cargo_common_metadata_path),
481-
"{:?} has incorrect package name",
482-
path
478+
"{path:?} has incorrect package name"
483479
);
484480

485481
let publish = package.get("publish").and_then(toml::Value::as_bool).unwrap_or(true);
486482
assert!(
487483
!publish || publish_exceptions.contains(&path.parent().unwrap().to_path_buf()),
488-
"{:?} lacks `publish = false`",
489-
path
484+
"{path:?} lacks `publish = false`"
490485
);
491486
}
492487
}

tests/lint_message_convention.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn lint_message_convention() {
102102
"error: the test '{}' contained the following nonconforming lines :",
103103
message.path.display()
104104
);
105-
message.bad_lines.iter().for_each(|line| eprintln!("{}", line));
105+
message.bad_lines.iter().for_each(|line| eprintln!("{line}"));
106106
eprintln!("\n\n");
107107
}
108108

tests/missing-test-files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn test_missing_tests() {
1717
"Didn't see a test file for the following files:\n\n{}\n",
1818
missing_files
1919
.iter()
20-
.map(|s| format!("\t{}", s))
20+
.map(|s| format!("\t{s}"))
2121
.collect::<Vec<_>>()
2222
.join("\n")
2323
);

tests/versioncheck.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ use std::fs;
88
#[test]
99
fn check_that_clippy_lints_and_clippy_utils_have_the_same_version_as_clippy() {
1010
fn read_version(path: &str) -> String {
11-
let contents = fs::read_to_string(path).unwrap_or_else(|e| panic!("error reading `{}`: {:?}", path, e));
11+
let contents = fs::read_to_string(path).unwrap_or_else(|e| panic!("error reading `{path}`: {e:?}"));
1212
contents
1313
.lines()
1414
.filter_map(|l| l.split_once('='))
1515
.find_map(|(k, v)| (k.trim() == "version").then(|| v.trim()))
16-
.unwrap_or_else(|| panic!("error finding version in `{}`", path))
16+
.unwrap_or_else(|| panic!("error finding version in `{path}`"))
1717
.to_string()
1818
}
1919

@@ -83,7 +83,7 @@ fn check_that_clippy_has_the_same_major_version_as_rustc() {
8383
// we don't want our tests failing suddenly
8484
},
8585
_ => {
86-
panic!("Failed to parse rustc version: {:?}", vsplit);
86+
panic!("Failed to parse rustc version: {vsplit:?}");
8787
},
8888
};
8989
}

0 commit comments

Comments
 (0)