Skip to content

Commit 0bb9b1a

Browse files
committed
Fix adjacent code
1 parent 1499021 commit 0bb9b1a

12 files changed

+26
-25
lines changed

clippy_dev/src/bless.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fn update_reference_file(test_output_entry: &DirEntry, ignore_timestamp: bool) {
3737
return;
3838
}
3939

40-
let test_output_file = fs::read(&test_output_path).expect("Unable to read test output file");
40+
let test_output_file = fs::read(test_output_path).expect("Unable to read test output file");
4141
let reference_file = fs::read(&reference_file_path).unwrap_or_default();
4242

4343
if test_output_file != reference_file {

clippy_dev/src/fmt.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub fn run(check: bool, verbose: bool) {
4646
// dependency
4747
if fs::read_to_string(project_root.join("Cargo.toml"))
4848
.expect("Failed to read clippy Cargo.toml")
49-
.contains(&"[target.'cfg(NOT_A_PLATFORM)'.dependencies]")
49+
.contains("[target.'cfg(NOT_A_PLATFORM)'.dependencies]")
5050
{
5151
return Err(CliError::RaSetupActive);
5252
}
@@ -193,10 +193,10 @@ fn rustfmt_test(context: &FmtContext) -> Result<(), CliError> {
193193
let args = &["--version"];
194194

195195
if context.verbose {
196-
println!("{}", format_command(&program, &dir, args));
196+
println!("{}", format_command(program, &dir, args));
197197
}
198198

199-
let output = Command::new(&program).current_dir(&dir).args(args.iter()).output()?;
199+
let output = Command::new(program).current_dir(&dir).args(args.iter()).output()?;
200200

201201
if output.status.success() {
202202
Ok(())
@@ -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/update_lints.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ fn remove_lint_declaration(name: &str, path: &Path, lints: &mut Vec<Lint>) -> io
418418
.expect("failed to find `impl_lint_pass` terminator");
419419

420420
impl_lint_pass_end += impl_lint_pass_start;
421-
if let Some(lint_name_pos) = content[impl_lint_pass_start..impl_lint_pass_end].find(&lint_name_upper) {
421+
if let Some(lint_name_pos) = content[impl_lint_pass_start..impl_lint_pass_end].find(lint_name_upper) {
422422
let mut lint_name_end = impl_lint_pass_start + (lint_name_pos + lint_name_upper.len());
423423
for c in content[lint_name_end..impl_lint_pass_end].chars() {
424424
// Remove trailing whitespace
@@ -451,7 +451,7 @@ fn remove_lint_declaration(name: &str, path: &Path, lints: &mut Vec<Lint>) -> io
451451
}
452452

453453
let mut content =
454-
fs::read_to_string(&path).unwrap_or_else(|_| panic!("failed to read `{}`", path.to_string_lossy()));
454+
fs::read_to_string(path).unwrap_or_else(|_| panic!("failed to read `{}`", path.to_string_lossy()));
455455

456456
eprintln!(
457457
"warn: you will have to manually remove any code related to `{}` from `{}`",

rustc_tools_util/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ impl std::fmt::Debug for VersionInfo {
8484
#[must_use]
8585
pub fn get_commit_hash() -> Option<String> {
8686
std::process::Command::new("git")
87-
.args(&["rev-parse", "--short", "HEAD"])
87+
.args(["rev-parse", "--short", "HEAD"])
8888
.output()
8989
.ok()
9090
.and_then(|r| String::from_utf8(r.stdout).ok())
@@ -93,7 +93,7 @@ pub fn get_commit_hash() -> Option<String> {
9393
#[must_use]
9494
pub fn get_commit_date() -> Option<String> {
9595
std::process::Command::new("git")
96-
.args(&["log", "-1", "--date=short", "--pretty=format:%cd"])
96+
.args(["log", "-1", "--date=short", "--pretty=format:%cd"])
9797
.output()
9898
.ok()
9999
.and_then(|r| String::from_utf8(r.stdout).ok())

tests/check-fmt.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fn fmt() {
1313
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
1414
let output = Command::new("cargo")
1515
.current_dir(root_dir)
16-
.args(&["dev", "fmt", "--check"])
16+
.args(["dev", "fmt", "--check"])
1717
.output()
1818
.unwrap();
1919

tests/dogfood.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ fn run_clippy_for_package(project: &str, args: &[&str]) {
8787

8888
if cfg!(feature = "internal") {
8989
// internal lints only exist if we build with the internal feature
90-
command.args(&["-D", "clippy::internal"]);
90+
command.args(["-D", "clippy::internal"]);
9191
} else {
9292
// running a clippy built without internal lints on the clippy source
9393
// that contains e.g. `allow(clippy::invalid_paths)`
94-
command.args(&["-A", "unknown_lints"]);
94+
command.args(["-A", "unknown_lints"]);
9595
}
9696

9797
let output = command.output().unwrap();

tests/integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ fn integration_test() {
1919
repo_dir.push(crate_name);
2020

2121
let st = Command::new("git")
22-
.args(&[
22+
.args([
2323
OsStr::new("clone"),
2424
OsStr::new("--depth=1"),
2525
OsStr::new(&repo_url),
@@ -37,7 +37,7 @@ fn integration_test() {
3737
.current_dir(repo_dir)
3838
.env("RUST_BACKTRACE", "full")
3939
.env("CARGO_TARGET_DIR", target_dir)
40-
.args(&[
40+
.args([
4141
"clippy",
4242
"--all-targets",
4343
"--all-features",

tests/lint_message_convention.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ impl Message {
1919
// we don't want the first letter after "error: ", "help: " ... to be capitalized
2020
// also no punctuation (except for "?" ?) at the end of a line
2121
static REGEX_SET: LazyLock<RegexSet> = LazyLock::new(|| {
22-
RegexSet::new(&[
22+
RegexSet::new([
2323
r"error: [A-Z]",
2424
r"help: [A-Z]",
2525
r"warning: [A-Z]",
@@ -37,7 +37,7 @@ impl Message {
3737
// sometimes the first character is capitalized and it is legal (like in "C-like enum variants") or
3838
// we want to ask a question ending in "?"
3939
static EXCEPTIONS_SET: LazyLock<RegexSet> = LazyLock::new(|| {
40-
RegexSet::new(&[
40+
RegexSet::new([
4141
r"\.\.\.$",
4242
r".*C-like enum variant discriminant is not portable to 32-bit targets",
4343
r".*Intel x86 assembly syntax used",

tests/ui/regex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(unused)]
1+
#![allow(unused, clippy::needless_borrow)]
22
#![warn(clippy::invalid_regex, clippy::trivial_regex)]
33

44
extern crate regex;

tests/ui/same_item_push.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ fn main() {
151151

152152
// Fix #6987
153153
let mut vec = Vec::new();
154+
#[allow(clippy::needless_borrow)]
154155
for _ in 0..10 {
155156
vec.push(1);
156157
vec.extend(&[2]);

tests/ui/verbose_file_reads.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ fn main() -> std::io::Result<()> {
1818
s.read_to_end();
1919
s.read_to_string();
2020
// Should catch this
21-
let mut f = File::open(&path)?;
21+
let mut f = File::open(path)?;
2222
let mut buffer = Vec::new();
2323
f.read_to_end(&mut buffer)?;
2424
// ...and this

tests/workspace.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
2020
.current_dir(&cwd)
2121
.env("CARGO_TARGET_DIR", &target_dir)
2222
.arg("clean")
23-
.args(&["-p", "subcrate"])
24-
.args(&["-p", "path_dep"])
23+
.args(["-p", "subcrate"])
24+
.args(["-p", "path_dep"])
2525
.output()
2626
.unwrap();
2727

@@ -32,11 +32,11 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
3232
.env("CARGO_INCREMENTAL", "0")
3333
.env("CARGO_TARGET_DIR", &target_dir)
3434
.arg("clippy")
35-
.args(&["-p", "subcrate"])
35+
.args(["-p", "subcrate"])
3636
.arg("--no-deps")
3737
.arg("--")
3838
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
39-
.args(&["--cfg", r#"feature="primary_package_test""#])
39+
.args(["--cfg", r#"feature="primary_package_test""#])
4040
.output()
4141
.unwrap();
4242
println!("status: {}", output.status);
@@ -52,10 +52,10 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
5252
.env("CARGO_INCREMENTAL", "0")
5353
.env("CARGO_TARGET_DIR", &target_dir)
5454
.arg("clippy")
55-
.args(&["-p", "subcrate"])
55+
.args(["-p", "subcrate"])
5656
.arg("--")
5757
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
58-
.args(&["--cfg", r#"feature="primary_package_test""#])
58+
.args(["--cfg", r#"feature="primary_package_test""#])
5959
.output()
6060
.unwrap();
6161
println!("status: {}", output.status);
@@ -79,7 +79,7 @@ fn test_no_deps_ignores_path_deps_in_workspaces() {
7979
.env("CARGO_INCREMENTAL", "0")
8080
.env("CARGO_TARGET_DIR", &target_dir)
8181
.arg("clippy")
82-
.args(&["-p", "subcrate"])
82+
.args(["-p", "subcrate"])
8383
.arg("--")
8484
.arg("-Cdebuginfo=0") // disable debuginfo to generate less data in the target dir
8585
.output()

0 commit comments

Comments
 (0)