Skip to content

Commit

Permalink
Auto merge of #5335 - dwijnand:target-autodiscovery, r=alexcrichton
Browse files Browse the repository at this point in the history
Introduce autoXXX keys for target auto-discovery

In Rust 2015 absence of the configuration makes it default to not
include auto-discovered targets (i.e false), with a warnings message.

In Rust 2018 absence makes it default to include auto-discovered
targets (i.e true).

Fixes #5330

---

_original_

Fixes #5330

submitted for early review. feedback very welcome, I'm happy to iterate (and learn).

in particular I require assistance with the borrowing of `warnings` in `clean_benches`.
  • Loading branch information
bors committed Apr 21, 2018
2 parents 6d2781d + ab5ac28 commit fd3be77
Show file tree
Hide file tree
Showing 7 changed files with 465 additions and 64 deletions.
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

0 comments on commit fd3be77

Please sign in to comment.