Skip to content

Commit 688f37c

Browse files
committed
fix(toml): remove key
1 parent 4de0094 commit 688f37c

File tree

6 files changed

+34
-208
lines changed

6 files changed

+34
-208
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: 10 additions & 32 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,10 +841,10 @@ 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,
844+
.set_for_host(match toml.proc_macro() {
845+
None => t2.for_host(),
846+
Some(true) => true,
847+
Some(false) => false,
870848
});
871849
if let Some(edition) = toml.edition.clone() {
872850
target.set_edition(

tests/testsuite/cross_compile.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -912,8 +912,7 @@ fn plugin_build_script_right_arch() {
912912
.arg(cross_compile::alternate())
913913
.with_stderr(
914914
"\
915-
[WARNING] support for rustc plugins has been removed from rustc. library `foo` should not specify `plugin = true`
916-
[WARNING] support for `plugin = true` will be removed from cargo in the future
915+
[WARNING] unused manifest key: lib.plugin
917916
[COMPILING] foo v0.0.1 ([..])
918917
[RUNNING] `rustc [..] build.rs [..]`
919918
[RUNNING] `[..]/build-script-build`

tests/testsuite/proc_macro.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,28 @@ fn proc_macro_crate_type_warning() {
345345
.run();
346346
}
347347

348+
#[cargo_test]
349+
fn lib_plugin_unused_key_warning() {
350+
let foo = project()
351+
.file(
352+
"Cargo.toml",
353+
r#"
354+
[package]
355+
name = "foo"
356+
version = "0.1.0"
357+
edition = "2015"
358+
[lib]
359+
plugin = true
360+
"#,
361+
)
362+
.file("src/lib.rs", "")
363+
.build();
364+
365+
foo.cargo("check")
366+
.with_stderr_contains("[WARNING] unused manifest key: lib.plugin")
367+
.run();
368+
}
369+
348370
#[cargo_test]
349371
fn proc_macro_crate_type_warning_plugin() {
350372
let foo = project()
@@ -357,20 +379,12 @@ fn proc_macro_crate_type_warning_plugin() {
357379
edition = "2015"
358380
[lib]
359381
crate-type = ["proc-macro"]
360-
plugin = true
361382
"#,
362383
)
363384
.file("src/lib.rs", "")
364385
.build();
365386

366387
foo.cargo("check")
367-
.with_stderr_contains(
368-
"[WARNING] support for rustc plugins has been removed from rustc. \
369-
library `foo` should not specify `plugin = true`")
370-
.with_stderr_contains(
371-
"[WARNING] support for `plugin = true` will be removed from cargo in the future")
372-
.with_stderr_contains(
373-
"[WARNING] proc-macro library `foo` should not specify `plugin = true`")
374388
.with_stderr_contains(
375389
"[WARNING] library `foo` should only specify `proc-macro = true` instead of setting `crate-type`")
376390
.run();

tests/testsuite/rustflags.rs

Lines changed: 0 additions & 164 deletions
Original file line numberDiff line numberDiff line change
@@ -345,84 +345,6 @@ fn env_rustflags_build_script_dep_with_target() {
345345
.run();
346346
}
347347

348-
#[cargo_test]
349-
fn env_rustflags_plugin_with_target() {
350-
// RUSTFLAGS should not be passed to rustc for plugins
351-
// when --target is specified.
352-
// In this test if --cfg foo is passed the build will fail.
353-
let p = project()
354-
.file(
355-
"Cargo.toml",
356-
r#"
357-
[package]
358-
name = "foo"
359-
version = "0.0.1"
360-
361-
[lib]
362-
name = "foo"
363-
plugin = true
364-
"#,
365-
)
366-
.file(
367-
"src/lib.rs",
368-
r#"
369-
fn main() { }
370-
#[cfg(foo)]
371-
fn main() { }
372-
"#,
373-
)
374-
.build();
375-
376-
let host = rustc_host();
377-
p.cargo("check --target")
378-
.arg(host)
379-
.env("RUSTFLAGS", "--cfg foo")
380-
.run();
381-
}
382-
383-
#[cargo_test]
384-
fn env_rustflags_plugin_dep_with_target() {
385-
// RUSTFLAGS should not be passed to rustc for plugins
386-
// when --target is specified.
387-
// In this test if --cfg foo is passed the build will fail.
388-
let foo = project()
389-
.file(
390-
"Cargo.toml",
391-
r#"
392-
[package]
393-
name = "foo"
394-
version = "0.0.1"
395-
396-
[lib]
397-
name = "foo"
398-
plugin = true
399-
400-
[dependencies.bar]
401-
path = "../bar"
402-
"#,
403-
)
404-
.file("src/lib.rs", "fn foo() {}")
405-
.build();
406-
let _bar = project()
407-
.at("bar")
408-
.file("Cargo.toml", &basic_lib_manifest("bar"))
409-
.file(
410-
"src/lib.rs",
411-
r#"
412-
fn bar() { }
413-
#[cfg(foo)]
414-
fn bar() { }
415-
"#,
416-
)
417-
.build();
418-
419-
let host = rustc_host();
420-
foo.cargo("check --target")
421-
.arg(host)
422-
.env("RUSTFLAGS", "--cfg foo")
423-
.run();
424-
}
425-
426348
#[cargo_test]
427349
fn env_rustflags_recompile() {
428350
let p = project().file("src/lib.rs", "").build();
@@ -800,92 +722,6 @@ fn build_rustflags_build_script_dep_with_target() {
800722
foo.cargo("check --target").arg(host).run();
801723
}
802724

803-
#[cargo_test]
804-
fn build_rustflags_plugin_with_target() {
805-
// RUSTFLAGS should not be passed to rustc for plugins
806-
// when --target is specified.
807-
// In this test if --cfg foo is passed the build will fail.
808-
let p = project()
809-
.file(
810-
"Cargo.toml",
811-
r#"
812-
[package]
813-
name = "foo"
814-
version = "0.0.1"
815-
816-
[lib]
817-
name = "foo"
818-
plugin = true
819-
"#,
820-
)
821-
.file(
822-
"src/lib.rs",
823-
r#"
824-
fn main() { }
825-
#[cfg(foo)]
826-
fn main() { }
827-
"#,
828-
)
829-
.file(
830-
".cargo/config.toml",
831-
r#"
832-
[build]
833-
rustflags = ["--cfg", "foo"]
834-
"#,
835-
)
836-
.build();
837-
838-
let host = rustc_host();
839-
p.cargo("check --target").arg(host).run();
840-
}
841-
842-
#[cargo_test]
843-
fn build_rustflags_plugin_dep_with_target() {
844-
// RUSTFLAGS should not be passed to rustc for plugins
845-
// when --target is specified.
846-
// In this test if --cfg foo is passed the build will fail.
847-
let foo = project()
848-
.file(
849-
"Cargo.toml",
850-
r#"
851-
[package]
852-
name = "foo"
853-
version = "0.0.1"
854-
855-
[lib]
856-
name = "foo"
857-
plugin = true
858-
859-
[dependencies.bar]
860-
path = "../bar"
861-
"#,
862-
)
863-
.file("src/lib.rs", "fn foo() {}")
864-
.file(
865-
".cargo/config.toml",
866-
r#"
867-
[build]
868-
rustflags = ["--cfg", "foo"]
869-
"#,
870-
)
871-
.build();
872-
let _bar = project()
873-
.at("bar")
874-
.file("Cargo.toml", &basic_lib_manifest("bar"))
875-
.file(
876-
"src/lib.rs",
877-
r#"
878-
fn bar() { }
879-
#[cfg(foo)]
880-
fn bar() { }
881-
"#,
882-
)
883-
.build();
884-
885-
let host = rustc_host();
886-
foo.cargo("check --target").arg(host).run();
887-
}
888-
889725
#[cargo_test]
890726
fn build_rustflags_recompile() {
891727
let p = project().file("src/lib.rs", "").build();

0 commit comments

Comments
 (0)