Skip to content

Commit abc8463

Browse files
committed
Auto merge of #7911 - aleksator:run_through_clippy, r=ehuss
Clean up code mostly based on clippy suggestions
2 parents f0a7bf7 + 2b1dc3e commit abc8463

28 files changed

+52
-85
lines changed

crates/cargo-platform/src/lib.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,14 @@ impl Platform {
8484
)),
8585
_ => (),
8686
},
87-
Cfg::KeyPair(name, _) => match name.as_str() {
88-
"feature" =>
89-
warnings.push(String::from(
90-
"Found `feature = ...` in `target.'cfg(...)'.dependencies`. \
91-
This key is not supported for selecting dependencies \
92-
and will not work as expected. \
93-
Use the [features] section instead: \
94-
https://doc.rust-lang.org/cargo/reference/features.html"
95-
)),
96-
_ => (),
87+
Cfg::KeyPair(name, _) => if name.as_str() == "feature" {
88+
warnings.push(String::from(
89+
"Found `feature = ...` in `target.'cfg(...)'.dependencies`. \
90+
This key is not supported for selecting dependencies \
91+
and will not work as expected. \
92+
Use the [features] section instead: \
93+
https://doc.rust-lang.org/cargo/reference/features.html"
94+
))
9795
},
9896
}
9997
}

crates/crates-io/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use anyhow::{bail, Result};
1111
use curl::easy::{Easy, List};
1212
use percent_encoding::{percent_encode, NON_ALPHANUMERIC};
1313
use serde::{Deserialize, Serialize};
14-
use serde_json;
1514
use url::Url;
1615

1716
pub struct Registry {

src/bin/cargo/cli.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
1-
use clap;
2-
3-
use clap::{AppSettings, Arg, ArgMatches};
4-
51
use cargo::core::features;
62
use cargo::{self, CliResult, Config};
3+
use clap::{AppSettings, Arg, ArgMatches};
74

85
use super::commands;
96
use super::list_commands;
@@ -155,7 +152,7 @@ fn expand_aliases(
155152
// capture those global options now.
156153
// Note that an alias to an external command will not receive
157154
// these arguments. That may be confusing, but such is life.
158-
let global_args = GlobalArgs::new(&args);
155+
let global_args = GlobalArgs::new(args);
159156
let new_args = cli()
160157
.setting(AppSettings::NoBinaryName)
161158
.get_matches_from_safe(alias)?;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
271271

272272
let file_type = file_types
273273
.iter()
274-
.filter(|file_type| file_type.flavor == FileFlavor::Normal)
275-
.next()
274+
.find(|file_type| file_type.flavor == FileFlavor::Normal)
276275
.expect("target must support `bin`");
277276

278277
Ok(dest.join(file_type.filename(target.name())))

src/cargo/core/compiler/unit_dependencies.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,10 +267,7 @@ fn compute_deps<'a, 'cfg>(
267267
// If this is an optional dependency, and the new feature resolver
268268
// did not enable it, don't include it.
269269
if dep.is_optional() {
270-
let features_for = match unit_for.is_for_build_dep() {
271-
true => FeaturesFor::BuildDep,
272-
false => FeaturesFor::NormalOrDev,
273-
};
270+
let features_for = unit_for.map_to_features_for();
274271

275272
let feats = state.activated_features(id, features_for);
276273
if !feats.contains(&dep.name_in_toml()) {
@@ -627,10 +624,7 @@ fn new_unit_dep_with_profile<'a>(
627624
let public = state
628625
.resolve()
629626
.is_public_dep(parent.pkg.package_id(), pkg.package_id());
630-
let features_for = match unit_for.is_for_build_dep() {
631-
true => FeaturesFor::BuildDep,
632-
false => FeaturesFor::NormalOrDev,
633-
};
627+
let features_for = unit_for.map_to_features_for();
634628
let features = state.activated_features(pkg.package_id(), features_for);
635629
let unit = state
636630
.bcx

src/cargo/core/package_id.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use std::path::Path;
66
use std::ptr;
77
use std::sync::Mutex;
88

9-
use semver;
109
use serde::de;
1110
use serde::ser;
1211

src/cargo/core/profiles.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::core::compiler::CompileMode;
22
use crate::core::interning::InternedString;
3+
use crate::core::resolver::features::FeaturesFor;
34
use crate::core::{Feature, Features, PackageId, PackageIdSpec, Resolve, Shell};
45
use crate::util::errors::CargoResultExt;
56
use crate::util::toml::{ProfilePackageSpec, StringOrBool, TomlProfile, TomlProfiles, U32OrBool};
@@ -975,6 +976,14 @@ impl UnitFor {
975976
];
976977
ALL
977978
}
979+
980+
pub(crate) fn map_to_features_for(&self) -> FeaturesFor {
981+
if self.is_for_build_dep() {
982+
FeaturesFor::BuildDep
983+
} else {
984+
FeaturesFor::NormalOrDev
985+
}
986+
}
978987
}
979988

980989
/// Takes the manifest profiles, and overlays the config profiles on-top.

src/cargo/core/resolver/errors.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use crate::core::{Dependency, PackageId, Registry, Summary};
44
use crate::util::lev_distance::lev_distance;
55
use crate::util::Config;
66
use anyhow::Error;
7-
use semver;
87

98
use super::context::Context;
109
use super::types::{ConflictMap, ConflictReason};

src/cargo/core/resolver/resolve.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@ impl PartialEq for Resolve {
385385
fn eq(&self, other: &Resolve) -> bool {
386386
macro_rules! compare {
387387
($($fields:ident)* | $($ignored:ident)*) => {
388-
let Resolve { $($fields,)* $($ignored,)* } = self;
389-
$(drop($ignored);)*
388+
let Resolve { $($fields,)* $($ignored: _,)* } = self;
390389
$($fields == &other.$fields)&&*
391390
}
392391
}

src/cargo/core/resolver/types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::core::interning::InternedString;
33
use crate::core::{Dependency, PackageId, Summary};
44
use crate::util::errors::CargoResult;
55
use crate::util::Config;
6-
use im_rc;
76
use std::cmp::Ordering;
87
use std::collections::{BTreeMap, BTreeSet};
98
use std::ops::Range;

0 commit comments

Comments
 (0)