publish: Option<VecStringOrBool>,
edition: Option<String>,
badges: Option<BTreeMap<String, BTreeMap<String, String>>>,
+ rust_version: Option<String>,
ws_root: PathBuf,
}
publish: Option<VecStringOrBool>,
edition: Option<String>,
badges: Option<BTreeMap<String, BTreeMap<String, String>>>,
+ rust_version: Option<String>,
ws_root: PathBuf,
) -> InheritableFields {
Self {
publish,
edition,
badges,
+ rust_version,
ws_root,
}
}
})
}
+ pub fn rust_version(&self) -> CargoResult<String> {
+ self.rust_version.clone().map_or(
+ Err(anyhow!("`workspace.rust-version` was not defined")),
+ |d| Ok(d),
+ )
+ }
+
pub fn badges(&self) -> CargoResult<BTreeMap<String, BTreeMap<String, String>>> {
self.badges
.clone()
#[serde(rename_all = "kebab-case")]
pub struct TomlProject {
edition: Option<MaybeWorkspace<String>>,
- rust_version: Option<String>,
+ rust_version: Option<MaybeWorkspace<String>>,
name: InternedString,
#[serde(deserialize_with = "version_trim_whitespace")]
version: MaybeWorkspace<semver::Version>,
publish: Option<VecStringOrBool>,
edition: Option<String>,
badges: Option<BTreeMap<String, BTreeMap<String, String>>>,
+ #[serde(rename = "rust-version")]
+ rust_version: Option<String>,
// Note that this field must come last due to the way toml serialization
// works which requires tables to be emitted after all values.
config.publish.clone(),
config.edition.clone(),
config.badges.clone(),
+ config.rust_version.clone(),
package_root.to_path_buf(),
);
}
let rust_version = if let Some(rust_version) = &project.rust_version {
- let req = match semver::VersionReq::parse(rust_version) {
+ let rust_version = rust_version
+ .clone()
+ .resolve(&features, "rust_version", || {
+ get_ws(config, resolved_path.clone(), workspace_config.clone())?.rust_version()
+ })?;
+ let req = match semver::VersionReq::parse(&rust_version) {
// Exclude semver operators like `^` and pre-release identifiers
Ok(req) if rust_version.chars().all(|c| c.is_ascii_digit() || c == '.') => req,
_ => bail!("`rust-version` must be a value like \"1.32\""),
.categories
.as_ref()
.map(|_| MaybeWorkspace::Defined(metadata.categories.clone()));
+ project.rust_version = rust_version.clone().map(|rv| MaybeWorkspace::Defined(rv));
let profiles = me.profile.clone();
if let Some(profiles) = &profiles {
config.publish.clone(),
config.edition.clone(),
config.badges.clone(),
+ config.rust_version.clone(),
root.to_path_buf(),
);
WorkspaceConfig::Root(WorkspaceRootConfig::new(
categories = ["development-tools"]
publish = false
edition = "2018"
+ rust-version = "1.60"
[workspace.badges]
gitlab = { repository = "https://gitlab.com/rust-lang/rust", branch = "master" }
categories = { workspace = true }
publish = { workspace = true }
edition = { workspace = true }
+ rust-version = { workspace = true }
[workspace]
members = []
categories = ["development-tools"]
publish = true
edition = "2018"
+ rust-version = "1.60"
[workspace.badges]
gitlab = { repository = "https://gitlab.com/rust-lang/rust", branch = "master" }
"#,
[package]
edition = "2018"
+rust-version = "1.60"
name = "foo"
version = "1.2.3"
authors = ["Rustaceans"]
categories = ["development-tools"]
publish = true
edition = "2018"
+ rust-version = "1.60"
[workspace.badges]
gitlab = { repository = "https://gitlab.com/rust-lang/rust", branch = "master" }
"#,
categories = { workspace = true }
publish = { workspace = true }
edition = { workspace = true }
+ rust-version = { workspace = true }
"#,
)
.file("LICENSE", "license")
[package]
edition = "2018"
+rust-version = "1.60"
name = "bar"
version = "1.2.3"
authors = ["Rustaceans"]