Skip to content

Commit ef0b477

Browse files
committed
Cleanup: Remove unnecessary borrows.
1 parent a57b96d commit ef0b477

28 files changed

+110
-107
lines changed

src/bin/cargo/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
4747
return Ok(());
4848
}
4949

50-
if let Some(ref code) = args.value_of("explain") {
50+
if let Some(code) = args.value_of("explain") {
5151
let mut procss = config.rustc(None)?.process();
5252
procss.arg("--explain").arg(code).exec()?;
5353
return Ok(());

src/bin/cargo/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#![warn(rust_2018_idioms)] // while we're getting used to 2018
22
#![allow(clippy::too_many_arguments)] // large project
33
#![allow(clippy::redundant_closure)] // there's a false positive
4+
#![warn(clippy::needless_borrow)]
45

56
use std::collections::BTreeSet;
67
use std::env;

src/cargo/core/compiler/build_plan.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl BuildPlan {
113113
let id = self.plan.invocations.len();
114114
self.invocation_map.insert(unit.buildkey(), id);
115115
let deps = cx
116-
.dep_targets(&unit)
116+
.dep_targets(unit)
117117
.iter()
118118
.map(|dep| self.invocation_map[&dep.buildkey()])
119119
.collect();

src/cargo/core/compiler/compilation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ impl<'cfg> Compilation<'cfg> {
120120
rustc_process: rustc,
121121
host: bcx.host_triple().to_string(),
122122
target: bcx.target_triple().to_string(),
123-
target_runner: target_runner(&bcx)?,
123+
target_runner: target_runner(bcx)?,
124124
})
125125
}
126126

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ fn compute_metadata<'a, 'cfg>(
491491
// settings like debuginfo and whatnot.
492492
unit.profile.hash(&mut hasher);
493493
unit.mode.hash(&mut hasher);
494-
if let Some(ref args) = bcx.extra_args_for(unit) {
494+
if let Some(args) = bcx.extra_args_for(unit) {
495495
args.hash(&mut hasher);
496496
}
497497

src/cargo/core/compiler/context/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,11 +474,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
474474
for unit in keys {
475475
for output in self.outputs(unit)?.iter() {
476476
if let Some(other_unit) = output_collisions.insert(output.path.clone(), unit) {
477-
report_collision(unit, &other_unit, &output.path)?;
477+
report_collision(unit, other_unit, &output.path)?;
478478
}
479479
if let Some(hardlink) = output.hardlink.as_ref() {
480480
if let Some(other_unit) = output_collisions.insert(hardlink.clone(), unit) {
481-
report_collision(unit, &other_unit, hardlink)?;
481+
report_collision(unit, other_unit, hardlink)?;
482482
}
483483
}
484484
if let Some(ref export_path) = output.export_path {
@@ -488,7 +488,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
488488
{}\
489489
The exported filenames should be unique.\n\
490490
{}",
491-
describe_collision(unit, &other_unit, &export_path),
491+
describe_collision(unit, other_unit, export_path),
492492
suggestion
493493
))?;
494494
}

src/cargo/core/compiler/custom_build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
160160
.env(
161161
"TARGET",
162162
&match unit.kind {
163-
Kind::Host => &bcx.host_triple(),
163+
Kind::Host => bcx.host_triple(),
164164
Kind::Target => bcx.target_triple(),
165165
},
166166
)

src/cargo/core/compiler/fingerprint.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ fn calculate<'a, 'cfg>(
682682
local.extend(local_fingerprint_run_custom_build_deps(cx, unit));
683683
local
684684
} else {
685-
let fingerprint = pkg_fingerprint(&cx.bcx, unit.pkg)?;
685+
let fingerprint = pkg_fingerprint(cx.bcx, unit.pkg)?;
686686
vec![LocalFingerprint::Precalculated(fingerprint)]
687687
};
688688

@@ -701,7 +701,7 @@ fn calculate<'a, 'cfg>(
701701
profile: profile_hash,
702702
// Note that .0 is hashed here, not .1 which is the cwd. That doesn't
703703
// actually affect the output artifact so there's no need to hash it.
704-
path: util::hash_u64(&super::path_args(&cx.bcx, unit).0),
704+
path: util::hash_u64(&super::path_args(cx.bcx, unit).0),
705705
features: format!("{:?}", bcx.resolve.features_sorted(unit.pkg.package_id())),
706706
deps,
707707
local,
@@ -855,7 +855,7 @@ fn build_script_local_fingerprints<'a, 'cfg>(
855855
let output = deps.build_script_output.clone();
856856
if deps.rerun_if_changed.is_empty() && deps.rerun_if_env_changed.is_empty() {
857857
debug!("old local fingerprints deps");
858-
let s = pkg_fingerprint(&cx.bcx, unit.pkg)?;
858+
let s = pkg_fingerprint(cx.bcx, unit.pkg)?;
859859
return Ok((vec![LocalFingerprint::Precalculated(s)], Some(output)));
860860
}
861861

src/cargo/core/compiler/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
631631

632632
add_error_format(bcx, &mut rustdoc);
633633

634-
if let Some(ref args) = bcx.extra_args_for(unit) {
634+
if let Some(args) = bcx.extra_args_for(unit) {
635635
rustdoc.args(args);
636636
}
637637

@@ -822,7 +822,7 @@ fn build_base_args<'a, 'cfg>(
822822
cmd.arg("-C").arg(format!("debuginfo={}", debuginfo));
823823
}
824824

825-
if let Some(ref args) = bcx.extra_args_for(unit) {
825+
if let Some(args) = bcx.extra_args_for(unit) {
826826
cmd.args(args);
827827
}
828828

src/cargo/core/package.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl ser::Serialize for Package {
105105

106106
SerializedPackage {
107107
name: &*package_id.name(),
108-
version: &package_id.version(),
108+
version: package_id.version(),
109109
id: package_id,
110110
license,
111111
license_file,
@@ -740,7 +740,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> {
740740
self.set.multi.messages(|msg| {
741741
let token = msg.token().expect("failed to read token");
742742
let handle = &pending[&token].1;
743-
if let Some(result) = msg.result_for(&handle) {
743+
if let Some(result) = msg.result_for(handle) {
744744
results.push((token, result));
745745
} else {
746746
debug!("message without a result (?)");

0 commit comments

Comments
 (0)