mirror of
https://github.com/rust-lang/cargo
synced 2024-10-13 19:22:33 +00:00
Rename "explicit" to "crate_prefix".
This commit is contained in:
parent
c8a3db8e8f
commit
8ff130bb28
|
@ -374,7 +374,7 @@ fn build_requirements<'a, 'b: 'a>(
|
|||
} else {
|
||||
for &f in opts.features.features.iter() {
|
||||
let fv = FeatureValue::new(f);
|
||||
if fv.is_explicit_crate() {
|
||||
if fv.has_crate_prefix() {
|
||||
return Err(ActivateError::Fatal(anyhow::format_err!(
|
||||
"feature value `{}` is not allowed to use explicit `crate:` syntax",
|
||||
fv
|
||||
|
@ -442,12 +442,12 @@ impl Requirements<'_> {
|
|||
&mut self,
|
||||
package: InternedString,
|
||||
feat: InternedString,
|
||||
explicit: bool,
|
||||
crate_prefix: bool,
|
||||
) -> Result<(), RequirementError> {
|
||||
// If `package` is indeed an optional dependency then we activate the
|
||||
// feature named `package`, but otherwise if `package` is a required
|
||||
// dependency then there's no feature associated with it.
|
||||
if !explicit
|
||||
if !crate_prefix
|
||||
&& self
|
||||
.summary
|
||||
.dependencies()
|
||||
|
@ -493,8 +493,8 @@ impl Requirements<'_> {
|
|||
FeatureValue::CrateFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
explicit,
|
||||
} => self.require_crate_feature(*dep_name, *dep_feature, *explicit)?,
|
||||
crate_prefix,
|
||||
} => self.require_crate_feature(*dep_name, *dep_feature, *crate_prefix)?,
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -463,7 +463,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
|
|||
FeatureValue::CrateFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
explicit,
|
||||
crate_prefix,
|
||||
} => {
|
||||
// Activate a feature within a dependency.
|
||||
for (dep_pkg_id, deps) in self.deps(pkg_id, for_host) {
|
||||
|
@ -477,7 +477,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
|
|||
dep_name: *dep_name,
|
||||
};
|
||||
self.activate_fv(pkg_id, &fv, for_host)?;
|
||||
if !explicit {
|
||||
if !crate_prefix {
|
||||
// To retain compatibility with old behavior,
|
||||
// this also enables a feature of the same
|
||||
// name.
|
||||
|
|
|
@ -183,7 +183,7 @@ fn build_feature_map(
|
|||
(*feature, fvs)
|
||||
})
|
||||
.collect();
|
||||
let has_namespaced_features = map.values().flatten().any(|fv| fv.is_explicit_crate());
|
||||
let has_namespaced_features = map.values().flatten().any(|fv| fv.has_crate_prefix());
|
||||
|
||||
// Add implicit features for optional dependencies if they weren't
|
||||
// explicitly listed anywhere.
|
||||
|
@ -194,7 +194,7 @@ fn build_feature_map(
|
|||
Crate { dep_name }
|
||||
| CrateFeature {
|
||||
dep_name,
|
||||
explicit: true,
|
||||
crate_prefix: true,
|
||||
..
|
||||
} => Some(*dep_name),
|
||||
_ => None,
|
||||
|
@ -340,7 +340,7 @@ pub enum FeatureValue {
|
|||
dep_feature: InternedString,
|
||||
/// If this is true, then the feature used the `crate:` prefix, which
|
||||
/// prevents enabling the feature named `dep_name`.
|
||||
explicit: bool,
|
||||
crate_prefix: bool,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -350,7 +350,7 @@ impl FeatureValue {
|
|||
Some(pos) => {
|
||||
let (dep, dep_feat) = feature.split_at(pos);
|
||||
let dep_feat = &dep_feat[1..];
|
||||
let (dep, explicit) = if let Some(dep) = dep.strip_prefix("crate:") {
|
||||
let (dep, crate_prefix) = if let Some(dep) = dep.strip_prefix("crate:") {
|
||||
(dep, true)
|
||||
} else {
|
||||
(dep, false)
|
||||
|
@ -358,7 +358,7 @@ impl FeatureValue {
|
|||
FeatureValue::CrateFeature {
|
||||
dep_name: InternedString::new(dep),
|
||||
dep_feature: InternedString::new(dep_feat),
|
||||
explicit,
|
||||
crate_prefix,
|
||||
}
|
||||
}
|
||||
None if feature.starts_with("crate:") => FeatureValue::Crate {
|
||||
|
@ -369,8 +369,8 @@ impl FeatureValue {
|
|||
}
|
||||
|
||||
/// Returns `true` if this feature explicitly used `crate:` syntax.
|
||||
pub fn is_explicit_crate(&self) -> bool {
|
||||
matches!(self, FeatureValue::Crate{..} | FeatureValue::CrateFeature{explicit:true, ..})
|
||||
pub fn has_crate_prefix(&self) -> bool {
|
||||
matches!(self, FeatureValue::Crate{..} | FeatureValue::CrateFeature{crate_prefix:true, ..})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -383,12 +383,12 @@ impl fmt::Display for FeatureValue {
|
|||
CrateFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
explicit: true,
|
||||
crate_prefix: true,
|
||||
} => write!(f, "crate:{}/{}", dep_name, dep_feature),
|
||||
CrateFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
explicit: false,
|
||||
crate_prefix: false,
|
||||
} => write!(f, "{}/{}", dep_name, dep_feature),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1071,10 +1071,13 @@ fn validate_required_features(
|
|||
))?;
|
||||
}
|
||||
}
|
||||
FeatureValue::Crate { .. } | FeatureValue::CrateFeature { explicit: true, .. } => {
|
||||
FeatureValue::Crate { .. }
|
||||
| FeatureValue::CrateFeature {
|
||||
crate_prefix: true, ..
|
||||
} => {
|
||||
anyhow::bail!(
|
||||
"invalid feature `{}` in required-features of target `{}`: \
|
||||
explicit `crate:` feature values are not allowed in required-features",
|
||||
`crate:` prefixed feature values are not allowed in required-features",
|
||||
fv,
|
||||
target_name
|
||||
);
|
||||
|
@ -1083,7 +1086,7 @@ fn validate_required_features(
|
|||
FeatureValue::CrateFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
explicit: false,
|
||||
crate_prefix: false,
|
||||
} => {
|
||||
match resolve
|
||||
.deps(summary.package_id())
|
||||
|
|
|
@ -567,7 +567,7 @@ fn add_feature_rec(
|
|||
FeatureValue::CrateFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
explicit,
|
||||
crate_prefix,
|
||||
} => {
|
||||
let dep_indexes = match graph.dep_name_map[&package_index].get(dep_name) {
|
||||
Some(indexes) => indexes.clone(),
|
||||
|
@ -585,7 +585,7 @@ fn add_feature_rec(
|
|||
};
|
||||
for (dep_index, is_optional) in dep_indexes {
|
||||
let dep_pkg_id = graph.package_id_for_index(dep_index);
|
||||
if is_optional && !explicit {
|
||||
if is_optional && !crate_prefix {
|
||||
// Activate the optional dep on self.
|
||||
add_feature(
|
||||
graph,
|
||||
|
|
|
@ -701,7 +701,7 @@ fn crate_required_features() {
|
|||
"\
|
||||
[UPDATING] [..]
|
||||
[ERROR] invalid feature `crate:bar` in required-features of target `foo`: \
|
||||
explicit `crate:` feature values are not allowed in required-features
|
||||
`crate:` prefixed feature values are not allowed in required-features
|
||||
",
|
||||
)
|
||||
.run();
|
||||
|
|
Loading…
Reference in a new issue