mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-30 00:20:36 +00:00
a few more core lint fixes
This commit is contained in:
parent
e67b2bf732
commit
cb6d1267c4
6 changed files with 20 additions and 25 deletions
|
@ -193,8 +193,8 @@ fn report_clippy_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
|
|||
|
||||
let xs: Vec<Cow<'static, str>> = vec![
|
||||
"the compiler unexpectedly panicked. this is a bug.".into(),
|
||||
format!("we would appreciate a bug report: {}", bug_report_url).into(),
|
||||
format!("Clippy version: {}", version_info).into(),
|
||||
format!("we would appreciate a bug report: {bug_report_url}").into(),
|
||||
format!("Clippy version: {version_info}").into(),
|
||||
];
|
||||
|
||||
for note in &xs {
|
||||
|
@ -290,7 +290,7 @@ pub fn main() {
|
|||
|
||||
if orig_args.iter().any(|a| a == "--version" || a == "-V") {
|
||||
let version_info = rustc_tools_util::get_version_info!();
|
||||
println!("{}", version_info);
|
||||
println!("{version_info}");
|
||||
exit(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -37,12 +37,12 @@ You can use tool lints to allow or deny lints from your code, eg.:
|
|||
"#;
|
||||
|
||||
fn show_help() {
|
||||
println!("{}", CARGO_CLIPPY_HELP);
|
||||
println!("{CARGO_CLIPPY_HELP}");
|
||||
}
|
||||
|
||||
fn show_version() {
|
||||
let version_info = rustc_tools_util::get_version_info!();
|
||||
println!("{}", version_info);
|
||||
println!("{version_info}");
|
||||
}
|
||||
|
||||
pub fn main() {
|
||||
|
@ -133,7 +133,7 @@ impl ClippyCmd {
|
|||
let clippy_args: String = self
|
||||
.clippy_args
|
||||
.iter()
|
||||
.map(|arg| format!("{}__CLIPPY_HACKERY__", arg))
|
||||
.map(|arg| format!("{arg}__CLIPPY_HACKERY__"))
|
||||
.collect();
|
||||
|
||||
// Currently, `CLIPPY_TERMINAL_WIDTH` is used only to format "unknown field" error messages.
|
||||
|
|
|
@ -111,15 +111,14 @@ static EXTERN_FLAGS: LazyLock<String> = LazyLock::new(|| {
|
|||
.collect();
|
||||
assert!(
|
||||
not_found.is_empty(),
|
||||
"dependencies not found in depinfo: {:?}\n\
|
||||
"dependencies not found in depinfo: {not_found:?}\n\
|
||||
help: Make sure the `-Z binary-dep-depinfo` rust flag is enabled\n\
|
||||
help: Try adding to dev-dependencies in Cargo.toml\n\
|
||||
help: Be sure to also add `extern crate ...;` to tests/compile-test.rs",
|
||||
not_found,
|
||||
);
|
||||
crates
|
||||
.into_iter()
|
||||
.map(|(name, path)| format!(" --extern {}={}", name, path))
|
||||
.map(|(name, path)| format!(" --extern {name}={path}"))
|
||||
.collect()
|
||||
});
|
||||
|
||||
|
@ -150,9 +149,8 @@ fn base_config(test_dir: &str) -> compiletest::Config {
|
|||
.map(|p| format!(" -L dependency={}", Path::new(p).join("deps").display()))
|
||||
.unwrap_or_default();
|
||||
config.target_rustcflags = Some(format!(
|
||||
"--emit=metadata -Dwarnings -Zui-testing -L dependency={}{}{}",
|
||||
"--emit=metadata -Dwarnings -Zui-testing -L dependency={}{host_libs}{}",
|
||||
deps_path.display(),
|
||||
host_libs,
|
||||
&*EXTERN_FLAGS,
|
||||
));
|
||||
|
||||
|
@ -239,7 +237,7 @@ fn run_ui_toml() {
|
|||
Ok(true) => {},
|
||||
Ok(false) => panic!("Some tests failed"),
|
||||
Err(e) => {
|
||||
panic!("I/O failure during tests: {:?}", e);
|
||||
panic!("I/O failure during tests: {e:?}");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +346,7 @@ fn run_ui_cargo() {
|
|||
Ok(true) => {},
|
||||
Ok(false) => panic!("Some tests failed"),
|
||||
Err(e) => {
|
||||
panic!("I/O failure during tests: {:?}", e);
|
||||
panic!("I/O failure during tests: {e:?}");
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -419,16 +417,15 @@ fn check_rustfix_coverage() {
|
|||
if rs_path.starts_with("tests/ui/crashes") {
|
||||
continue;
|
||||
}
|
||||
assert!(rs_path.starts_with("tests/ui/"), "{:?}", rs_file);
|
||||
assert!(rs_path.starts_with("tests/ui/"), "{rs_file:?}");
|
||||
let filename = rs_path.strip_prefix("tests/ui/").unwrap();
|
||||
assert!(
|
||||
RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS
|
||||
.binary_search_by_key(&filename, Path::new)
|
||||
.is_ok(),
|
||||
"`{}` runs `MachineApplicable` diagnostics but is missing a `run-rustfix` annotation. \
|
||||
"`{rs_file}` runs `MachineApplicable` diagnostics but is missing a `run-rustfix` annotation. \
|
||||
Please either add `// run-rustfix` at the top of the file or add the file to \
|
||||
`RUSTFIX_COVERAGE_KNOWN_EXCEPTIONS` in `tests/compile-test.rs`.",
|
||||
rs_file,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -478,15 +475,13 @@ fn ui_cargo_toml_metadata() {
|
|||
.map(|component| component.as_os_str().to_string_lossy().replace('-', "_"))
|
||||
.any(|s| *s == name)
|
||||
|| path.starts_with(&cargo_common_metadata_path),
|
||||
"{:?} has incorrect package name",
|
||||
path
|
||||
"{path:?} has incorrect package name"
|
||||
);
|
||||
|
||||
let publish = package.get("publish").and_then(toml::Value::as_bool).unwrap_or(true);
|
||||
assert!(
|
||||
!publish || publish_exceptions.contains(&path.parent().unwrap().to_path_buf()),
|
||||
"{:?} lacks `publish = false`",
|
||||
path
|
||||
"{path:?} lacks `publish = false`"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ fn lint_message_convention() {
|
|||
"error: the test '{}' contained the following nonconforming lines :",
|
||||
message.path.display()
|
||||
);
|
||||
message.bad_lines.iter().for_each(|line| eprintln!("{}", line));
|
||||
message.bad_lines.iter().for_each(|line| eprintln!("{line}"));
|
||||
eprintln!("\n\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ fn test_missing_tests() {
|
|||
"Didn't see a test file for the following files:\n\n{}\n",
|
||||
missing_files
|
||||
.iter()
|
||||
.map(|s| format!("\t{}", s))
|
||||
.map(|s| format!("\t{s}"))
|
||||
.collect::<Vec<_>>()
|
||||
.join("\n")
|
||||
);
|
||||
|
|
|
@ -8,12 +8,12 @@ use std::fs;
|
|||
#[test]
|
||||
fn check_that_clippy_lints_and_clippy_utils_have_the_same_version_as_clippy() {
|
||||
fn read_version(path: &str) -> String {
|
||||
let contents = fs::read_to_string(path).unwrap_or_else(|e| panic!("error reading `{}`: {:?}", path, e));
|
||||
let contents = fs::read_to_string(path).unwrap_or_else(|e| panic!("error reading `{path}`: {e:?}"));
|
||||
contents
|
||||
.lines()
|
||||
.filter_map(|l| l.split_once('='))
|
||||
.find_map(|(k, v)| (k.trim() == "version").then(|| v.trim()))
|
||||
.unwrap_or_else(|| panic!("error finding version in `{}`", path))
|
||||
.unwrap_or_else(|| panic!("error finding version in `{path}`"))
|
||||
.to_string()
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ fn check_that_clippy_has_the_same_major_version_as_rustc() {
|
|||
// we don't want our tests failing suddenly
|
||||
},
|
||||
_ => {
|
||||
panic!("Failed to parse rustc version: {:?}", vsplit);
|
||||
panic!("Failed to parse rustc version: {vsplit:?}");
|
||||
},
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue