Skip to content

Commit 1f48eab

Browse files
committed
fix(toml): remove lib.plugin key
1 parent 4de0094 commit 1f48eab

File tree

3 files changed

+9
-35
lines changed

3 files changed

+9
-35
lines changed

crates/cargo-util-schemas/src/manifest/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,6 @@ pub struct TomlTarget {
12231223
pub doctest: Option<bool>,
12241224
pub bench: Option<bool>,
12251225
pub doc: Option<bool>,
1226-
pub plugin: Option<bool>,
12271226
pub doc_scrape_examples: Option<bool>,
12281227
pub proc_macro: Option<bool>,
12291228
#[serde(rename = "proc_macro")]

src/cargo/core/manifest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ impl Target {
905905
pub fn documented(&self) -> bool {
906906
self.inner.doc
907907
}
908-
// A plugin, proc-macro, or build-script.
908+
// A proc-macro or build-script.
909909
pub fn for_host(&self) -> bool {
910910
self.inner.for_host
911911
}

src/cargo/util/toml/targets.rs

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -188,17 +188,6 @@ fn to_lib_target(
188188
let path = lib.path.as_ref().expect("previously resolved");
189189
let path = package_root.join(&path.0);
190190

191-
if lib.plugin == Some(true) {
192-
warnings.push(format!(
193-
"support for rustc plugins has been removed from rustc. \
194-
library `{}` should not specify `plugin = true`",
195-
name_or_panic(lib)
196-
));
197-
warnings.push(format!(
198-
"support for `plugin = true` will be removed from cargo in the future"
199-
));
200-
}
201-
202191
// Per the Macros 1.1 RFC:
203192
//
204193
// > Initially if a crate is compiled with the `proc-macro` crate type
@@ -208,8 +197,8 @@ fn to_lib_target(
208197
//
209198
// A plugin requires exporting plugin_registrar so a crate cannot be
210199
// both at once.
211-
let crate_types = match (lib.crate_types(), lib.plugin, lib.proc_macro()) {
212-
(Some(kinds), _, _)
200+
let crate_types = match (lib.crate_types(), lib.proc_macro()) {
201+
(Some(kinds), _)
213202
if kinds.contains(&CrateType::Dylib.as_str().to_owned())
214203
&& kinds.contains(&CrateType::Cdylib.as_str().to_owned()) =>
215204
{
@@ -218,14 +207,7 @@ fn to_lib_target(
218207
name_or_panic(lib)
219208
));
220209
}
221-
(Some(kinds), _, _) if kinds.contains(&"proc-macro".to_string()) => {
222-
if let Some(true) = lib.plugin {
223-
// This is a warning to retain backwards compatibility.
224-
warnings.push(format!(
225-
"proc-macro library `{}` should not specify `plugin = true`",
226-
name_or_panic(lib)
227-
));
228-
}
210+
(Some(kinds), _) if kinds.contains(&"proc-macro".to_string()) => {
229211
warnings.push(format!(
230212
"library `{}` should only specify `proc-macro = true` instead of setting `crate-type`",
231213
name_or_panic(lib)
@@ -235,13 +217,9 @@ fn to_lib_target(
235217
}
236218
vec![CrateType::ProcMacro]
237219
}
238-
(_, Some(true), Some(true)) => {
239-
anyhow::bail!("`lib.plugin` and `lib.proc-macro` cannot both be `true`")
240-
}
241-
(Some(kinds), _, _) => kinds.iter().map(|s| s.into()).collect(),
242-
(None, Some(true), _) => vec![CrateType::Dylib],
243-
(None, _, Some(true)) => vec![CrateType::ProcMacro],
244-
(None, _, _) => vec![CrateType::Lib],
220+
(Some(kinds), _) => kinds.iter().map(|s| s.into()).collect(),
221+
(None, Some(true)) => vec![CrateType::ProcMacro],
222+
(None, _) => vec![CrateType::Lib],
245223
};
246224

247225
let mut target = Target::lib_target(name_or_panic(lib), crate_types, path, edition);
@@ -863,11 +841,8 @@ fn configure(toml: &TomlTarget, target: &mut Target) -> CargoResult<()> {
863841
Some(false) => RustdocScrapeExamples::Disabled,
864842
Some(true) => RustdocScrapeExamples::Enabled,
865843
})
866-
.set_for_host(match (toml.plugin, toml.proc_macro()) {
867-
(None, None) => t2.for_host(),
868-
(Some(true), _) | (_, Some(true)) => true,
869-
(Some(false), _) | (_, Some(false)) => false,
870-
});
844+
.set_for_host(toml.proc_macro().unwrap_or_else(|| t2.for_host()));
845+
871846
if let Some(edition) = toml.edition.clone() {
872847
target.set_edition(
873848
edition

0 commit comments

Comments
 (0)