Skip to content

Blanket rename rustc-macro to proc-macro #3160

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 7, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/cargo/core/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub enum LibKind {
Lib,
Rlib,
Dylib,
RustcMacro,
ProcMacro,
Other(String),
}

Expand All @@ -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()),
}
}
Expand All @@ -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,
}
}
Expand All @@ -92,7 +92,7 @@ impl LibKind {
LibKind::Lib |
LibKind::Rlib |
LibKind::Dylib |
LibKind::RustcMacro => true,
LibKind::ProcMacro => true,
LibKind::Other(..) => false,
}
}
Expand Down
16 changes: 8 additions & 8 deletions src/cargo/util/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ struct TomlTarget {
bench: Option<bool>,
doc: Option<bool>,
plugin: Option<bool>,
rustc_macro: Option<bool>,
proc_macro: Option<bool>,
harness: Option<bool>,
}

Expand Down Expand Up @@ -934,7 +934,7 @@ impl TomlTarget {
bench: None,
doc: None,
plugin: None,
rustc_macro: None,
proc_macro: None,
harness: None,
}
}
Expand Down Expand Up @@ -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(())
}
Expand Down Expand Up @@ -1064,7 +1064,7 @@ fn normalize(lib: &Option<TomlLibTarget>,
.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,
Expand All @@ -1081,7 +1081,7 @@ fn normalize(lib: &Option<TomlLibTarget>,
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} ]
}
};
Expand Down
6 changes: 3 additions & 3 deletions src/doc/manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
38 changes: 19 additions & 19 deletions tests/rustc-macro.rs → tests/proc-macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn noop() {
path = "../noop"
"#)
.file("src/main.rs", r#"
#![feature(rustc_macro)]
#![feature(proc_macro)]

#[macro_use]
extern crate noop;
Expand All @@ -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
}
Expand Down Expand Up @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -149,7 +149,7 @@ fn impl_and_derive() {

#[test]
#[ignore]
fn plugin_and_rustc_macro() {
fn plugin_and_proc_macro() {
if !is_nightly() {
return;
}
Expand All @@ -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));
}