mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
Rename crate: to dep:
This commit is contained in:
parent
8ff130bb28
commit
f4ac82a0f5
@ -42,7 +42,7 @@ Available unstable (nightly-only) flags:
|
||||
-Z timings -- Display concurrency information
|
||||
-Z doctest-xcompile -- Compile and run doctests for non-host target using runner config
|
||||
-Z terminal-width -- Provide a terminal width to rustc for error truncation
|
||||
-Z namespaced-features -- Allow features with `crate:` prefix
|
||||
-Z namespaced-features -- Allow features with `dep:` prefix
|
||||
|
||||
Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
|
||||
);
|
||||
|
@ -342,7 +342,7 @@ pub fn resolve_features<'b>(
|
||||
}
|
||||
|
||||
// This is a special case for command-line `--features
|
||||
// crate_name/feat_name` where `crate_name` does not exist. All other
|
||||
// dep_name/feat_name` where `dep_name` does not exist. All other
|
||||
// validation is done either in `build_requirements` or
|
||||
// `build_feature_map`.
|
||||
for dep_name in reqs.deps.keys() {
|
||||
@ -374,9 +374,9 @@ fn build_requirements<'a, 'b: 'a>(
|
||||
} else {
|
||||
for &f in opts.features.features.iter() {
|
||||
let fv = FeatureValue::new(f);
|
||||
if fv.has_crate_prefix() {
|
||||
if fv.has_dep_prefix() {
|
||||
return Err(ActivateError::Fatal(anyhow::format_err!(
|
||||
"feature value `{}` is not allowed to use explicit `crate:` syntax",
|
||||
"feature value `{}` is not allowed to use explicit `dep:` syntax",
|
||||
fv
|
||||
)));
|
||||
}
|
||||
@ -438,16 +438,16 @@ impl Requirements<'_> {
|
||||
self.features
|
||||
}
|
||||
|
||||
fn require_crate_feature(
|
||||
fn require_dep_feature(
|
||||
&mut self,
|
||||
package: InternedString,
|
||||
feat: InternedString,
|
||||
crate_prefix: bool,
|
||||
dep_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 !crate_prefix
|
||||
if !dep_prefix
|
||||
&& self
|
||||
.summary
|
||||
.dependencies()
|
||||
@ -489,12 +489,12 @@ impl Requirements<'_> {
|
||||
fn require_value(&mut self, fv: &FeatureValue) -> Result<(), RequirementError> {
|
||||
match fv {
|
||||
FeatureValue::Feature(feat) => self.require_feature(*feat)?,
|
||||
FeatureValue::Crate { dep_name } => self.require_dependency(*dep_name),
|
||||
FeatureValue::CrateFeature {
|
||||
FeatureValue::Dep { dep_name } => self.require_dependency(*dep_name),
|
||||
FeatureValue::DepFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
crate_prefix,
|
||||
} => self.require_crate_feature(*dep_name, *dep_feature, *crate_prefix)?,
|
||||
dep_prefix,
|
||||
} => self.require_dep_feature(*dep_name, *dep_feature, *dep_prefix)?,
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
@ -526,7 +526,7 @@ impl RequirementError {
|
||||
match parent {
|
||||
None => ActivateError::Fatal(anyhow::format_err!(
|
||||
"Package `{}` does not have feature `{}`. It has an optional dependency \
|
||||
with that name, but that dependency uses the \"crate:\" \
|
||||
with that name, but that dependency uses the \"dep:\" \
|
||||
syntax in the features table, so it does not have an implicit feature with that name.",
|
||||
summary.package_id(),
|
||||
feat
|
||||
@ -559,7 +559,7 @@ impl RequirementError {
|
||||
dep_name
|
||||
)),
|
||||
// This code path currently isn't used, since `foo/bar`
|
||||
// and `crate:` syntax is not allowed in a dependency.
|
||||
// and `dep:` syntax is not allowed in a dependency.
|
||||
Some(p) => ActivateError::Conflict(
|
||||
p,
|
||||
ConflictReason::MissingFeatures(dep_name.to_string()),
|
||||
|
@ -170,7 +170,7 @@ pub(super) fn activation_error(
|
||||
msg.push_str("` does not have these features.\n");
|
||||
msg.push_str(
|
||||
" It has an optional dependency with that name, \
|
||||
but but that dependency uses the \"crate:\" \
|
||||
but but that dependency uses the \"dep:\" \
|
||||
syntax in the features table, so it does not have an \
|
||||
implicit feature with that name.\n",
|
||||
);
|
||||
|
@ -412,7 +412,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
|
||||
// For example, consider we've already processed our dependencies,
|
||||
// and another package comes along and enables one of our optional
|
||||
// dependencies, it will do so immediately in the
|
||||
// `FeatureValue::CrateFeature` branch, and then immediately
|
||||
// `FeatureValue::DepFeature` branch, and then immediately
|
||||
// recurse into that optional dependency. This also holds true for
|
||||
// features that enable other features.
|
||||
return Ok(());
|
||||
@ -443,7 +443,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
|
||||
FeatureValue::Feature(f) => {
|
||||
self.activate_rec(pkg_id, *f, for_host)?;
|
||||
}
|
||||
FeatureValue::Crate { dep_name } => {
|
||||
FeatureValue::Dep { dep_name } => {
|
||||
// Mark this dependency as activated.
|
||||
self.activated_dependencies
|
||||
.entry((pkg_id, self.opts.decouple_host_deps && for_host))
|
||||
@ -460,10 +460,10 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
|
||||
}
|
||||
}
|
||||
}
|
||||
FeatureValue::CrateFeature {
|
||||
FeatureValue::DepFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
crate_prefix,
|
||||
dep_prefix,
|
||||
} => {
|
||||
// Activate a feature within a dependency.
|
||||
for (dep_pkg_id, deps) in self.deps(pkg_id, for_host) {
|
||||
@ -472,12 +472,12 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
|
||||
continue;
|
||||
}
|
||||
if dep.is_optional() {
|
||||
// Activate the crate on self.
|
||||
let fv = FeatureValue::Crate {
|
||||
// Activate the dependency on self.
|
||||
let fv = FeatureValue::Dep {
|
||||
dep_name: *dep_name,
|
||||
};
|
||||
self.activate_fv(pkg_id, &fv, for_host)?;
|
||||
if !crate_prefix {
|
||||
if !dep_prefix {
|
||||
// To retain compatibility with old behavior,
|
||||
// this also enables a feature of the same
|
||||
// name.
|
||||
|
@ -297,7 +297,7 @@ pub enum ConflictReason {
|
||||
RequiredDependencyAsFeature(InternedString),
|
||||
|
||||
/// A dependency listed a feature for an optional dependency, but that
|
||||
/// optional dependency is "hidden" using namespaced `crate:` syntax.
|
||||
/// optional dependency is "hidden" using namespaced `dep:` syntax.
|
||||
NonImplicitDependencyAsFeature(InternedString),
|
||||
|
||||
// TODO: needs more info for `activation_error`
|
||||
|
@ -88,7 +88,7 @@ impl Summary {
|
||||
if !namespaced_features {
|
||||
if self.inner.has_namespaced_features {
|
||||
bail!(
|
||||
"namespaced features with the `crate:` prefix are only allowed on \
|
||||
"namespaced features with the `dep:` prefix are only allowed on \
|
||||
the nightly channel and requires the `-Z namespaced-features` flag on the command-line"
|
||||
);
|
||||
}
|
||||
@ -158,7 +158,7 @@ impl Hash for Summary {
|
||||
/// and creates FeatureValues for each feature.
|
||||
///
|
||||
/// The returned `bool` indicates whether or not the `[features]` table
|
||||
/// included a `crate:` prefixed namespaced feature (used for gating on
|
||||
/// included a `dep:` prefixed namespaced feature (used for gating on
|
||||
/// nightly).
|
||||
fn build_feature_map(
|
||||
features: &BTreeMap<InternedString, Vec<InternedString>>,
|
||||
@ -183,7 +183,7 @@ fn build_feature_map(
|
||||
(*feature, fvs)
|
||||
})
|
||||
.collect();
|
||||
let has_namespaced_features = map.values().flatten().any(|fv| fv.has_crate_prefix());
|
||||
let has_namespaced_features = map.values().flatten().any(|fv| fv.has_dep_prefix());
|
||||
|
||||
// Add implicit features for optional dependencies if they weren't
|
||||
// explicitly listed anywhere.
|
||||
@ -191,10 +191,10 @@ fn build_feature_map(
|
||||
.values()
|
||||
.flatten()
|
||||
.filter_map(|fv| match fv {
|
||||
Crate { dep_name }
|
||||
| CrateFeature {
|
||||
Dep { dep_name }
|
||||
| DepFeature {
|
||||
dep_name,
|
||||
crate_prefix: true,
|
||||
dep_prefix: true,
|
||||
..
|
||||
} => Some(*dep_name),
|
||||
_ => None,
|
||||
@ -209,7 +209,7 @@ fn build_feature_map(
|
||||
{
|
||||
continue;
|
||||
}
|
||||
let fv = Crate {
|
||||
let fv = Dep {
|
||||
dep_name: dep_name_in_toml,
|
||||
};
|
||||
map.insert(dep_name_in_toml, vec![fv]);
|
||||
@ -217,9 +217,9 @@ fn build_feature_map(
|
||||
|
||||
// Validate features are listed properly.
|
||||
for (feature, fvs) in &map {
|
||||
if feature.starts_with("crate:") {
|
||||
if feature.starts_with("dep:") {
|
||||
bail!(
|
||||
"feature named `{}` is not allowed to start with `crate:`",
|
||||
"feature named `{}` is not allowed to start with `dep:`",
|
||||
feature
|
||||
);
|
||||
}
|
||||
@ -227,7 +227,7 @@ fn build_feature_map(
|
||||
// Find data for the referenced dependency...
|
||||
let dep_data = {
|
||||
match fv {
|
||||
Feature(dep_name) | Crate { dep_name, .. } | CrateFeature { dep_name, .. } => {
|
||||
Feature(dep_name) | Dep { dep_name, .. } | DepFeature { dep_name, .. } => {
|
||||
dep_map.get(dep_name)
|
||||
}
|
||||
}
|
||||
@ -253,7 +253,7 @@ fn build_feature_map(
|
||||
bail!(
|
||||
"feature `{}` includes `{}`, but `{}` is an \
|
||||
optional dependency without an implicit feature\n\
|
||||
Use `crate:{}` to enable the dependency.",
|
||||
Use `dep:{}` to enable the dependency.",
|
||||
feature,
|
||||
fv,
|
||||
f,
|
||||
@ -268,7 +268,7 @@ fn build_feature_map(
|
||||
}
|
||||
}
|
||||
}
|
||||
Crate { dep_name } => {
|
||||
Dep { dep_name } => {
|
||||
if !is_any_dep {
|
||||
bail!(
|
||||
"feature `{}` includes `{}`, but `{}` is not listed as a dependency",
|
||||
@ -288,7 +288,7 @@ fn build_feature_map(
|
||||
);
|
||||
}
|
||||
}
|
||||
CrateFeature { dep_name, .. } => {
|
||||
DepFeature { dep_name, .. } => {
|
||||
// Validation of the feature name will be performed in the resolver.
|
||||
if !is_any_dep {
|
||||
bail!(
|
||||
@ -308,7 +308,7 @@ fn build_feature_map(
|
||||
.values()
|
||||
.flatten()
|
||||
.filter_map(|fv| match fv {
|
||||
Crate { dep_name } | CrateFeature { dep_name, .. } => Some(dep_name),
|
||||
Dep { dep_name } | DepFeature { dep_name, .. } => Some(dep_name),
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
@ -318,7 +318,7 @@ fn build_feature_map(
|
||||
{
|
||||
bail!(
|
||||
"optional dependency `{}` is not included in any feature\n\
|
||||
Make sure that `crate:{}` is included in one of features in the [features] table.",
|
||||
Make sure that `dep:{}` is included in one of features in the [features] table.",
|
||||
dep.name_in_toml(),
|
||||
dep.name_in_toml(),
|
||||
);
|
||||
@ -332,15 +332,15 @@ fn build_feature_map(
|
||||
pub enum FeatureValue {
|
||||
/// A feature enabling another feature.
|
||||
Feature(InternedString),
|
||||
/// A feature enabling a dependency with `crate:dep_name` syntax.
|
||||
Crate { dep_name: InternedString },
|
||||
/// A feature enabling a dependency with `dep:dep_name` syntax.
|
||||
Dep { dep_name: InternedString },
|
||||
/// A feature enabling a feature on a dependency with `crate_name/feat_name` syntax.
|
||||
CrateFeature {
|
||||
DepFeature {
|
||||
dep_name: InternedString,
|
||||
dep_feature: InternedString,
|
||||
/// If this is true, then the feature used the `crate:` prefix, which
|
||||
/// If this is true, then the feature used the `dep:` prefix, which
|
||||
/// prevents enabling the feature named `dep_name`.
|
||||
crate_prefix: bool,
|
||||
dep_prefix: bool,
|
||||
},
|
||||
}
|
||||
|
||||
@ -350,27 +350,32 @@ impl FeatureValue {
|
||||
Some(pos) => {
|
||||
let (dep, dep_feat) = feature.split_at(pos);
|
||||
let dep_feat = &dep_feat[1..];
|
||||
let (dep, crate_prefix) = if let Some(dep) = dep.strip_prefix("crate:") {
|
||||
let (dep, dep_prefix) = if let Some(dep) = dep.strip_prefix("dep:") {
|
||||
(dep, true)
|
||||
} else {
|
||||
(dep, false)
|
||||
};
|
||||
FeatureValue::CrateFeature {
|
||||
FeatureValue::DepFeature {
|
||||
dep_name: InternedString::new(dep),
|
||||
dep_feature: InternedString::new(dep_feat),
|
||||
crate_prefix,
|
||||
dep_prefix,
|
||||
}
|
||||
}
|
||||
None => {
|
||||
if let Some(dep_name) = feature.strip_prefix("dep:") {
|
||||
FeatureValue::Dep {
|
||||
dep_name: InternedString::new(dep_name),
|
||||
}
|
||||
} else {
|
||||
FeatureValue::Feature(feature)
|
||||
}
|
||||
}
|
||||
None if feature.starts_with("crate:") => FeatureValue::Crate {
|
||||
dep_name: InternedString::new(&feature[6..]),
|
||||
},
|
||||
None => FeatureValue::Feature(feature),
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if this feature explicitly used `crate:` syntax.
|
||||
pub fn has_crate_prefix(&self) -> bool {
|
||||
matches!(self, FeatureValue::Crate{..} | FeatureValue::CrateFeature{crate_prefix:true, ..})
|
||||
/// Returns `true` if this feature explicitly used `dep:` syntax.
|
||||
pub fn has_dep_prefix(&self) -> bool {
|
||||
matches!(self, FeatureValue::Dep{..} | FeatureValue::DepFeature{dep_prefix:true, ..})
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,16 +384,16 @@ impl fmt::Display for FeatureValue {
|
||||
use self::FeatureValue::*;
|
||||
match self {
|
||||
Feature(feat) => write!(f, "{}", feat),
|
||||
Crate { dep_name } => write!(f, "crate:{}", dep_name),
|
||||
CrateFeature {
|
||||
Dep { dep_name } => write!(f, "dep:{}", dep_name),
|
||||
DepFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
crate_prefix: true,
|
||||
} => write!(f, "crate:{}/{}", dep_name, dep_feature),
|
||||
CrateFeature {
|
||||
dep_prefix: true,
|
||||
} => write!(f, "dep:{}/{}", dep_name, dep_feature),
|
||||
DepFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
crate_prefix: false,
|
||||
dep_prefix: false,
|
||||
} => write!(f, "{}/{}", dep_name, dep_feature),
|
||||
}
|
||||
}
|
||||
|
@ -1071,22 +1071,22 @@ fn validate_required_features(
|
||||
))?;
|
||||
}
|
||||
}
|
||||
FeatureValue::Crate { .. }
|
||||
| FeatureValue::CrateFeature {
|
||||
crate_prefix: true, ..
|
||||
FeatureValue::Dep { .. }
|
||||
| FeatureValue::DepFeature {
|
||||
dep_prefix: true, ..
|
||||
} => {
|
||||
anyhow::bail!(
|
||||
"invalid feature `{}` in required-features of target `{}`: \
|
||||
`crate:` prefixed feature values are not allowed in required-features",
|
||||
`dep:` prefixed feature values are not allowed in required-features",
|
||||
fv,
|
||||
target_name
|
||||
);
|
||||
}
|
||||
// Handling of dependent_crate/dependent_crate_feature syntax
|
||||
FeatureValue::CrateFeature {
|
||||
FeatureValue::DepFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
crate_prefix: false,
|
||||
dep_prefix: false,
|
||||
} => {
|
||||
match resolve
|
||||
.deps(summary.package_id())
|
||||
|
@ -563,11 +563,11 @@ fn add_feature_rec(
|
||||
package_index,
|
||||
);
|
||||
}
|
||||
FeatureValue::Crate { .. } => {}
|
||||
FeatureValue::CrateFeature {
|
||||
FeatureValue::Dep { .. } => {}
|
||||
FeatureValue::DepFeature {
|
||||
dep_name,
|
||||
dep_feature,
|
||||
crate_prefix,
|
||||
dep_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 && !crate_prefix {
|
||||
if is_optional && !dep_prefix {
|
||||
// Activate the optional dep on self.
|
||||
add_feature(
|
||||
graph,
|
||||
|
@ -20,7 +20,7 @@ use std::mem;
|
||||
use std::path::Path;
|
||||
use std::str;
|
||||
|
||||
fn make_crate_prefix(name: &str) -> String {
|
||||
fn make_dep_prefix(name: &str) -> String {
|
||||
match name.len() {
|
||||
1 => String::from("1"),
|
||||
2 => String::from("2"),
|
||||
@ -274,7 +274,7 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
|
||||
{
|
||||
write!(url, "/{}/{}/download", CRATE_TEMPLATE, VERSION_TEMPLATE).unwrap();
|
||||
}
|
||||
let prefix = make_crate_prefix(&*pkg.name());
|
||||
let prefix = make_dep_prefix(&*pkg.name());
|
||||
let url = url
|
||||
.replace(CRATE_TEMPLATE, &*pkg.name())
|
||||
.replace(VERSION_TEMPLATE, &pkg.version().to_string())
|
||||
@ -341,15 +341,15 @@ impl<'cfg> Drop for RemoteRegistry<'cfg> {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::make_crate_prefix;
|
||||
use super::make_dep_prefix;
|
||||
|
||||
#[test]
|
||||
fn crate_prefix() {
|
||||
assert_eq!(make_crate_prefix("a"), "1");
|
||||
assert_eq!(make_crate_prefix("ab"), "2");
|
||||
assert_eq!(make_crate_prefix("abc"), "3/a");
|
||||
assert_eq!(make_crate_prefix("Abc"), "3/A");
|
||||
assert_eq!(make_crate_prefix("AbCd"), "Ab/Cd");
|
||||
assert_eq!(make_crate_prefix("aBcDe"), "aB/cD");
|
||||
fn dep_prefix() {
|
||||
assert_eq!(make_dep_prefix("a"), "1");
|
||||
assert_eq!(make_dep_prefix("ab"), "2");
|
||||
assert_eq!(make_dep_prefix("abc"), "3/a");
|
||||
assert_eq!(make_dep_prefix("Abc"), "3/A");
|
||||
assert_eq!(make_dep_prefix("AbCd"), "Ab/Cd");
|
||||
assert_eq!(make_dep_prefix("aBcDe"), "aB/cD");
|
||||
}
|
||||
}
|
||||
|
@ -196,11 +196,11 @@ specified:
|
||||
|
||||
* Features may now be defined with the same name as a dependency.
|
||||
* Optional dependencies can be explicitly enabled in the `[features]` table
|
||||
with the `crate:` prefix, which enables the dependency without enabling a
|
||||
with the `dep:` prefix, which enables the dependency without enabling a
|
||||
feature of the same name.
|
||||
|
||||
By default, an optional dependency `foo` will define a feature `foo =
|
||||
["crate:foo"]` *unless* `crate:foo` is mentioned in any other feature, or the
|
||||
["dep:foo"]` *unless* `dep:foo` is mentioned in any other feature, or the
|
||||
`foo` feature is already defined. This helps prevent unnecessary boilerplate
|
||||
of listing every optional dependency, but still allows you to override the
|
||||
implicit feature.
|
||||
@ -223,7 +223,7 @@ regex = { version = "1.4.1", optional = true }
|
||||
lazy_static = { version = "1.4.0", optional = true }
|
||||
|
||||
[features]
|
||||
regex = ["crate:regex", "crate:lazy_static"]
|
||||
regex = ["dep:regex", "dep:lazy_static"]
|
||||
```
|
||||
|
||||
In this example, the "regex" feature enables both `regex` and `lazy_static`.
|
||||
@ -240,7 +240,7 @@ num-bigint = "0.2"
|
||||
serde = {version = "1.0", optional = true }
|
||||
|
||||
[features]
|
||||
serde = ["crate:serde", "bigdecimal/serde", "chrono/serde", "num-bigint/serde"]
|
||||
serde = ["dep:serde", "bigdecimal/serde", "chrono/serde", "num-bigint/serde"]
|
||||
```
|
||||
|
||||
In this case, `serde` is a natural name to use for a feature, because it is
|
||||
|
@ -5,7 +5,7 @@ use cargo_test_support::registry::{Dependency, Package};
|
||||
|
||||
#[cargo_test]
|
||||
fn gated() {
|
||||
// Need namespaced-features to use `crate:` syntax.
|
||||
// Need namespaced-features to use `dep:` syntax.
|
||||
Package::new("bar", "1.0.0").publish();
|
||||
let p = project()
|
||||
.file(
|
||||
@ -19,7 +19,7 @@ fn gated() {
|
||||
bar = { version = "1.0", optional = true }
|
||||
|
||||
[features]
|
||||
foo = ["crate:bar"]
|
||||
foo = ["dep:bar"]
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
@ -32,7 +32,7 @@ fn gated() {
|
||||
[ERROR] failed to parse manifest at `[..]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
namespaced features with the `crate:` prefix are only allowed on the nightly channel \
|
||||
namespaced features with the `dep:` prefix are only allowed on the nightly channel \
|
||||
and requires the `-Z namespaced-features` flag on the command-line
|
||||
",
|
||||
)
|
||||
@ -41,11 +41,11 @@ Caused by:
|
||||
|
||||
#[cargo_test]
|
||||
fn dependency_gate_ignored() {
|
||||
// Dependencies with `crate:` features are ignored in the registry if not on nightly.
|
||||
// Dependencies with `dep:` features are ignored in the registry if not on nightly.
|
||||
Package::new("baz", "1.0.0").publish();
|
||||
Package::new("bar", "1.0.0")
|
||||
.add_dep(Dependency::new("baz", "1.0").optional(true))
|
||||
.feature("feat", &["crate:baz"])
|
||||
.feature("feat", &["dep:baz"])
|
||||
.publish();
|
||||
let p = project()
|
||||
.file(
|
||||
@ -98,11 +98,11 @@ required by package `foo v0.1.0 ([..]/foo)`
|
||||
|
||||
#[cargo_test]
|
||||
fn dependency_with_crate_syntax() {
|
||||
// Registry dependency uses crate: syntax.
|
||||
// Registry dependency uses dep: syntax.
|
||||
Package::new("baz", "1.0.0").publish();
|
||||
Package::new("bar", "1.0.0")
|
||||
.add_dep(Dependency::new("baz", "1.0").optional(true))
|
||||
.feature("feat", &["crate:baz"])
|
||||
.feature("feat", &["dep:baz"])
|
||||
.publish();
|
||||
let p = project()
|
||||
.file(
|
||||
@ -171,7 +171,7 @@ Caused by:
|
||||
|
||||
#[cargo_test]
|
||||
fn namespaced_invalid_dependency() {
|
||||
// Specifies a crate:name that doesn't exist.
|
||||
// Specifies a dep:name that doesn't exist.
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
@ -181,7 +181,7 @@ fn namespaced_invalid_dependency() {
|
||||
version = "0.0.1"
|
||||
|
||||
[features]
|
||||
bar = ["crate:baz"]
|
||||
bar = ["dep:baz"]
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "")
|
||||
@ -195,7 +195,7 @@ fn namespaced_invalid_dependency() {
|
||||
[ERROR] failed to parse manifest at `[..]`
|
||||
|
||||
Caused by:
|
||||
feature `bar` includes `crate:baz`, but `baz` is not listed as a dependency
|
||||
feature `bar` includes `dep:baz`, but `baz` is not listed as a dependency
|
||||
",
|
||||
)
|
||||
.run();
|
||||
@ -203,7 +203,7 @@ Caused by:
|
||||
|
||||
#[cargo_test]
|
||||
fn namespaced_non_optional_dependency() {
|
||||
// Specifies a crate:name for a dependency that is not optional.
|
||||
// Specifies a dep:name for a dependency that is not optional.
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
@ -213,7 +213,7 @@ fn namespaced_non_optional_dependency() {
|
||||
version = "0.0.1"
|
||||
|
||||
[features]
|
||||
bar = ["crate:baz"]
|
||||
bar = ["dep:baz"]
|
||||
|
||||
[dependencies]
|
||||
baz = "0.1"
|
||||
@ -230,7 +230,7 @@ fn namespaced_non_optional_dependency() {
|
||||
[ERROR] failed to parse manifest at `[..]`
|
||||
|
||||
Caused by:
|
||||
feature `bar` includes `crate:baz`, but `baz` is not an optional dependency
|
||||
feature `bar` includes `dep:baz`, but `baz` is not an optional dependency
|
||||
A non-optional dependency of the same name is defined; consider adding `optional = true` to its definition.
|
||||
",
|
||||
)
|
||||
@ -315,7 +315,7 @@ fn namespaced_shadowed_dep() {
|
||||
|
||||
Caused by:
|
||||
optional dependency `baz` is not included in any feature
|
||||
Make sure that `crate:baz` is included in one of features in the [features] table.
|
||||
Make sure that `dep:baz` is included in one of features in the [features] table.
|
||||
",
|
||||
)
|
||||
.run();
|
||||
@ -394,7 +394,7 @@ fn namespaced_same_name() {
|
||||
version = "0.0.1"
|
||||
|
||||
[features]
|
||||
baz = ["crate:baz"]
|
||||
baz = ["dep:baz"]
|
||||
|
||||
[dependencies]
|
||||
baz = { version = "0.1", optional = true }
|
||||
@ -441,7 +441,7 @@ fn namespaced_same_name() {
|
||||
|
||||
#[cargo_test]
|
||||
fn no_implicit_feature() {
|
||||
// Using `crate:` will not create an implicit feature.
|
||||
// Using `dep:` will not create an implicit feature.
|
||||
Package::new("regex", "1.0.0").publish();
|
||||
Package::new("lazy_static", "1.0.0").publish();
|
||||
|
||||
@ -458,7 +458,7 @@ fn no_implicit_feature() {
|
||||
lazy_static = { version = "1.0", optional = true }
|
||||
|
||||
[features]
|
||||
regex = ["crate:regex", "crate:lazy_static"]
|
||||
regex = ["dep:regex", "dep:lazy_static"]
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
@ -507,7 +507,7 @@ fn no_implicit_feature() {
|
||||
.with_stderr(
|
||||
"\
|
||||
[ERROR] Package `foo v0.1.0 [..]` does not have feature `lazy_static`. \
|
||||
It has an optional dependency with that name, but that dependency uses the \"crate:\" \
|
||||
It has an optional dependency with that name, but that dependency uses the \"dep:\" \
|
||||
syntax in the features table, so it does not have an implicit feature with that name.
|
||||
",
|
||||
)
|
||||
@ -517,7 +517,7 @@ syntax in the features table, so it does not have an implicit feature with that
|
||||
|
||||
#[cargo_test]
|
||||
fn crate_feature_explicit() {
|
||||
// crate:name/feature syntax shouldn't set implicit feature.
|
||||
// dep:name/feature syntax shouldn't set implicit feature.
|
||||
Package::new("bar", "1.0.0")
|
||||
.file(
|
||||
"src/lib.rs",
|
||||
@ -540,7 +540,7 @@ fn crate_feature_explicit() {
|
||||
bar = {version = "1.0", optional=true}
|
||||
|
||||
[features]
|
||||
f1 = ["crate:bar/feat"]
|
||||
f1 = ["dep:bar/feat"]
|
||||
"#,
|
||||
)
|
||||
.file(
|
||||
@ -572,7 +572,7 @@ fn crate_feature_explicit() {
|
||||
|
||||
#[cargo_test]
|
||||
fn crate_syntax_bad_name() {
|
||||
// "crate:bar" = []
|
||||
// "dep:bar" = []
|
||||
Package::new("bar", "1.0.0").publish();
|
||||
let p = project()
|
||||
.file(
|
||||
@ -586,13 +586,13 @@ fn crate_syntax_bad_name() {
|
||||
bar = { version="1.0", optional=true }
|
||||
|
||||
[features]
|
||||
"crate:bar" = []
|
||||
"dep:bar" = []
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("check -Z namespaced-features --features crate:bar")
|
||||
p.cargo("check -Z namespaced-features --features dep:bar")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
@ -600,7 +600,7 @@ fn crate_syntax_bad_name() {
|
||||
[ERROR] failed to parse manifest at [..]/foo/Cargo.toml`
|
||||
|
||||
Caused by:
|
||||
feature named `crate:bar` is not allowed to start with `crate:`
|
||||
feature named `dep:bar` is not allowed to start with `dep:`
|
||||
",
|
||||
)
|
||||
.run();
|
||||
@ -608,7 +608,7 @@ Caused by:
|
||||
|
||||
#[cargo_test]
|
||||
fn crate_syntax_in_dep() {
|
||||
// features = ["crate:baz"]
|
||||
// features = ["dep:baz"]
|
||||
Package::new("baz", "1.0.0").publish();
|
||||
Package::new("bar", "1.0.0")
|
||||
.add_dep(Dependency::new("baz", "1.0").optional(true))
|
||||
@ -622,7 +622,7 @@ fn crate_syntax_in_dep() {
|
||||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
bar = { version = "1.0", features = ["crate:baz"] }
|
||||
bar = { version = "1.0", features = ["dep:baz"] }
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
@ -634,7 +634,7 @@ fn crate_syntax_in_dep() {
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] [..]
|
||||
[ERROR] feature value `crate:baz` is not allowed to use explicit `crate:` syntax
|
||||
[ERROR] feature value `dep:baz` is not allowed to use explicit `dep:` syntax
|
||||
",
|
||||
)
|
||||
.run();
|
||||
@ -642,7 +642,7 @@ fn crate_syntax_in_dep() {
|
||||
|
||||
#[cargo_test]
|
||||
fn crate_syntax_cli() {
|
||||
// --features crate:bar
|
||||
// --features dep:bar
|
||||
Package::new("bar", "1.0.0").publish();
|
||||
let p = project()
|
||||
.file(
|
||||
@ -659,13 +659,13 @@ fn crate_syntax_cli() {
|
||||
.file("src/lib.rs", "")
|
||||
.build();
|
||||
|
||||
p.cargo("check -Z namespaced-features --features crate:bar")
|
||||
p.cargo("check -Z namespaced-features --features dep:bar")
|
||||
.masquerade_as_nightly_cargo()
|
||||
.with_status(101)
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] [..]
|
||||
[ERROR] feature value `crate:bar` is not allowed to use explicit `crate:` syntax
|
||||
[ERROR] feature value `dep:bar` is not allowed to use explicit `dep:` syntax
|
||||
",
|
||||
)
|
||||
.run();
|
||||
@ -673,7 +673,7 @@ fn crate_syntax_cli() {
|
||||
|
||||
#[cargo_test]
|
||||
fn crate_required_features() {
|
||||
// required-features = ["crate:bar"]
|
||||
// required-features = ["dep:bar"]
|
||||
Package::new("bar", "1.0.0").publish();
|
||||
let p = project()
|
||||
.file(
|
||||
@ -688,7 +688,7 @@ fn crate_required_features() {
|
||||
|
||||
[[bin]]
|
||||
name = "foo"
|
||||
required-features = ["crate:bar"]
|
||||
required-features = ["dep:bar"]
|
||||
"#,
|
||||
)
|
||||
.file("src/main.rs", "fn main() {}")
|
||||
@ -700,8 +700,8 @@ fn crate_required_features() {
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] [..]
|
||||
[ERROR] invalid feature `crate:bar` in required-features of target `foo`: \
|
||||
`crate:` prefixed feature values are not allowed in required-features
|
||||
[ERROR] invalid feature `dep:bar` in required-features of target `foo`: \
|
||||
`dep:` prefixed feature values are not allowed in required-features
|
||||
",
|
||||
)
|
||||
.run();
|
||||
@ -709,7 +709,7 @@ fn crate_required_features() {
|
||||
|
||||
#[cargo_test]
|
||||
fn json_exposed() {
|
||||
// Checks that the implicit crate: values are exposed in JSON.
|
||||
// Checks that the implicit dep: values are exposed in JSON.
|
||||
Package::new("bar", "1.0.0").publish();
|
||||
let p = project()
|
||||
.file(
|
||||
@ -745,7 +745,7 @@ fn json_exposed() {
|
||||
"dependencies": "{...}",
|
||||
"targets": "{...}",
|
||||
"features": {
|
||||
"bar": ["crate:bar"]
|
||||
"bar": ["dep:bar"]
|
||||
},
|
||||
"manifest_path": "[..]foo/Cargo.toml",
|
||||
"metadata": null,
|
||||
@ -798,7 +798,7 @@ fn crate_feature_with_explicit() {
|
||||
|
||||
[features]
|
||||
f1 = ["bar/bar_feat"]
|
||||
bar = ["crate:bar", "f2"]
|
||||
bar = ["dep:bar", "f2"]
|
||||
f2 = []
|
||||
"#,
|
||||
)
|
||||
@ -846,7 +846,7 @@ fn optional_explicit_without_crate() {
|
||||
bar = { version = "1.0", optional = true }
|
||||
|
||||
[features]
|
||||
feat1 = ["crate:bar"]
|
||||
feat1 = ["dep:bar"]
|
||||
feat2 = ["bar"]
|
||||
"#,
|
||||
)
|
||||
@ -862,7 +862,7 @@ fn optional_explicit_without_crate() {
|
||||
|
||||
Caused by:
|
||||
feature `feat2` includes `bar`, but `bar` is an optional dependency without an implicit feature
|
||||
Use `crate:bar` to enable the dependency.
|
||||
Use `dep:bar` to enable the dependency.
|
||||
",
|
||||
)
|
||||
.run();
|
||||
@ -873,7 +873,7 @@ fn tree() {
|
||||
Package::new("baz", "1.0.0").publish();
|
||||
Package::new("bar", "1.0.0")
|
||||
.add_dep(Dependency::new("baz", "1.0").optional(true))
|
||||
.feature("feat1", &["crate:baz"])
|
||||
.feature("feat1", &["dep:baz"])
|
||||
.feature("feat2", &[])
|
||||
.publish();
|
||||
let p = project()
|
||||
@ -889,8 +889,8 @@ fn tree() {
|
||||
|
||||
[features]
|
||||
a = ["bar/feat2"]
|
||||
b = ["crate:bar/feat2"]
|
||||
bar = ["crate:bar"]
|
||||
b = ["dep:bar/feat2"]
|
||||
bar = ["dep:bar"]
|
||||
"#,
|
||||
)
|
||||
.file("src/lib.rs", "")
|
||||
|
Loading…
x
Reference in New Issue
Block a user