mirror of
https://github.com/rust-lang/cargo
synced 2024-10-05 23:39:47 +00:00
Run through nightly clippy
This commit is contained in:
parent
45ad3f9986
commit
2b1dc3e518
|
@ -84,16 +84,14 @@ impl Platform {
|
|||
)),
|
||||
_ => (),
|
||||
},
|
||||
Cfg::KeyPair(name, _) => match name.as_str() {
|
||||
"feature" =>
|
||||
warnings.push(String::from(
|
||||
"Found `feature = ...` in `target.'cfg(...)'.dependencies`. \
|
||||
This key is not supported for selecting dependencies \
|
||||
and will not work as expected. \
|
||||
Use the [features] section instead: \
|
||||
https://doc.rust-lang.org/cargo/reference/features.html"
|
||||
)),
|
||||
_ => (),
|
||||
Cfg::KeyPair(name, _) => if name.as_str() == "feature" {
|
||||
warnings.push(String::from(
|
||||
"Found `feature = ...` in `target.'cfg(...)'.dependencies`. \
|
||||
This key is not supported for selecting dependencies \
|
||||
and will not work as expected. \
|
||||
Use the [features] section instead: \
|
||||
https://doc.rust-lang.org/cargo/reference/features.html"
|
||||
))
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -151,7 +151,7 @@ fn expand_aliases(
|
|||
// capture those global options now.
|
||||
// Note that an alias to an external command will not receive
|
||||
// these arguments. That may be confusing, but such is life.
|
||||
let global_args = GlobalArgs::new(&args);
|
||||
let global_args = GlobalArgs::new(args);
|
||||
let new_args = cli()
|
||||
.setting(AppSettings::NoBinaryName)
|
||||
.get_matches_from_safe(alias)?;
|
||||
|
|
|
@ -271,8 +271,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
|
|||
|
||||
let file_type = file_types
|
||||
.iter()
|
||||
.filter(|file_type| file_type.flavor == FileFlavor::Normal)
|
||||
.next()
|
||||
.find(|file_type| file_type.flavor == FileFlavor::Normal)
|
||||
.expect("target must support `bin`");
|
||||
|
||||
Ok(dest.join(file_type.filename(target.name())))
|
||||
|
|
|
@ -267,10 +267,7 @@ fn compute_deps<'a, 'cfg>(
|
|||
// If this is an optional dependency, and the new feature resolver
|
||||
// did not enable it, don't include it.
|
||||
if dep.is_optional() {
|
||||
let features_for = match unit_for.is_for_build_dep() {
|
||||
true => FeaturesFor::BuildDep,
|
||||
false => FeaturesFor::NormalOrDev,
|
||||
};
|
||||
let features_for = unit_for.map_to_features_for();
|
||||
|
||||
let feats = state.activated_features(id, features_for);
|
||||
if !feats.contains(&dep.name_in_toml()) {
|
||||
|
@ -627,10 +624,7 @@ fn new_unit_dep_with_profile<'a>(
|
|||
let public = state
|
||||
.resolve()
|
||||
.is_public_dep(parent.pkg.package_id(), pkg.package_id());
|
||||
let features_for = match unit_for.is_for_build_dep() {
|
||||
true => FeaturesFor::BuildDep,
|
||||
false => FeaturesFor::NormalOrDev,
|
||||
};
|
||||
let features_for = unit_for.map_to_features_for();
|
||||
let features = state.activated_features(pkg.package_id(), features_for);
|
||||
let unit = state
|
||||
.bcx
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::core::compiler::CompileMode;
|
||||
use crate::core::interning::InternedString;
|
||||
use crate::core::resolver::features::FeaturesFor;
|
||||
use crate::core::{Feature, Features, PackageId, PackageIdSpec, Resolve, Shell};
|
||||
use crate::util::errors::CargoResultExt;
|
||||
use crate::util::toml::{ProfilePackageSpec, StringOrBool, TomlProfile, TomlProfiles, U32OrBool};
|
||||
|
@ -975,6 +976,14 @@ impl UnitFor {
|
|||
];
|
||||
ALL
|
||||
}
|
||||
|
||||
pub(crate) fn map_to_features_for(&self) -> FeaturesFor {
|
||||
if self.is_for_build_dep() {
|
||||
FeaturesFor::BuildDep
|
||||
} else {
|
||||
FeaturesFor::NormalOrDev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Takes the manifest profiles, and overlays the config profiles on-top.
|
||||
|
|
|
@ -385,8 +385,7 @@ impl PartialEq for Resolve {
|
|||
fn eq(&self, other: &Resolve) -> bool {
|
||||
macro_rules! compare {
|
||||
($($fields:ident)* | $($ignored:ident)*) => {
|
||||
let Resolve { $($fields,)* $($ignored,)* } = self;
|
||||
$(drop($ignored);)*
|
||||
let Resolve { $($fields,)* $($ignored: _,)* } = self;
|
||||
$($fields == &other.$fields)&&*
|
||||
}
|
||||
}
|
||||
|
|
|
@ -884,7 +884,7 @@ impl<'cfg> Workspace<'cfg> {
|
|||
.map(|m| (m, RequestedFeatures::new_all(false)))
|
||||
.collect());
|
||||
}
|
||||
return Ok(members);
|
||||
Ok(members)
|
||||
} else {
|
||||
let ms = self.members().filter_map(|member| {
|
||||
let member_id = member.package_id();
|
||||
|
@ -911,7 +911,7 @@ impl<'cfg> Workspace<'cfg> {
|
|||
}
|
||||
}
|
||||
});
|
||||
return Ok(ms.collect());
|
||||
Ok(ms.collect())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,9 +7,7 @@ use crate::core::compiler::unit_dependencies;
|
|||
use crate::core::compiler::{BuildConfig, BuildContext, CompileKind, CompileMode, Context};
|
||||
use crate::core::compiler::{RustcTargetData, UnitInterner};
|
||||
use crate::core::profiles::{Profiles, UnitFor};
|
||||
use crate::core::resolver::features::{
|
||||
FeatureResolver, FeaturesFor, HasDevUnits, RequestedFeatures,
|
||||
};
|
||||
use crate::core::resolver::features::{FeatureResolver, HasDevUnits, RequestedFeatures};
|
||||
use crate::core::{PackageIdSpec, Workspace};
|
||||
use crate::ops;
|
||||
use crate::util::errors::{CargoResult, CargoResultExt};
|
||||
|
@ -120,10 +118,7 @@ pub fn clean(ws: &Workspace<'_>, opts: &CleanOptions<'_>) -> CargoResult<()> {
|
|||
};
|
||||
// Use unverified here since this is being more
|
||||
// exhaustive than what is actually needed.
|
||||
let features_for = match unit_for.is_for_build_dep() {
|
||||
true => FeaturesFor::BuildDep,
|
||||
false => FeaturesFor::NormalOrDev,
|
||||
};
|
||||
let features_for = unit_for.map_to_features_for();
|
||||
let features =
|
||||
features.activated_features_unverified(pkg.package_id(), features_for);
|
||||
units.push(bcx.units.intern(
|
||||
|
|
|
@ -312,9 +312,10 @@ pub fn compile_ws<'a>(
|
|||
let specs = spec.to_package_id_specs(ws)?;
|
||||
let dev_deps = ws.require_optional_deps() || filter.need_dev_deps(build_config.mode);
|
||||
let opts = ResolveOpts::new(dev_deps, features, all_features, !no_default_features);
|
||||
let has_dev_units = match filter.need_dev_deps(build_config.mode) {
|
||||
true => HasDevUnits::Yes,
|
||||
false => HasDevUnits::No,
|
||||
let has_dev_units = if filter.need_dev_deps(build_config.mode) {
|
||||
HasDevUnits::Yes
|
||||
} else {
|
||||
HasDevUnits::No
|
||||
};
|
||||
let resolve = ops::resolve_ws_with_opts(
|
||||
ws,
|
||||
|
@ -950,9 +951,10 @@ fn resolve_all_features(
|
|||
// required-features field when deciding whether to be built or skipped.
|
||||
for (dep_id, deps) in resolve_with_overrides.deps(package_id) {
|
||||
for dep in deps {
|
||||
let features_for = match dep.is_build() {
|
||||
true => FeaturesFor::BuildDep,
|
||||
false => FeaturesFor::NormalOrDev,
|
||||
let features_for = if dep.is_build() {
|
||||
FeaturesFor::BuildDep
|
||||
} else {
|
||||
FeaturesFor::NormalOrDev
|
||||
};
|
||||
for feature in resolved_features.activated_features(dep_id, features_for) {
|
||||
features.insert(dep.name_in_toml().to_string() + "/" + &feature);
|
||||
|
|
|
@ -172,7 +172,7 @@ fn build_resolve_graph_r(
|
|||
if node_map.contains_key(&pkg_id) {
|
||||
return;
|
||||
}
|
||||
let features = resolve.features(pkg_id).iter().cloned().collect();
|
||||
let features = resolve.features(pkg_id).to_vec();
|
||||
|
||||
let deps: Vec<Dep> = resolve
|
||||
.deps(pkg_id)
|
||||
|
|
|
@ -576,7 +576,7 @@ impl Config {
|
|||
/// Helper for StringList type to get something that is a string or list.
|
||||
fn get_list_or_string(&self, key: &ConfigKey) -> CargoResult<Vec<(String, Definition)>> {
|
||||
let mut res = Vec::new();
|
||||
match self.get_cv(&key)? {
|
||||
match self.get_cv(key)? {
|
||||
Some(CV::List(val, _def)) => res.extend(val),
|
||||
Some(CV::String(val, def)) => {
|
||||
let split_vs = val.split_whitespace().map(|s| (s.to_string(), def.clone()));
|
||||
|
|
|
@ -378,21 +378,19 @@ fn _link_or_copy(src: &Path, dst: &Path) -> CargoResult<()> {
|
|||
src
|
||||
};
|
||||
symlink(src, dst)
|
||||
} else if env::var_os("__CARGO_COPY_DONT_LINK_DO_NOT_USE_THIS").is_some() {
|
||||
// This is a work-around for a bug in macOS 10.15. When running on
|
||||
// APFS, there seems to be a strange race condition with
|
||||
// Gatekeeper where it will forcefully kill a process launched via
|
||||
// `cargo run` with SIGKILL. Copying seems to avoid the problem.
|
||||
// This shouldn't affect anyone except Cargo's test suite because
|
||||
// it is very rare, and only seems to happen under heavy load and
|
||||
// rapidly creating lots of executables and running them.
|
||||
// See https://github.com/rust-lang/cargo/issues/7821 for the
|
||||
// gory details.
|
||||
fs::copy(src, dst).map(|_| ())
|
||||
} else {
|
||||
if env::var_os("__CARGO_COPY_DONT_LINK_DO_NOT_USE_THIS").is_some() {
|
||||
// This is a work-around for a bug in macOS 10.15. When running on
|
||||
// APFS, there seems to be a strange race condition with
|
||||
// Gatekeeper where it will forcefully kill a process launched via
|
||||
// `cargo run` with SIGKILL. Copying seems to avoid the problem.
|
||||
// This shouldn't affect anyone except Cargo's test suite because
|
||||
// it is very rare, and only seems to happen under heavy load and
|
||||
// rapidly creating lots of executables and running them.
|
||||
// See https://github.com/rust-lang/cargo/issues/7821 for the
|
||||
// gory details.
|
||||
fs::copy(src, dst).map(|_| ())
|
||||
} else {
|
||||
fs::hard_link(src, dst)
|
||||
}
|
||||
fs::hard_link(src, dst)
|
||||
};
|
||||
link_result
|
||||
.or_else(|err| {
|
||||
|
|
|
@ -1137,7 +1137,7 @@ impl TomlManifest {
|
|||
.collect()
|
||||
})
|
||||
.unwrap_or_else(BTreeMap::new),
|
||||
project.links.as_ref().map(|x| x.as_str()),
|
||||
project.links.as_deref(),
|
||||
project.namespaced_features.unwrap_or(false),
|
||||
)?;
|
||||
let metadata = ManifestMetadata {
|
||||
|
|
Loading…
Reference in a new issue