Skip to content

Commit ea40fc4

Browse files
committed
some clippy things
1 parent 6562942 commit ea40fc4

File tree

6 files changed

+22
-35
lines changed

6 files changed

+22
-35
lines changed

src/cargo/core/compiler/fingerprint.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -478,9 +478,7 @@ enum LocalFingerprint {
478478
/// The `dep_info` file, when present, also lists a number of other files
479479
/// for us to look at. If any of those files are newer than this file then
480480
/// we need to recompile.
481-
CheckDepInfo {
482-
dep_info: PathBuf,
483-
},
481+
CheckDepInfo { dep_info: PathBuf },
484482

485483
/// This represents a nonempty set of `rerun-if-changed` annotations printed
486484
/// out by a build script. The `output` file is a arelative file anchored at
@@ -500,10 +498,7 @@ enum LocalFingerprint {
500498
/// build script. The exact env var and value are hashed here. There's no
501499
/// filesystem dependence here, and if the values are changed the hash will
502500
/// change forcing a recompile.
503-
RerunIfEnvChanged {
504-
var: String,
505-
val: Option<String>,
506-
},
501+
RerunIfEnvChanged { var: String, val: Option<String> },
507502
}
508503

509504
enum StaleFile {
@@ -762,7 +757,7 @@ impl Fingerprint {
762757
let t = FileTime::from_system_time(SystemTime::now());
763758
drop(filetime::set_file_times(f, t, t));
764759
}
765-
return mtime;
760+
mtime
766761
})
767762
.min();
768763

@@ -1350,7 +1345,7 @@ fn compare_old_fingerprint(
13501345
debug_assert_eq!(util::to_hex(old_fingerprint.hash()), old_fingerprint_short);
13511346
let result = new_fingerprint.compare(&old_fingerprint);
13521347
assert!(result.is_err());
1353-
return result;
1348+
result
13541349
}
13551350

13561351
fn log_compare(unit: &Unit<'_>, compare: &CargoResult<()>) {
@@ -1444,7 +1439,7 @@ where
14441439
});
14451440
}
14461441

1447-
return None;
1442+
None
14481443
}
14491444

14501445
fn filename<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> String {

src/cargo/core/resolver/conflict_cache.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ impl ConflictCache {
234234
/// all the `PackageId` entries are activated.
235235
pub fn contains(&self, dep: &Dependency, con: &ConflictMap) -> bool {
236236
if let Some(cst) = self.con_from_dep.get(dep) {
237-
cst.contains(con.keys().cloned(), &con)
237+
cst.contains(con.keys().cloned(), con)
238238
} else {
239239
false
240240
}

src/cargo/core/resolver/context.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ impl From<&semver::Version> for SemverCompatibility {
7777
}
7878

7979
impl PackageId {
80-
pub fn as_activations_key(&self) -> (InternedString, SourceId, SemverCompatibility) {
80+
pub fn as_activations_key(self) -> (InternedString, SourceId, SemverCompatibility) {
8181
(self.name(), self.source_id(), self.version().into())
8282
}
8383
}
@@ -304,17 +304,12 @@ impl Context {
304304

305305
// Record what list of features is active for this package.
306306
if !reqs.used.is_empty() {
307-
let pkgid = s.package_id();
308-
309-
let set = Rc::make_mut(
307+
Rc::make_mut(
310308
self.resolve_features
311-
.entry(pkgid)
312-
.or_insert_with(|| Rc::new(HashSet::new())),
313-
);
314-
315-
for feature in reqs.used {
316-
set.insert(feature);
317-
}
309+
.entry(s.package_id())
310+
.or_insert_with(|| Rc::new(HashSet::with_capacity(reqs.used.len()))),
311+
)
312+
.extend(reqs.used);
318313
}
319314

320315
Ok(ret)
@@ -411,7 +406,7 @@ struct Requirements<'a> {
411406
visited: HashSet<InternedString>,
412407
}
413408

414-
impl<'r> Requirements<'r> {
409+
impl Requirements<'_> {
415410
fn new(summary: &Summary) -> Requirements<'_> {
416411
Requirements {
417412
summary,
@@ -468,7 +463,7 @@ impl<'r> Requirements<'r> {
468463
Ok(())
469464
}
470465

471-
fn require_value<'f>(&mut self, fv: &'f FeatureValue) -> CargoResult<()> {
466+
fn require_value(&mut self, fv: &FeatureValue) -> CargoResult<()> {
472467
match fv {
473468
FeatureValue::Feature(feat) => self.require_feature(*feat)?,
474469
FeatureValue::Crate(dep) => self.require_dependency(*dep),

src/cargo/core/resolver/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -883,7 +883,7 @@ fn generalize_conflicting(
883883
// Thus, if all the things it can resolve to have already ben determined
884884
// to be conflicting, then we can just say that we conflict with the parent.
885885
if registry
886-
.query(&critical_parents_dep)
886+
.query(critical_parents_dep)
887887
.expect("an already used dep now error!?")
888888
.iter()
889889
.rev() // the last one to be tried is the least likely to be in the cache, so start with that.
@@ -894,13 +894,13 @@ fn generalize_conflicting(
894894
other.summary.package_id(),
895895
backtrack_critical_reason.clone(),
896896
);
897-
past_conflicting_activations.contains(&dep, &con)
897+
past_conflicting_activations.contains(dep, &con)
898898
})
899899
{
900900
let mut con = conflicting_activations.clone();
901901
con.remove(&backtrack_critical_id);
902902
con.insert(*critical_parent, backtrack_critical_reason);
903-
past_conflicting_activations.insert(&dep, &con);
903+
past_conflicting_activations.insert(dep, &con);
904904
return Some(con);
905905
}
906906
}

src/cargo/ops/cargo_install.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -461,10 +461,7 @@ fn install_one(
461461
let mut pkg_map = BTreeMap::new();
462462
for (bin_name, opt_pkg_id) in &duplicates {
463463
let key = opt_pkg_id.map_or_else(|| "unknown".to_string(), |pkg_id| pkg_id.to_string());
464-
pkg_map
465-
.entry(key)
466-
.or_insert_with(|| Vec::new())
467-
.push(bin_name);
464+
pkg_map.entry(key).or_insert_with(Vec::new).push(bin_name);
468465
}
469466
for (pkg_descr, bin_names) in &pkg_map {
470467
config.shell().status(

src/cargo/sources/registry/index.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,10 +269,10 @@ impl<'cfg> RegistryIndex<'cfg> {
269269
yanked_whitelist: &HashSet<PackageId>,
270270
f: &mut dyn FnMut(Summary),
271271
) -> CargoResult<()> {
272-
if self.config.cli_unstable().offline {
273-
if self.query_inner_with_online(dep, load, yanked_whitelist, f, false)? != 0 {
274-
return Ok(());
275-
}
272+
if self.config.cli_unstable().offline
273+
&& self.query_inner_with_online(dep, load, yanked_whitelist, f, false)? != 0
274+
{
275+
return Ok(());
276276
// If offline, and there are no matches, try again with online.
277277
// This is necessary for dependencies that are not used (such as
278278
// target-cfg or optional), but are not downloaded. Normally the

0 commit comments

Comments
 (0)