From ca073eed8002adff8ef51a408aeb9b2f541e3c7c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 1 Mar 2017 09:22:05 -0800 Subject: [PATCH] Accept proc_macro in addition to proc-macro More historical behavior... --- src/cargo/util/toml.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index 8bd6ac6446b..277b9610eb1 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -988,6 +988,8 @@ struct TomlTarget { plugin: Option, #[serde(rename = "proc-macro")] proc_macro: Option, + #[serde(rename = "proc_macro")] + proc_macro2: Option, harness: Option, #[serde(rename = "required-features")] required_features: Option>, @@ -1104,12 +1106,16 @@ impl TomlTarget { // // A plugin requires exporting plugin_registrar so a crate cannot be // both at once. - if self.plugin == Some(true) && self.proc_macro == Some(true) { + if self.plugin == Some(true) && self.proc_macro() == Some(true) { Err(human("lib.plugin and lib.proc-macro cannot both be true".to_string())) } else { Ok(()) } } + + fn proc_macro(&self) -> Option { + self.proc_macro.or(self.proc_macro2) + } } impl PathValue { @@ -1144,7 +1150,7 @@ fn normalize(package_root: &Path, .set_doctest(toml.doctest.unwrap_or(t2.doctested())) .set_benched(toml.bench.unwrap_or(t2.benched())) .set_harness(toml.harness.unwrap_or(t2.harness())) - .set_for_host(match (toml.plugin, toml.proc_macro) { + .set_for_host(match (toml.plugin, toml.proc_macro()) { (None, None) => t2.for_host(), (Some(true), _) | (_, Some(true)) => true, (Some(false), _) | (_, Some(false)) => false, @@ -1160,7 +1166,7 @@ fn normalize(package_root: &Path, Some(kinds) => kinds.iter().map(|s| LibKind::from_str(s)).collect(), None => { vec![ if l.plugin == Some(true) {LibKind::Dylib} - else if l.proc_macro == Some(true) {LibKind::ProcMacro} + else if l.proc_macro() == Some(true) {LibKind::ProcMacro} else {LibKind::Lib} ] } };