From 55fc374c9d30e25a9fe1eb45f83ec0ee78307332 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 4 Oct 2016 09:58:28 -0700 Subject: [PATCH] Blanket rename rustc-macro to proc-macro --- src/cargo/core/manifest.rs | 8 +++--- src/cargo/util/toml.rs | 16 +++++------ src/doc/manifest.md | 6 ++-- tests/{rustc-macro.rs => proc-macro.rs} | 38 ++++++++++++------------- 4 files changed, 34 insertions(+), 34 deletions(-) rename tests/{rustc-macro.rs => proc-macro.rs} (83%) diff --git a/src/cargo/core/manifest.rs b/src/cargo/core/manifest.rs index 827008b8be4..e72674b9602 100644 --- a/src/cargo/core/manifest.rs +++ b/src/cargo/core/manifest.rs @@ -61,7 +61,7 @@ pub enum LibKind { Lib, Rlib, Dylib, - RustcMacro, + ProcMacro, Other(String), } @@ -71,7 +71,7 @@ impl LibKind { "lib" => LibKind::Lib, "rlib" => LibKind::Rlib, "dylib" => LibKind::Dylib, - "rustc-macro" => LibKind::RustcMacro, + "procc-macro" => LibKind::ProcMacro, s => LibKind::Other(s.to_string()), } } @@ -82,7 +82,7 @@ impl LibKind { LibKind::Lib => "lib", LibKind::Rlib => "rlib", LibKind::Dylib => "dylib", - LibKind::RustcMacro => "rustc-macro", + LibKind::ProcMacro => "proc-macro", LibKind::Other(ref s) => s, } } @@ -92,7 +92,7 @@ impl LibKind { LibKind::Lib | LibKind::Rlib | LibKind::Dylib | - LibKind::RustcMacro => true, + LibKind::ProcMacro => true, LibKind::Other(..) => false, } } diff --git a/src/cargo/util/toml.rs b/src/cargo/util/toml.rs index a051a2836b3..0a9ecd6136c 100644 --- a/src/cargo/util/toml.rs +++ b/src/cargo/util/toml.rs @@ -905,7 +905,7 @@ struct TomlTarget { bench: Option, doc: Option, plugin: Option, - rustc_macro: Option, + proc_macro: Option, harness: Option, } @@ -934,7 +934,7 @@ impl TomlTarget { bench: None, doc: None, plugin: None, - rustc_macro: None, + proc_macro: None, harness: None, } } @@ -1017,15 +1017,15 @@ impl TomlTarget { fn validate_crate_type(&self) -> CargoResult<()> { // Per the Macros 1.1 RFC: // - // > Initially if a crate is compiled with the rustc-macro crate type + // > Initially if a crate is compiled with the proc-macro crate type // > (and possibly others) it will forbid exporting any items in the - // > crate other than those functions tagged #[rustc_macro_derive] and + // > crate other than those functions tagged #[proc_macro_derive] and // > those functions must also be placed at the crate root. // // A plugin requires exporting plugin_registrar so a crate cannot be // both at once. - if self.plugin == Some(true) && self.rustc_macro == Some(true) { - Err(human("lib.plugin and lib.rustc-macro cannot both be true".to_string())) + 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(()) } @@ -1064,7 +1064,7 @@ fn normalize(lib: &Option, .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.rustc_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, @@ -1081,7 +1081,7 @@ fn normalize(lib: &Option, Some(kinds) => kinds.iter().map(|s| LibKind::from_str(s)).collect(), None => { vec![ if l.plugin == Some(true) {LibKind::Dylib} - else if l.rustc_macro == Some(true) {LibKind::RustcMacro} + else if l.proc_macro == Some(true) {LibKind::ProcMacro} else {LibKind::Lib} ] } }; diff --git a/src/doc/manifest.md b/src/doc/manifest.md index eb5331d54e2..9aaab670738 100644 --- a/src/doc/manifest.md +++ b/src/doc/manifest.md @@ -512,7 +512,7 @@ plugin = false # If the target is meant to be a "macros 1.1" procedural macro, this field must # be set to true. -rustc-macro = false +proc-macro = false # If set to false, `cargo test` will omit the `--test` flag to rustc, which # stops it from generating a test harness. This is useful when the binary being @@ -534,11 +534,11 @@ crate-type = ["dylib"] # could be `staticlib` as well ``` The available options are `dylib`, `rlib`, `staticlib`, `cdylib`, and -`rustc-macro`. You should only use this option in a project. Cargo will always +`proc-macro`. You should only use this option in a project. Cargo will always compile packages (dependencies) based on the requirements of the project that includes them. -You can read more about the different crate types in the +You can read more about the different crate types in the [Rust Reference Manual](https://doc.rust-lang.org/reference.html#linkage) # The `[replace]` Section diff --git a/tests/rustc-macro.rs b/tests/proc-macro.rs similarity index 83% rename from tests/rustc-macro.rs rename to tests/proc-macro.rs index f9ea79d2a17..daae388e0ce 100644 --- a/tests/rustc-macro.rs +++ b/tests/proc-macro.rs @@ -23,7 +23,7 @@ fn noop() { path = "../noop" "#) .file("src/main.rs", r#" - #![feature(rustc_macro)] + #![feature(proc_macro)] #[macro_use] extern crate noop; @@ -41,15 +41,15 @@ fn noop() { authors = [] [lib] - rustc-macro = true + proc-macro = true "#) .file("src/lib.rs", r#" - #![feature(rustc_macro, rustc_macro_lib)] + #![feature(proc_macro, proc_macro_lib)] - extern crate rustc_macro; - use rustc_macro::TokenStream; + extern crate proc_macro; + use proc_macro::TokenStream; - #[rustc_macro_derive(Noop)] + #[proc_macro_derive(Noop)] pub fn noop(input: TokenStream) -> TokenStream { input } @@ -80,7 +80,7 @@ fn impl_and_derive() { path = "../transmogrify" "#) .file("src/main.rs", r#" - #![feature(rustc_macro)] + #![feature(proc_macro)] #[macro_use] extern crate transmogrify; @@ -106,15 +106,15 @@ fn impl_and_derive() { authors = [] [lib] - rustc-macro = true + proc-macro = true "#) .file("src/lib.rs", r#" - #![feature(rustc_macro, rustc_macro_lib)] + #![feature(proc_macro, proc_macro_lib)] - extern crate rustc_macro; - use rustc_macro::TokenStream; + extern crate proc_macro; + use proc_macro::TokenStream; - #[rustc_macro_derive(Transmogrify)] + #[proc_macro_derive(Transmogrify)] #[doc(hidden)] pub fn transmogrify(input: TokenStream) -> TokenStream { assert_eq!(input.to_string(), "struct X;\n"); @@ -149,7 +149,7 @@ fn impl_and_derive() { #[test] #[ignore] -fn plugin_and_rustc_macro() { +fn plugin_and_proc_macro() { if !is_nightly() { return; } @@ -163,28 +163,28 @@ fn plugin_and_rustc_macro() { [lib] plugin = true - rustc-macro = true + proc-macro = true "#) .file("src/lib.rs", r#" #![feature(plugin_registrar, rustc_private)] - #![feature(rustc_macro, rustc_macro_lib)] + #![feature(proc_macro, proc_macro_lib)] extern crate rustc_plugin; use rustc_plugin::Registry; - extern crate rustc_macro; - use rustc_macro::TokenStream; + extern crate proc_macro; + use proc_macro::TokenStream; #[plugin_registrar] pub fn plugin_registrar(reg: &mut Registry) {} - #[rustc_macro_derive(Questionable)] + #[proc_macro_derive(Questionable)] pub fn questionable(input: TokenStream) -> TokenStream { input } "#); - let msg = " lib.plugin and lib.rustc-macro cannot both be true"; + let msg = " lib.plugin and lib.proc-macro cannot both be true"; assert_that(questionable.cargo_process("build"), execs().with_status(101).with_stderr_contains(msg)); }