Skip to content

Commit 3331f34

Browse files
authored
Merge pull request #3096 from hi-rustin/rustin-patch-clippy
Clippy satisfying changes - unneeded & and &*.
2 parents b3d5325 + e7395b8 commit 3331f34

File tree

13 files changed

+50
-50
lines changed

13 files changed

+50
-50
lines changed

download/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ pub fn download_to_path_with_backend(
6161

6262
|| -> Result<()> {
6363
let (file, resume_from) = if resume_from_partial {
64-
let possible_partial = OpenOptions::new().read(true).open(&path);
64+
let possible_partial = OpenOptions::new().read(true).open(path);
6565

6666
let downloaded_so_far = if let Ok(mut partial) = possible_partial {
6767
if let Some(cb) = callback {
@@ -90,7 +90,7 @@ pub fn download_to_path_with_backend(
9090
let mut possible_partial = OpenOptions::new()
9191
.write(true)
9292
.create(true)
93-
.open(&path)
93+
.open(path)
9494
.context("error opening file for download")?;
9595

9696
possible_partial.seek(SeekFrom::End(0))?;
@@ -101,7 +101,7 @@ pub fn download_to_path_with_backend(
101101
OpenOptions::new()
102102
.write(true)
103103
.create(true)
104-
.open(&path)
104+
.open(path)
105105
.context("error creating file for download")?,
106106
0,
107107
)

src/cli/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ fn print_toolchain_path(
423423
) -> Result<()> {
424424
let toolchain_path = {
425425
let mut t_path = cfg.toolchains_dir.clone();
426-
t_path.push(&toolchain);
426+
t_path.push(toolchain);
427427
t_path
428428
};
429429
let toolchain_meta = fs::symlink_metadata(&toolchain_path)?;

src/cli/self_update/shell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl Zsh {
161161
}
162162
} else {
163163
match std::process::Command::new("zsh")
164-
.args(&["-c", "'echo $ZDOTDIR'"])
164+
.args(["-c", "'echo $ZDOTDIR'"])
165165
.output()
166166
{
167167
Ok(io) if !io.stdout.is_empty() => Ok(PathBuf::from(OsStr::from_bytes(&io.stdout))),

src/cli/topical_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn dir_into_vec(dir: &Path) -> Result<Vec<OsString>> {
2929
}
3030

3131
fn search_path(doc: &DocData<'_>, wpath: &Path, keywords: &[&str]) -> Result<PathBuf> {
32-
let dir = &doc.root.join(&wpath);
32+
let dir = &doc.root.join(wpath);
3333
if dir.is_dir() {
3434
let entries = dir_into_vec(dir)?;
3535
for k in keywords {

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl PgpPublicKey {
171171
/// Retrieve the key.
172172
pub(crate) fn cert(&self) -> &Cert {
173173
match self {
174-
Self::Builtin => &*BUILTIN_PGP_KEY,
174+
Self::Builtin => &BUILTIN_PGP_KEY,
175175
Self::FromEnvironment(_, k) => k,
176176
Self::FromConfiguration(_, k) => k,
177177
}

src/diskio/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ pub(crate) fn perform<F: Fn(usize)>(item: &mut Item, chunk_complete_callback: F)
339339
contents.clear();
340340
match contents {
341341
FileBuffer::Immediate(ref contents) => {
342-
write_file(&item.full_path, &contents, item.mode)
342+
write_file(&item.full_path, contents, item.mode)
343343
}
344344
FileBuffer::Threaded(ref mut contents) => {
345345
write_file(&item.full_path, &contents, item.mode)

src/dist/component/package.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ impl<'a> TarPackage<'a> {
149149
// The rust-installer packages unpack to a directory called
150150
// $pkgname-$version-$target. Skip that directory when
151151
// unpacking.
152-
unpack_without_first_dir(&mut archive, &*temp_dir, notify_handler)
152+
unpack_without_first_dir(&mut archive, &temp_dir, notify_handler)
153153
.context("failed to extract package (perhaps you ran out of disk space?)")?;
154154

155155
Ok(TarPackage(
@@ -334,7 +334,7 @@ fn unpack_without_first_dir<'a, R: Read>(
334334
let mut components = relpath.components();
335335
// Throw away the first path component: our root was supplied.
336336
components.next();
337-
let full_path = path.join(&components.as_path());
337+
let full_path = path.join(components.as_path());
338338
if full_path == path {
339339
// The tmp dir code makes the root dir for us.
340340
continue;

src/toolchain.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl<'a> InstalledCommonToolchain<'a> {
381381
}
382382
Path::new(&binary)
383383
};
384-
let mut cmd = Command::new(&path);
384+
let mut cmd = Command::new(path);
385385
self.set_env(&mut cmd);
386386
Ok(cmd)
387387
}

tests/cli-misc.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ fn update_all_no_update_whitespace() {
127127
#[test]
128128
fn update_works_without_term() {
129129
setup(&|config| {
130-
let mut cmd = clitools::cmd(config, "rustup", &["update", "nightly"]);
130+
let mut cmd = clitools::cmd(config, "rustup", ["update", "nightly"]);
131131
clitools::env(config, &mut cmd);
132132
cmd.env_remove("TERM");
133133

@@ -140,7 +140,7 @@ fn update_works_without_term() {
140140
#[test]
141141
fn show_works_with_dumb_term() {
142142
setup(&|config| {
143-
let mut cmd = clitools::cmd(config, "rustup", &["show"]);
143+
let mut cmd = clitools::cmd(config, "rustup", ["show"]);
144144
clitools::env(config, &mut cmd);
145145
cmd.env("TERM", "dumb");
146146
assert!(cmd.spawn().unwrap().wait().unwrap().success());
@@ -152,12 +152,12 @@ fn show_works_with_dumb_term() {
152152
#[test]
153153
fn subcommand_required_for_target() {
154154
setup(&|config| {
155-
let mut cmd = clitools::cmd(config, "rustup", &["target"]);
155+
let mut cmd = clitools::cmd(config, "rustup", ["target"]);
156156
clitools::env(config, &mut cmd);
157157
let out = cmd.output().unwrap();
158158
assert!(!out.status.success());
159159
assert_eq!(out.status.code().unwrap(), 1);
160-
assert!(str::from_utf8(&out.stdout).unwrap().contains(&"USAGE"));
160+
assert!(str::from_utf8(&out.stdout).unwrap().contains("USAGE"));
161161
});
162162
}
163163

@@ -166,12 +166,12 @@ fn subcommand_required_for_target() {
166166
#[test]
167167
fn subcommand_required_for_toolchain() {
168168
setup(&|config| {
169-
let mut cmd = clitools::cmd(config, "rustup", &["toolchain"]);
169+
let mut cmd = clitools::cmd(config, "rustup", ["toolchain"]);
170170
clitools::env(config, &mut cmd);
171171
let out = cmd.output().unwrap();
172172
assert!(!out.status.success());
173173
assert_eq!(out.status.code().unwrap(), 1);
174-
assert!(str::from_utf8(&out.stdout).unwrap().contains(&"USAGE"));
174+
assert!(str::from_utf8(&out.stdout).unwrap().contains("USAGE"));
175175
});
176176
}
177177

@@ -180,12 +180,12 @@ fn subcommand_required_for_toolchain() {
180180
#[test]
181181
fn subcommand_required_for_override() {
182182
setup(&|config| {
183-
let mut cmd = clitools::cmd(config, "rustup", &["override"]);
183+
let mut cmd = clitools::cmd(config, "rustup", ["override"]);
184184
clitools::env(config, &mut cmd);
185185
let out = cmd.output().unwrap();
186186
assert!(!out.status.success());
187187
assert_eq!(out.status.code().unwrap(), 1);
188-
assert!(str::from_utf8(&out.stdout).unwrap().contains(&"USAGE"));
188+
assert!(str::from_utf8(&out.stdout).unwrap().contains("USAGE"));
189189
});
190190
}
191191

@@ -194,12 +194,12 @@ fn subcommand_required_for_override() {
194194
#[test]
195195
fn subcommand_required_for_self() {
196196
setup(&|config| {
197-
let mut cmd = clitools::cmd(config, "rustup", &["self"]);
197+
let mut cmd = clitools::cmd(config, "rustup", ["self"]);
198198
clitools::env(config, &mut cmd);
199199
let out = cmd.output().unwrap();
200200
assert!(!out.status.success());
201201
assert_eq!(out.status.code().unwrap(), 1);
202-
assert!(str::from_utf8(&out.stdout).unwrap().contains(&"USAGE"));
202+
assert!(str::from_utf8(&out.stdout).unwrap().contains("USAGE"));
203203
});
204204
}
205205

tests/cli-paths.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ export PATH="$HOME/apple/bin"
5959
assert!(cmd.output().unwrap().status.success());
6060
let mut rcs = files.iter();
6161
let env = rcs.next().unwrap();
62-
let envfile = fs::read_to_string(&env).unwrap();
62+
let envfile = fs::read_to_string(env).unwrap();
6363
let (_, envfile_export) = envfile.split_at(envfile.find("export PATH").unwrap_or(0));
6464
assert_eq!(&envfile_export[..DEFAULT_EXPORT.len()], DEFAULT_EXPORT);
6565

6666
for rc in rcs {
6767
let expected = source("$HOME/.cargo", POSIX_SH);
68-
let new_profile = fs::read_to_string(&rc).unwrap();
68+
let new_profile = fs::read_to_string(rc).unwrap();
6969
assert_eq!(new_profile, expected);
7070
}
7171
});
@@ -86,7 +86,7 @@ export PATH="$HOME/apple/bin"
8686

8787
let expected = FAKE_RC.to_owned() + &source(config.cargodir.display(), POSIX_SH);
8888
for rc in &rcs {
89-
let new_rc = fs::read_to_string(&rc).unwrap();
89+
let new_rc = fs::read_to_string(rc).unwrap();
9090
assert_eq!(new_rc, expected);
9191
}
9292
})
@@ -191,9 +191,9 @@ export PATH="$HOME/apple/bin"
191191

192192
expect_ok(config, &INIT_NONE);
193193

194-
let new1 = fs::read_to_string(&path1).unwrap();
194+
let new1 = fs::read_to_string(path1).unwrap();
195195
assert_eq!(new1, expected);
196-
let new2 = fs::read_to_string(&path2).unwrap();
196+
let new2 = fs::read_to_string(path2).unwrap();
197197
assert_eq!(new2, expected);
198198
}
199199
});
@@ -221,7 +221,7 @@ export PATH="$HOME/apple/bin"
221221
expect_ok(config, &["rustup", "self", "uninstall", "-y"]);
222222

223223
for rc in &rcs {
224-
let new_rc = fs::read_to_string(&rc).unwrap();
224+
let new_rc = fs::read_to_string(rc).unwrap();
225225
assert_eq!(new_rc, FAKE_RC);
226226
}
227227
})
@@ -255,11 +255,11 @@ export PATH="$HOME/apple/bin"
255255
assert!(cmd.output().unwrap().status.success());
256256
let fixed_rc = FAKE_RC.to_owned() + &source("$HOME/.cargo", POSIX_SH);
257257
for rc in &rcs {
258-
let new_rc = fs::read_to_string(&rc).unwrap();
258+
let new_rc = fs::read_to_string(rc).unwrap();
259259
assert_eq!(new_rc, fixed_rc);
260260
}
261261
for rc in &zprofiles {
262-
let new_rc = fs::read_to_string(&rc).unwrap();
262+
let new_rc = fs::read_to_string(rc).unwrap();
263263
assert_eq!(new_rc, FAKE_RC);
264264
}
265265
})
@@ -291,14 +291,14 @@ export PATH="$HOME/apple/bin"
291291
raw::write_file(rc, &old_rc).unwrap();
292292
}
293293

294-
let mut cmd = clitools::cmd(config, "rustup", &["self", "uninstall", "-y"]);
294+
let mut cmd = clitools::cmd(config, "rustup", ["self", "uninstall", "-y"]);
295295
cmd.env("SHELL", "zsh");
296296
cmd.env("ZDOTDIR", zdotdir.path());
297297
cmd.env_remove("CARGO_HOME");
298298
assert!(cmd.output().unwrap().status.success());
299299

300300
for rc in &rcs {
301-
let new_rc = fs::read_to_string(&rc).unwrap();
301+
let new_rc = fs::read_to_string(rc).unwrap();
302302
// It's not ideal, but it's OK, if we leave whitespace.
303303
assert_eq!(new_rc, FAKE_RC);
304304
}
@@ -324,7 +324,7 @@ export PATH="$HOME/apple/bin"
324324
let expected = format!("{}. \"$HOME/.cargo/env\"\n", FAKE_RC);
325325
assert_eq!(new_profile, expected);
326326

327-
let mut cmd = clitools::cmd(config, "rustup", &["self", "uninstall", "-y"]);
327+
let mut cmd = clitools::cmd(config, "rustup", ["self", "uninstall", "-y"]);
328328
cmd.env_remove("CARGO_HOME");
329329
assert!(cmd.output().unwrap().status.success());
330330

tests/cli-rustup.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ fn show_toolchain_toolchain_file_override_not_installed() {
947947

948948
// I'm not sure this should really be erroring when the toolchain
949949
// is not installed; just capturing the behavior.
950-
let mut cmd = clitools::cmd(config, "rustup", &["show"]);
950+
let mut cmd = clitools::cmd(config, "rustup", ["show"]);
951951
clitools::env(config, &mut cmd);
952952
let out = cmd.output().unwrap();
953953
assert!(!out.status.success());
@@ -965,7 +965,7 @@ fn show_toolchain_override_not_installed() {
965965
setup(&|config| {
966966
expect_ok(config, &["rustup", "override", "add", "nightly"]);
967967
expect_ok(config, &["rustup", "toolchain", "remove", "nightly"]);
968-
let mut cmd = clitools::cmd(config, "rustup", &["show"]);
968+
let mut cmd = clitools::cmd(config, "rustup", ["show"]);
969969
clitools::env(config, &mut cmd);
970970
let out = cmd.output().unwrap();
971971
assert!(out.status.success());
@@ -1015,7 +1015,7 @@ fn override_set_unset_with_path() {
10151015
fn show_toolchain_env() {
10161016
setup(&|config| {
10171017
expect_ok(config, &["rustup", "default", "nightly"]);
1018-
let mut cmd = clitools::cmd(config, "rustup", &["show"]);
1018+
let mut cmd = clitools::cmd(config, "rustup", ["show"]);
10191019
clitools::env(config, &mut cmd);
10201020
cmd.env("RUSTUP_TOOLCHAIN", "nightly");
10211021
let out = cmd.output().unwrap();
@@ -1039,7 +1039,7 @@ nightly-{0} (environment override by RUSTUP_TOOLCHAIN)
10391039
#[test]
10401040
fn show_toolchain_env_not_installed() {
10411041
setup(&|config| {
1042-
let mut cmd = clitools::cmd(config, "rustup", &["show"]);
1042+
let mut cmd = clitools::cmd(config, "rustup", ["show"]);
10431043
clitools::env(config, &mut cmd);
10441044
cmd.env("RUSTUP_TOOLCHAIN", "nightly");
10451045
let out = cmd.output().unwrap();
@@ -1197,7 +1197,7 @@ fn update_doesnt_update_non_tracking_channels() {
11971197
setup(&|config| {
11981198
expect_ok(config, &["rustup", "default", "nightly"]);
11991199
expect_ok(config, &["rustup", "update", "nightly-2015-01-01"]);
1200-
let mut cmd = clitools::cmd(config, "rustup", &["update"]);
1200+
let mut cmd = clitools::cmd(config, "rustup", ["update"]);
12011201
clitools::env(config, &mut cmd);
12021202
let out = cmd.output().unwrap();
12031203
let stderr = String::from_utf8(out.stderr).unwrap();
@@ -1261,7 +1261,7 @@ fn toolchain_update_is_like_update() {
12611261
fn toolchain_uninstall_is_like_uninstall() {
12621262
setup(&|config| {
12631263
expect_ok(config, &["rustup", "uninstall", "nightly"]);
1264-
let mut cmd = clitools::cmd(config, "rustup", &["show"]);
1264+
let mut cmd = clitools::cmd(config, "rustup", ["show"]);
12651265
clitools::env(config, &mut cmd);
12661266
let out = cmd.output().unwrap();
12671267
assert!(out.status.success());
@@ -1324,7 +1324,7 @@ fn remove_component() {
13241324
));
13251325
assert!(config.rustupdir.has(&path));
13261326
expect_ok(config, &["rustup", "component", "remove", "rust-src"]);
1327-
assert!(!config.rustupdir.has(&path.parent().unwrap()));
1327+
assert!(!config.rustupdir.has(path.parent().unwrap()));
13281328
});
13291329
}
13301330

@@ -1355,7 +1355,7 @@ fn add_remove_multiple_components() {
13551355
this_host_triple(),
13561356
file
13571357
));
1358-
assert!(!config.rustupdir.has(&path.parent().unwrap()));
1358+
assert!(!config.rustupdir.has(path.parent().unwrap()));
13591359
}
13601360
});
13611361
}
@@ -1387,7 +1387,7 @@ fn env_override_path() {
13871387
.join("toolchains")
13881388
.join(format!("nightly-{}", this_host_triple()));
13891389

1390-
let mut cmd = clitools::cmd(config, "rustc", &["--version"]);
1390+
let mut cmd = clitools::cmd(config, "rustc", ["--version"]);
13911391
clitools::env(config, &mut cmd);
13921392
cmd.env("RUSTUP_TOOLCHAIN", toolchain_path.to_str().unwrap());
13931393

@@ -1871,7 +1871,7 @@ fn env_override_beats_file_override() {
18711871
let toolchain_file = cwd.join("rust-toolchain");
18721872
raw::write_file(&toolchain_file, "nightly").unwrap();
18731873

1874-
let mut cmd = clitools::cmd(config, "rustc", &["--version"]);
1874+
let mut cmd = clitools::cmd(config, "rustc", ["--version"]);
18751875
clitools::env(config, &mut cmd);
18761876
cmd.env("RUSTUP_TOOLCHAIN", "beta");
18771877

@@ -1963,7 +1963,7 @@ fn docs_with_path() {
19631963
expect_ok(config, &["rustup", "default", "stable"]);
19641964
expect_ok(config, &["rustup", "toolchain", "install", "nightly"]);
19651965

1966-
let mut cmd = clitools::cmd(config, "rustup", &["doc", "--path"]);
1966+
let mut cmd = clitools::cmd(config, "rustup", ["doc", "--path"]);
19671967
clitools::env(config, &mut cmd);
19681968

19691969
let out = cmd.output().unwrap();
@@ -1973,7 +1973,7 @@ fn docs_with_path() {
19731973
let mut cmd = clitools::cmd(
19741974
config,
19751975
"rustup",
1976-
&["doc", "--path", "--toolchain", "nightly"],
1976+
["doc", "--path", "--toolchain", "nightly"],
19771977
);
19781978
clitools::env(config, &mut cmd);
19791979

@@ -1989,7 +1989,7 @@ fn docs_topical_with_path() {
19891989
expect_ok(config, &["rustup", "toolchain", "install", "nightly"]);
19901990

19911991
for (topic, path) in mock::topical_doc_data::test_cases() {
1992-
let mut cmd = clitools::cmd(config, "rustup", &["doc", "--path", topic]);
1992+
let mut cmd = clitools::cmd(config, "rustup", ["doc", "--path", topic]);
19931993
clitools::env(config, &mut cmd);
19941994

19951995
let out = cmd.output().unwrap();
@@ -2143,7 +2143,7 @@ fn check_unix_settings_fallback() {
21432143
)
21442144
.unwrap();
21452145

2146-
let mut cmd = clitools::cmd(config, "rustup", &["default"]);
2146+
let mut cmd = clitools::cmd(config, "rustup", ["default"]);
21472147
clitools::env(config, &mut cmd);
21482148

21492149
// Override the path to the fallback settings file to be the mock file
@@ -2191,7 +2191,7 @@ fn dont_warn_on_partial_build() {
21912191
let mut cmd = clitools::cmd(
21922192
config,
21932193
"rustup",
2194-
&["toolchain", "install", &format!("nightly-{}", arch)],
2194+
["toolchain", "install", &format!("nightly-{}", arch)],
21952195
);
21962196
clitools::env(config, &mut cmd);
21972197
let out = cmd.output().unwrap();

0 commit comments

Comments
 (0)