Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce autoXXX keys for target auto-discovery #5335

Merged
merged 8 commits into from
Apr 21, 2018
Merged
30 changes: 18 additions & 12 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,10 @@ pub struct TomlProject {
workspace: Option<String>,
#[serde(rename = "im-a-teapot")]
im_a_teapot: Option<bool>,
autobins: Option<bool>,
autoexamples: Option<bool>,
autotests: Option<bool>,
autobenches: Option<bool>,

// package metadata
description: Option<String>,
Expand Down Expand Up @@ -633,13 +637,27 @@ impl TomlManifest {

let pkgid = project.to_package_id(source_id)?;

let edition = if let Some(ref edition) = project.rust {
features
.require(Feature::edition())
.chain_err(|| "editions are unstable")?;
if let Ok(edition) = edition.parse() {
edition
} else {
bail!("the `rust` key must be one of: `2015`, `2018`")
}
} else {
Edition::Edition2015
};

// If we have no lib at all, use the inferred lib if available
// If we have a lib with a path, we're done
// If we have a lib with no path, use the inferred lib or_else package name
let targets = targets(
me,
package_name,
package_root,
edition,
&project.build,
&mut warnings,
&mut errors,
Expand Down Expand Up @@ -798,18 +816,6 @@ impl TomlManifest {
None => false,
};

let edition = if let Some(ref edition) = project.rust {
features
.require(Feature::edition())
.chain_err(|| "editiones are unstable")?;
if let Ok(edition) = edition.parse() {
edition
} else {
bail!("the `rust` key must be one of: `2015`, `2018`")
}
} else {
Edition::Edition2015
};
let custom_metadata = project.metadata.clone();
let mut manifest = Manifest::new(
summary,
Expand Down
Loading