From 2148bdfcc7ea7b9614d8cbe596cbe7bb75b57cd1 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 3 Oct 2016 09:49:39 -0700 Subject: [PATCH] rustc: Rename rustc_macro to proc_macro This commit blanket renames the `rustc_macro` infrastructure to `proc_macro`, which reflects the general consensus of #35900. A follow up PR to Cargo will be required to purge the `rustc-macro` name as well. --- mk/crates.mk | 16 +- src/libproc_macro/Cargo.toml | 4 - src/libproc_macro/lib.rs | 252 ++++++++++-------- .../Cargo.toml | 6 +- .../build.rs | 0 src/libproc_macro_plugin/lib.rs | 137 ++++++++++ .../parse.rs | 0 .../prelude.rs | 0 .../qquote.rs | 4 +- src/librustc/middle/dependency_format.rs | 6 +- src/librustc/middle/reachable.rs | 2 +- src/librustc/middle/weak_lang_items.rs | 2 +- src/librustc/session/config.rs | 10 +- src/librustc/ty/context.rs | 2 +- src/librustc_driver/Cargo.toml | 8 +- src/librustc_driver/driver.rs | 20 +- src/librustc_macro/lib.rs | 169 ------------ src/librustc_metadata/Cargo.toml | 2 +- src/librustc_metadata/creader.rs | 12 +- src/librustc_metadata/encoder.rs | 6 +- src/librustc_metadata/lib.rs | 12 +- src/librustc_metadata/macro_import.rs | 8 +- src/librustc_resolve/build_reduced_graph.rs | 4 +- src/librustc_trans/back/link.rs | 8 +- src/librustc_trans/back/linker.rs | 4 +- src/libsyntax/ext/expand.rs | 2 +- src/libsyntax/feature_gate.rs | 12 +- src/libsyntax_ext/Cargo.toml | 2 +- src/libsyntax_ext/deriving/custom.rs | 2 +- src/libsyntax_ext/lib.rs | 8 +- ...o_registrar.rs => proc_macro_registrar.rs} | 60 ++--- src/rustc/Cargo.lock | 20 +- .../at-the-root.rs | 12 +- .../proc-macro/attribute.rs | 46 ++++ .../auxiliary/derive-a-2.rs | 12 +- .../auxiliary/derive-a.rs | 12 +- .../auxiliary/derive-bad.rs | 12 +- .../auxiliary/derive-panic.rs | 12 +- .../auxiliary/derive-unstable-2.rs | 12 +- .../auxiliary/derive-unstable.rs | 12 +- .../cannot-link.rs | 2 +- .../{rustc-macro => proc-macro}/define-two.rs | 12 +- .../{rustc-macro => proc-macro}/derive-bad.rs | 2 +- .../derive-still-gated.rs | 2 +- .../expand-to-unstable-2.rs | 2 +- .../expand-to-unstable.rs | 2 +- .../export-macro.rs | 6 +- .../{rustc-macro => proc-macro}/exports.rs | 2 +- .../feature-gate-1.rs | 4 +- .../feature-gate-2.rs | 2 +- .../feature-gate-3.rs | 4 +- .../feature-gate-4.rs | 0 .../feature-gate-5.rs | 2 +- .../{rustc-macro => proc-macro}/import.rs | 2 +- .../{rustc-macro => proc-macro}/load-panic.rs | 2 +- .../require-rustc-macro-crate-type.rs | 10 +- .../shadow-builtin.rs | 10 +- .../{rustc-macro => proc-macro}/shadow.rs | 2 +- .../{rustc-macro => proc-macro}/signature.rs | 10 +- .../two-crate-types-1.rs | 4 +- .../two-crate-types-2.rs | 4 +- .../rustc-macro/attribute.rs | 46 ---- .../run-make/rustc-macro-dep-files/Makefile | 2 +- .../run-make/rustc-macro-dep-files/bar.rs | 2 +- .../run-make/rustc-macro-dep-files/foo.rs | 12 +- .../auxiliary/cond_noprelude_plugin.rs | 6 +- .../auxiliary/cond_plugin.rs | 6 +- .../auxiliary/cond_prelude_plugin.rs | 6 +- .../auxiliary/proc_macro_def.rs | 4 +- src/test/run-pass-fulldeps/macro-quote-1.rs | 6 +- .../{rustc-macro => proc-macro}/add-impl.rs | 2 +- .../append-impl.rs | 2 +- .../auxiliary/add-impl.rs | 14 +- .../auxiliary/append-impl.rs | 12 +- .../auxiliary/derive-a.rs | 12 +- .../auxiliary/derive-atob.rs | 12 +- .../auxiliary/derive-ctod.rs | 12 +- .../auxiliary/derive-same-struct.rs | 14 +- .../auxiliary/expand-with-a-macro.rs | 12 +- .../derive-same-struct.rs | 2 +- .../expand-with-a-macro.rs | 2 +- .../{rustc-macro => proc-macro}/load-two.rs | 2 +- .../{rustc-macro => proc-macro}/smoke.rs | 2 +- src/test/rustdoc/rustc-macro-crate.rs | 12 +- src/tools/cargotest/main.rs | 2 +- src/tools/tidy/src/cargo.rs | 8 +- 86 files changed, 613 insertions(+), 615 deletions(-) rename src/{librustc_macro => libproc_macro_plugin}/Cargo.toml (53%) rename src/{libproc_macro => libproc_macro_plugin}/build.rs (100%) create mode 100644 src/libproc_macro_plugin/lib.rs rename src/{libproc_macro => libproc_macro_plugin}/parse.rs (100%) rename src/{libproc_macro => libproc_macro_plugin}/prelude.rs (100%) rename src/{libproc_macro => libproc_macro_plugin}/qquote.rs (99%) delete mode 100644 src/librustc_macro/lib.rs rename src/libsyntax_ext/{rustc_macro_registrar.rs => proc_macro_registrar.rs} (81%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/at-the-root.rs (73%) create mode 100644 src/test/compile-fail-fulldeps/proc-macro/attribute.rs rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-a-2.rs (77%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-a.rs (77%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-bad.rs (78%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-panic.rs (77%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-unstable-2.rs (78%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-unstable.rs (78%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/cannot-link.rs (87%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/define-two.rs (74%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/derive-bad.rs (96%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/derive-still-gated.rs (96%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/expand-to-unstable-2.rs (96%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/expand-to-unstable.rs (96%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/export-macro.rs (79%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/exports.rs (95%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/feature-gate-1.rs (83%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/feature-gate-2.rs (87%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/feature-gate-3.rs (83%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/feature-gate-4.rs (100%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/feature-gate-5.rs (87%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/import.rs (96%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/load-panic.rs (96%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/require-rustc-macro-crate-type.rs (69%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/shadow-builtin.rs (80%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/shadow.rs (96%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/signature.rs (78%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/two-crate-types-1.rs (83%) rename src/test/compile-fail-fulldeps/{rustc-macro => proc-macro}/two-crate-types-2.rs (78%) delete mode 100644 src/test/compile-fail-fulldeps/rustc-macro/attribute.rs rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/add-impl.rs (96%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/append-impl.rs (96%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/add-impl.rs (78%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/append-impl.rs (80%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-a.rs (82%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-atob.rs (79%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-ctod.rs (79%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/derive-same-struct.rs (80%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/auxiliary/expand-with-a-macro.rs (82%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/derive-same-struct.rs (96%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/expand-with-a-macro.rs (96%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/load-two.rs (96%) rename src/test/run-pass-fulldeps/{rustc-macro => proc-macro}/smoke.rs (96%) diff --git a/mk/crates.mk b/mk/crates.mk index 86bb3a8ca0c..efe7a579801 100644 --- a/mk/crates.mk +++ b/mk/crates.mk @@ -59,8 +59,8 @@ RUSTC_CRATES := rustc rustc_typeck rustc_mir rustc_borrowck rustc_resolve rustc_ rustc_trans rustc_back rustc_llvm rustc_privacy rustc_lint \ rustc_data_structures rustc_platform_intrinsics rustc_errors \ rustc_plugin rustc_metadata rustc_passes rustc_save_analysis \ - rustc_const_eval rustc_const_math rustc_incremental rustc_macro -HOST_CRATES := syntax syntax_ext proc_macro syntax_pos $(RUSTC_CRATES) rustdoc fmt_macros \ + rustc_const_eval rustc_const_math rustc_incremental proc_macro +HOST_CRATES := syntax syntax_ext proc_macro_plugin syntax_pos $(RUSTC_CRATES) rustdoc fmt_macros \ flate arena graphviz log serialize TOOLS := compiletest rustdoc rustc rustbook error_index_generator @@ -101,8 +101,8 @@ DEPS_term := std DEPS_test := std getopts term native:rust_test_helpers DEPS_syntax := std term serialize log arena libc rustc_bitflags rustc_unicode rustc_errors syntax_pos -DEPS_syntax_ext := syntax syntax_pos rustc_errors fmt_macros rustc_macro -DEPS_proc_macro := syntax syntax_pos rustc_plugin log +DEPS_syntax_ext := syntax syntax_pos rustc_errors fmt_macros proc_macro +DEPS_proc_macro_plugin := syntax syntax_pos rustc_plugin log DEPS_syntax_pos := serialize DEPS_rustc_const_math := std syntax log serialize @@ -118,15 +118,15 @@ DEPS_rustc_data_structures := std log serialize libc DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \ rustc_typeck rustc_mir rustc_resolve log syntax serialize rustc_llvm \ rustc_trans rustc_privacy rustc_lint rustc_plugin \ - rustc_metadata syntax_ext proc_macro \ + rustc_metadata syntax_ext proc_macro_plugin \ rustc_passes rustc_save_analysis rustc_const_eval \ - rustc_incremental syntax_pos rustc_errors rustc_macro + rustc_incremental syntax_pos rustc_errors proc_macro DEPS_rustc_errors := log libc serialize syntax_pos DEPS_rustc_lint := rustc log syntax syntax_pos rustc_const_eval DEPS_rustc_llvm := native:rustllvm libc std rustc_bitflags -DEPS_rustc_macro := std syntax +DEPS_proc_macro := std syntax DEPS_rustc_metadata := rustc syntax syntax_pos rustc_errors rustc_const_math \ - rustc_macro syntax_ext + proc_macro syntax_ext DEPS_rustc_passes := syntax syntax_pos rustc core rustc_const_eval rustc_errors DEPS_rustc_mir := rustc syntax syntax_pos rustc_const_math rustc_const_eval rustc_bitflags DEPS_rustc_resolve := arena rustc log syntax syntax_pos rustc_errors diff --git a/src/libproc_macro/Cargo.toml b/src/libproc_macro/Cargo.toml index 99fb1d65cda..7ce65d0fe4d 100644 --- a/src/libproc_macro/Cargo.toml +++ b/src/libproc_macro/Cargo.toml @@ -4,12 +4,8 @@ name = "proc_macro" version = "0.0.0" [lib] -name = "proc_macro" path = "lib.rs" crate-type = ["dylib"] [dependencies] -log = { path = "../liblog" } -rustc_plugin = { path = "../librustc_plugin" } syntax = { path = "../libsyntax" } -syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/libproc_macro/lib.rs b/src/libproc_macro/lib.rs index 9e25cb88e01..4b9b92fb3bb 100644 --- a/src/libproc_macro/lib.rs +++ b/src/libproc_macro/lib.rs @@ -8,130 +8,160 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -//! # Proc_Macro +//! A support library for macro authors when defining new macros. //! -//! A library for procedural macro writers. +//! This library, provided by the standard distribution, provides the types +//! consumed in the interfaces of procedurally defined macro definitions. +//! Currently the primary use of this crate is to provide the ability to define +//! new custom derive modes through `#[proc_macro_derive]`. //! -//! ## Usage -//! This package provides the `qquote!` macro for syntax creation, and the prelude -//! (at libproc_macro::prelude) provides a number of operations: -//! - `concat`, for concatenating two TokenStreams. -//! - `ident_eq`, for checking if two identifiers are equal regardless of syntax context. -//! - `str_to_token_ident`, for converting an `&str` into a Token. -//! - `keyword_to_token_delim`, for converting a `parse::token::keywords::Keyword` into a -//! Token. -//! - `build_delimited`, for creating a new TokenStream from an existing one and a delimiter -//! by wrapping the TokenStream in the delimiter. -//! - `build_bracket_delimited`, `build_brace_delimited`, and `build_paren_delimited`, for -//! easing the above. -//! - `build_empty_args`, which returns a TokenStream containing `()`. -//! - `lex`, which takes an `&str` and returns the TokenStream it represents. +//! Added recently as part of [RFC 1681] this crate is currently *unstable* and +//! requires the `#![feature(proc_macro_lib)]` directive to use. //! -//! The `qquote!` macro also imports `syntax::ext::proc_macro_shim::prelude::*`, so you -//! will need to `extern crate syntax` for usage. (This is a temporary solution until more -//! of the external API in libproc_macro is stabilized to support the token construction -//! operations that the qausiquoter relies on.) The shim file also provides additional -//! operations, such as `build_block_emitter` (as used in the `cond` example below). -//! -//! ## TokenStreams -//! -//! TokenStreams serve as the basis of the macro system. They are, in essence, vectors of -//! TokenTrees, where indexing treats delimited values as a single term. That is, the term -//! `even(a+c) && even(b)` will be indexibly encoded as `even | (a+c) | even | (b)` where, -//! in reality, `(a+c)` is actually a decorated pointer to `a | + | c`. -//! -//! If a user has a TokenStream that is a single, delimited value, they can use -//! `maybe_delimited` to destruct it and receive the internal vector as a new TokenStream -//! as: -//! ``` -//! `(a+c)`.maybe_delimited() ~> Some(a | + | c)` -//! ``` -//! -//! Check the TokenStream documentation for more information; the structure also provides -//! cheap concatenation and slicing. -//! -//! ## Quasiquotation -//! -//! The quasiquoter creates output that, when run, constructs the tokenstream specified as -//! input. For example, `qquote!(5 + 5)` will produce a program, that, when run, will -//! construct the TokenStream `5 | + | 5`. -//! -//! ### Unquoting -//! -//! Unquoting is currently done as `unquote`, and works by taking the single next -//! TokenTree in the TokenStream as the unquoted term. Ergonomically, `unquote(foo)` works -//! fine, but `unquote foo` is also supported. -//! -//! A simple example might be: -//! -//!``` -//!fn double(tmp: TokenStream) -> TokenStream { -//! qquote!(unquote(tmp) * 2) -//!} -//!``` -//! -//! ### Large Example: Implementing Scheme's `cond` -//! -//! Below is the full implementation of Scheme's `cond` operator. -//! -//! ``` -//! fn cond_rec(input: TokenStream) -> TokenStream { -//! if input.is_empty() { return quote!(); } -//! -//! let next = input.slice(0..1); -//! let rest = input.slice_from(1..); -//! -//! let clause : TokenStream = match next.maybe_delimited() { -//! Some(ts) => ts, -//! _ => panic!("Invalid input"), -//! }; -//! -//! // clause is ([test]) [rhs] -//! if clause.len() < 2 { panic!("Invalid macro usage in cond: {:?}", clause) } -//! -//! let test: TokenStream = clause.slice(0..1); -//! let rhs: TokenStream = clause.slice_from(1..); -//! -//! if ident_eq(&test[0], str_to_ident("else")) || rest.is_empty() { -//! quote!({unquote(rhs)}) -//! } else { -//! quote!({if unquote(test) { unquote(rhs) } else { cond!(unquote(rest)) } }) -//! } -//! } -//! ``` +//! [RFC 1681]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md //! +//! Note that this crate is intentionally very bare-bones currently. The main +//! type, `TokenStream`, only supports `fmt::Display` and `FromStr` +//! implementations, indicating that it can only go to and come from a string. +//! This functionality is intended to be expanded over time as more surface +//! area for macro authors is stabilized. #![crate_name = "proc_macro"] -#![unstable(feature = "rustc_private", issue = "27812")] -#![feature(plugin_registrar)] -#![crate_type = "dylib"] +#![unstable(feature = "proc_macro_lib", issue = "27812")] #![crate_type = "rlib"] -#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", - html_favicon_url = "https://doc.rust-lang.org/favicon.ico", - html_root_url = "https://doc.rust-lang.org/nightly/")] +#![crate_type = "dylib"] #![cfg_attr(not(stage0), deny(warnings))] +#![deny(missing_docs)] -#![feature(staged_api)] -#![feature(rustc_diagnostic_macros)] #![feature(rustc_private)] +#![feature(staged_api)] +#![feature(lang_items)] -extern crate rustc_plugin; extern crate syntax; -extern crate syntax_pos; -#[macro_use] extern crate log; -mod qquote; -pub mod build; -pub mod parse; -pub mod prelude; -use qquote::qquote; +use std::fmt; +use std::str::FromStr; -use rustc_plugin::Registry; +use syntax::ast; +use syntax::parse; +use syntax::ptr::P; -// ____________________________________________________________________________________________ -// Main macro definition - -#[plugin_registrar] -pub fn plugin_registrar(reg: &mut Registry) { - reg.register_macro("qquote", qquote); +/// The main type provided by this crate, representing an abstract stream of +/// tokens. +/// +/// This is both the input and output of `#[proc_macro_derive]` definitions. +/// Currently it's required to be a list of valid Rust items, but this +/// restriction may be lifted in the future. +/// +/// The API of this type is intentionally bare-bones, but it'll be expanded over +/// time! +pub struct TokenStream { + inner: Vec>, +} + +/// Error returned from `TokenStream::from_str`. +#[derive(Debug)] +pub struct LexError { + _inner: (), +} + +/// Permanently unstable internal implementation details of this crate. This +/// should not be used. +/// +/// These methods are used by the rest of the compiler to generate instances of +/// `TokenStream` to hand to macro definitions, as well as consume the output. +/// +/// Note that this module is also intentionally separate from the rest of the +/// crate. This allows the `#[unstable]` directive below to naturally apply to +/// all of the contents. +#[unstable(feature = "proc_macro_internals", issue = "27812")] +#[doc(hidden)] +pub mod __internal { + use std::cell::Cell; + + use syntax::ast; + use syntax::ptr::P; + use syntax::parse::ParseSess; + use super::TokenStream; + + pub fn new_token_stream(item: P) -> TokenStream { + TokenStream { inner: vec![item] } + } + + pub fn token_stream_items(stream: TokenStream) -> Vec> { + stream.inner + } + + pub trait Registry { + fn register_custom_derive(&mut self, + trait_name: &str, + expand: fn(TokenStream) -> TokenStream); + } + + // Emulate scoped_thread_local!() here essentially + thread_local! { + static CURRENT_SESS: Cell<*const ParseSess> = Cell::new(0 as *const _); + } + + pub fn set_parse_sess(sess: &ParseSess, f: F) -> R + where F: FnOnce() -> R + { + struct Reset { prev: *const ParseSess } + + impl Drop for Reset { + fn drop(&mut self) { + CURRENT_SESS.with(|p| p.set(self.prev)); + } + } + + CURRENT_SESS.with(|p| { + let _reset = Reset { prev: p.get() }; + p.set(sess); + f() + }) + } + + pub fn with_parse_sess(f: F) -> R + where F: FnOnce(&ParseSess) -> R + { + let p = CURRENT_SESS.with(|p| p.get()); + assert!(!p.is_null()); + f(unsafe { &*p }) + } +} + +impl FromStr for TokenStream { + type Err = LexError; + + fn from_str(src: &str) -> Result { + __internal::with_parse_sess(|sess| { + let src = src.to_string(); + let cfg = Vec::new(); + let name = "".to_string(); + let mut parser = parse::new_parser_from_source_str(sess, cfg, name, + src); + let mut ret = TokenStream { inner: Vec::new() }; + loop { + match parser.parse_item() { + Ok(Some(item)) => ret.inner.push(item), + Ok(None) => return Ok(ret), + Err(mut err) => { + err.cancel(); + return Err(LexError { _inner: () }) + } + } + } + }) + } +} + +impl fmt::Display for TokenStream { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + for item in self.inner.iter() { + let item = syntax::print::pprust::item_to_string(item); + try!(f.write_str(&item)); + try!(f.write_str("\n")); + } + Ok(()) + } } diff --git a/src/librustc_macro/Cargo.toml b/src/libproc_macro_plugin/Cargo.toml similarity index 53% rename from src/librustc_macro/Cargo.toml rename to src/libproc_macro_plugin/Cargo.toml index 6b3ee21d9ac..70bb86d0f58 100644 --- a/src/librustc_macro/Cargo.toml +++ b/src/libproc_macro_plugin/Cargo.toml @@ -1,12 +1,14 @@ [package] authors = ["The Rust Project Developers"] -name = "rustc_macro" +name = "proc_macro_plugin" version = "0.0.0" [lib] -name = "rustc_macro" path = "lib.rs" crate-type = ["dylib"] [dependencies] +log = { path = "../liblog" } +rustc_plugin = { path = "../librustc_plugin" } syntax = { path = "../libsyntax" } +syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/libproc_macro/build.rs b/src/libproc_macro_plugin/build.rs similarity index 100% rename from src/libproc_macro/build.rs rename to src/libproc_macro_plugin/build.rs diff --git a/src/libproc_macro_plugin/lib.rs b/src/libproc_macro_plugin/lib.rs new file mode 100644 index 00000000000..e82e97b5134 --- /dev/null +++ b/src/libproc_macro_plugin/lib.rs @@ -0,0 +1,137 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +//! # Proc_Macro +//! +//! A library for procedural macro writers. +//! +//! ## Usage +//! This package provides the `qquote!` macro for syntax creation, and the prelude +//! (at libproc_macro::prelude) provides a number of operations: +//! - `concat`, for concatenating two TokenStreams. +//! - `ident_eq`, for checking if two identifiers are equal regardless of syntax context. +//! - `str_to_token_ident`, for converting an `&str` into a Token. +//! - `keyword_to_token_delim`, for converting a `parse::token::keywords::Keyword` into a +//! Token. +//! - `build_delimited`, for creating a new TokenStream from an existing one and a delimiter +//! by wrapping the TokenStream in the delimiter. +//! - `build_bracket_delimited`, `build_brace_delimited`, and `build_paren_delimited`, for +//! easing the above. +//! - `build_empty_args`, which returns a TokenStream containing `()`. +//! - `lex`, which takes an `&str` and returns the TokenStream it represents. +//! +//! The `qquote!` macro also imports `syntax::ext::proc_macro_shim::prelude::*`, so you +//! will need to `extern crate syntax` for usage. (This is a temporary solution until more +//! of the external API in libproc_macro is stabilized to support the token construction +//! operations that the qausiquoter relies on.) The shim file also provides additional +//! operations, such as `build_block_emitter` (as used in the `cond` example below). +//! +//! ## TokenStreams +//! +//! TokenStreams serve as the basis of the macro system. They are, in essence, vectors of +//! TokenTrees, where indexing treats delimited values as a single term. That is, the term +//! `even(a+c) && even(b)` will be indexibly encoded as `even | (a+c) | even | (b)` where, +//! in reality, `(a+c)` is actually a decorated pointer to `a | + | c`. +//! +//! If a user has a TokenStream that is a single, delimited value, they can use +//! `maybe_delimited` to destruct it and receive the internal vector as a new TokenStream +//! as: +//! ``` +//! `(a+c)`.maybe_delimited() ~> Some(a | + | c)` +//! ``` +//! +//! Check the TokenStream documentation for more information; the structure also provides +//! cheap concatenation and slicing. +//! +//! ## Quasiquotation +//! +//! The quasiquoter creates output that, when run, constructs the tokenstream specified as +//! input. For example, `qquote!(5 + 5)` will produce a program, that, when run, will +//! construct the TokenStream `5 | + | 5`. +//! +//! ### Unquoting +//! +//! Unquoting is currently done as `unquote`, and works by taking the single next +//! TokenTree in the TokenStream as the unquoted term. Ergonomically, `unquote(foo)` works +//! fine, but `unquote foo` is also supported. +//! +//! A simple example might be: +//! +//!``` +//!fn double(tmp: TokenStream) -> TokenStream { +//! qquote!(unquote(tmp) * 2) +//!} +//!``` +//! +//! ### Large Example: Implementing Scheme's `cond` +//! +//! Below is the full implementation of Scheme's `cond` operator. +//! +//! ``` +//! fn cond_rec(input: TokenStream) -> TokenStream { +//! if input.is_empty() { return quote!(); } +//! +//! let next = input.slice(0..1); +//! let rest = input.slice_from(1..); +//! +//! let clause : TokenStream = match next.maybe_delimited() { +//! Some(ts) => ts, +//! _ => panic!("Invalid input"), +//! }; +//! +//! // clause is ([test]) [rhs] +//! if clause.len() < 2 { panic!("Invalid macro usage in cond: {:?}", clause) } +//! +//! let test: TokenStream = clause.slice(0..1); +//! let rhs: TokenStream = clause.slice_from(1..); +//! +//! if ident_eq(&test[0], str_to_ident("else")) || rest.is_empty() { +//! quote!({unquote(rhs)}) +//! } else { +//! quote!({if unquote(test) { unquote(rhs) } else { cond!(unquote(rest)) } }) +//! } +//! } +//! ``` +//! + +#![crate_name = "proc_macro_plugin"] +#![unstable(feature = "rustc_private", issue = "27812")] +#![feature(plugin_registrar)] +#![crate_type = "dylib"] +#![crate_type = "rlib"] +#![doc(html_logo_url = "https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png", + html_favicon_url = "https://doc.rust-lang.org/favicon.ico", + html_root_url = "https://doc.rust-lang.org/nightly/")] +#![cfg_attr(not(stage0), deny(warnings))] + +#![feature(staged_api)] +#![feature(rustc_diagnostic_macros)] +#![feature(rustc_private)] + +extern crate rustc_plugin; +extern crate syntax; +extern crate syntax_pos; +#[macro_use] extern crate log; + +mod qquote; +pub mod build; +pub mod parse; +pub mod prelude; +use qquote::qquote; + +use rustc_plugin::Registry; + +// ____________________________________________________________________________________________ +// Main macro definition + +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_macro("qquote", qquote); +} diff --git a/src/libproc_macro/parse.rs b/src/libproc_macro_plugin/parse.rs similarity index 100% rename from src/libproc_macro/parse.rs rename to src/libproc_macro_plugin/parse.rs diff --git a/src/libproc_macro/prelude.rs b/src/libproc_macro_plugin/prelude.rs similarity index 100% rename from src/libproc_macro/prelude.rs rename to src/libproc_macro_plugin/prelude.rs diff --git a/src/libproc_macro/qquote.rs b/src/libproc_macro_plugin/qquote.rs similarity index 99% rename from src/libproc_macro/qquote.rs rename to src/libproc_macro_plugin/qquote.rs index 67d0c77b00d..b73d085656e 100644 --- a/src/libproc_macro/qquote.rs +++ b/src/libproc_macro_plugin/qquote.rs @@ -51,7 +51,7 @@ pub fn qquote<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[TokenTree]) let output = qquoter(cx, TokenStream::from_tts(tts.clone().to_owned())); debug!("\nQQ out: {}\n", pprust::tts_to_string(&output.to_tts()[..])); let imports = concat(lex("use syntax::ext::proc_macro_shim::prelude::*;"), - lex("use proc_macro::prelude::*;")); + lex("use proc_macro_plugin::prelude::*;")); build_block_emitter(cx, sp, build_brace_delimited(concat(imports, output))) } @@ -219,7 +219,7 @@ fn convert_complex_tts<'cx>(cx: &'cx mut ExtCtxt, tts: Vec) -> (Bindings, T let sep = build_delim_tok(qdl.delim); - pushes.push(build_mod_call(vec![str_to_ident("proc_macro"), + pushes.push(build_mod_call(vec![str_to_ident("proc_macro_plugin"), str_to_ident("build"), str_to_ident("build_delimited")], concat(from_tokens(vec![Token::Ident(new_id)]), diff --git a/src/librustc/middle/dependency_format.rs b/src/librustc/middle/dependency_format.rs index 159b7256c7a..656d3146fe5 100644 --- a/src/librustc/middle/dependency_format.rs +++ b/src/librustc/middle/dependency_format.rs @@ -141,12 +141,12 @@ fn calculate_type(sess: &session::Session, } // Everything else falls through below. This will happen either with the - // `-C prefer-dynamic` or because we're a rustc-macro crate. Note that - // rustc-macro crates are required to be dylibs, and they're currently + // `-C prefer-dynamic` or because we're a proc-macro crate. Note that + // proc-macro crates are required to be dylibs, and they're currently // required to link to libsyntax as well. config::CrateTypeExecutable | config::CrateTypeDylib | - config::CrateTypeRustcMacro => {}, + config::CrateTypeProcMacro => {}, } let mut formats = FnvHashMap(); diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index beffaff1e5b..a476d0f6f30 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -139,7 +139,7 @@ impl<'a, 'tcx> ReachableContext<'a, 'tcx> { fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ReachableContext<'a, 'tcx> { let any_library = tcx.sess.crate_types.borrow().iter().any(|ty| { *ty == config::CrateTypeRlib || *ty == config::CrateTypeDylib || - *ty == config::CrateTypeRustcMacro + *ty == config::CrateTypeProcMacro }); ReachableContext { tcx: tcx, diff --git a/src/librustc/middle/weak_lang_items.rs b/src/librustc/middle/weak_lang_items.rs index aa75c7a572b..2c08e17f8f1 100644 --- a/src/librustc/middle/weak_lang_items.rs +++ b/src/librustc/middle/weak_lang_items.rs @@ -71,7 +71,7 @@ fn verify(sess: &Session, items: &lang_items::LanguageItems) { let needs_check = sess.crate_types.borrow().iter().any(|kind| { match *kind { config::CrateTypeDylib | - config::CrateTypeRustcMacro | + config::CrateTypeProcMacro | config::CrateTypeCdylib | config::CrateTypeExecutable | config::CrateTypeStaticlib => true, diff --git a/src/librustc/session/config.rs b/src/librustc/session/config.rs index 3372f221729..c7b4a3dfca5 100644 --- a/src/librustc/session/config.rs +++ b/src/librustc/session/config.rs @@ -482,7 +482,7 @@ pub enum CrateType { CrateTypeRlib, CrateTypeStaticlib, CrateTypeCdylib, - CrateTypeRustcMacro, + CrateTypeProcMacro, } #[derive(Clone, Hash)] @@ -972,8 +972,8 @@ pub fn default_configuration(sess: &Session) -> ast::CrateConfig { if sess.opts.debug_assertions { ret.push(attr::mk_word_item(InternedString::new("debug_assertions"))); } - if sess.opts.crate_types.contains(&CrateTypeRustcMacro) { - ret.push(attr::mk_word_item(InternedString::new("rustc_macro"))); + if sess.opts.crate_types.contains(&CrateTypeProcMacro) { + ret.push(attr::mk_word_item(InternedString::new("proc_macro"))); } return ret; } @@ -1546,7 +1546,7 @@ pub fn parse_crate_types_from_list(list_list: Vec) -> Result CrateTypeDylib, "cdylib" => CrateTypeCdylib, "bin" => CrateTypeExecutable, - "rustc-macro" => CrateTypeRustcMacro, + "proc-macro" => CrateTypeProcMacro, _ => { return Err(format!("unknown crate type: `{}`", part)); @@ -1630,7 +1630,7 @@ impl fmt::Display for CrateType { CrateTypeRlib => "rlib".fmt(f), CrateTypeStaticlib => "staticlib".fmt(f), CrateTypeCdylib => "cdylib".fmt(f), - CrateTypeRustcMacro => "rustc-macro".fmt(f), + CrateTypeProcMacro => "proc-macro".fmt(f), } } } diff --git a/src/librustc/ty/context.rs b/src/librustc/ty/context.rs index b1f80455dd9..d371cc2f8ad 100644 --- a/src/librustc/ty/context.rs +++ b/src/librustc/ty/context.rs @@ -493,7 +493,7 @@ pub struct GlobalCtxt<'tcx> { pub layout_depth: Cell, /// Map from function to the `#[derive]` mode that it's defining. Only used - /// by `rustc-macro` crates. + /// by `proc-macro` crates. pub derive_macros: RefCell>, } diff --git a/src/librustc_driver/Cargo.toml b/src/librustc_driver/Cargo.toml index 772d83eb2cf..98e2aa88189 100644 --- a/src/librustc_driver/Cargo.toml +++ b/src/librustc_driver/Cargo.toml @@ -13,25 +13,25 @@ arena = { path = "../libarena" } flate = { path = "../libflate" } graphviz = { path = "../libgraphviz" } log = { path = "../liblog" } +proc_macro_plugin = { path = "../libproc_macro_plugin" } rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } rustc_borrowck = { path = "../librustc_borrowck" } rustc_const_eval = { path = "../librustc_const_eval" } rustc_errors = { path = "../librustc_errors" } +rustc_incremental = { path = "../librustc_incremental" } rustc_lint = { path = "../librustc_lint" } rustc_llvm = { path = "../librustc_llvm" } +rustc_metadata = { path = "../librustc_metadata" } rustc_mir = { path = "../librustc_mir" } -rustc_plugin = { path = "../librustc_plugin" } rustc_passes = { path = "../librustc_passes" } +rustc_plugin = { path = "../librustc_plugin" } rustc_privacy = { path = "../librustc_privacy" } -rustc_incremental = { path = "../librustc_incremental" } rustc_resolve = { path = "../librustc_resolve" } rustc_save_analysis = { path = "../librustc_save_analysis" } rustc_trans = { path = "../librustc_trans" } rustc_typeck = { path = "../librustc_typeck" } -rustc_metadata = { path = "../librustc_metadata" } serialize = { path = "../libserialize" } syntax = { path = "../libsyntax" } syntax_ext = { path = "../libsyntax_ext" } syntax_pos = { path = "../libsyntax_pos" } -proc_macro = { path = "../libproc_macro" } diff --git a/src/librustc_driver/driver.rs b/src/librustc_driver/driver.rs index 8059ef61eab..ea42f7ba93e 100644 --- a/src/librustc_driver/driver.rs +++ b/src/librustc_driver/driver.rs @@ -710,14 +710,14 @@ pub fn phase_2_configure_and_expand<'a, F>(sess: &Session, krate = time(time_passes, "maybe creating a macro crate", || { let crate_types = sess.crate_types.borrow(); let num_crate_types = crate_types.len(); - let is_rustc_macro_crate = crate_types.contains(&config::CrateTypeRustcMacro); - syntax_ext::rustc_macro_registrar::modify(&sess.parse_sess, - &mut resolver, - krate, - is_rustc_macro_crate, - num_crate_types, - sess.diagnostic(), - &sess.features.borrow()) + let is_proc_macro_crate = crate_types.contains(&config::CrateTypeProcMacro); + syntax_ext::proc_macro_registrar::modify(&sess.parse_sess, + &mut resolver, + krate, + is_proc_macro_crate, + num_crate_types, + sess.diagnostic(), + &sess.features.borrow()) }); } @@ -1181,8 +1181,8 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec { Some(config::CrateTypeStaticlib) } - Some(ref n) if *n == "rustc-macro" => { - Some(config::CrateTypeRustcMacro) + Some(ref n) if *n == "proc-macro" => { + Some(config::CrateTypeProcMacro) } Some(ref n) if *n == "bin" => Some(config::CrateTypeExecutable), Some(_) => { diff --git a/src/librustc_macro/lib.rs b/src/librustc_macro/lib.rs deleted file mode 100644 index 1f3b705671d..00000000000 --- a/src/librustc_macro/lib.rs +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -//! A support library for macro authors when defining new macros. -//! -//! This library, provided by the standard distribution, provides the types -//! consumed in the interfaces of procedurally defined macro definitions. -//! Currently the primary use of this crate is to provide the ability to define -//! new custom derive modes through `#[rustc_macro_derive]`. -//! -//! Added recently as part of [RFC 1681] this crate is currently *unstable* and -//! requires the `#![feature(rustc_macro_lib)]` directive to use. Eventually, -//! though, it is intended for this crate to become stable to use (perhaps under -//! a different name). -//! -//! [RFC 1681]: https://github.com/rust-lang/rfcs/blob/master/text/1681-macros-1.1.md -//! -//! Note that this crate is intentionally very bare-bones currently. The main -//! type, `TokenStream`, only supports `fmt::Display` and `FromStr` -//! implementations, indicating that it can only go to and come from a string. -//! This functionality is intended to be expanded over time as more surface -//! area for macro authors is stabilized. - -#![crate_name = "rustc_macro"] -#![unstable(feature = "rustc_macro_lib", issue = "27812")] -#![crate_type = "rlib"] -#![crate_type = "dylib"] -#![cfg_attr(not(stage0), deny(warnings))] -#![deny(missing_docs)] - -#![feature(rustc_private)] -#![feature(staged_api)] -#![feature(lang_items)] - -extern crate syntax; - -use std::fmt; -use std::str::FromStr; - -use syntax::ast; -use syntax::parse; -use syntax::ptr::P; - -/// The main type provided by this crate, representing an abstract stream of -/// tokens. -/// -/// This is both the input and output of `#[rustc_macro_derive]` definitions. -/// Currently it's required to be a list of valid Rust items, but this -/// restriction may be lifted in the future. -/// -/// The API of this type is intentionally bare-bones, but it'll be expanded over -/// time! -pub struct TokenStream { - inner: Vec>, -} - -/// Error returned from `TokenStream::from_str`. -#[derive(Debug)] -pub struct LexError { - _inner: (), -} - -/// Permanently unstable internal implementation details of this crate. This -/// should not be used. -/// -/// These methods are used by the rest of the compiler to generate instances of -/// `TokenStream` to hand to macro definitions, as well as consume the output. -/// -/// Note that this module is also intentionally separate from the rest of the -/// crate. This allows the `#[unstable]` directive below to naturally apply to -/// all of the contents. -#[unstable(feature = "rustc_macro_internals", issue = "27812")] -#[doc(hidden)] -pub mod __internal { - use std::cell::Cell; - - use syntax::ast; - use syntax::ptr::P; - use syntax::parse::ParseSess; - use super::TokenStream; - - pub fn new_token_stream(item: P) -> TokenStream { - TokenStream { inner: vec![item] } - } - - pub fn token_stream_items(stream: TokenStream) -> Vec> { - stream.inner - } - - pub trait Registry { - fn register_custom_derive(&mut self, - trait_name: &str, - expand: fn(TokenStream) -> TokenStream); - } - - // Emulate scoped_thread_local!() here essentially - thread_local! { - static CURRENT_SESS: Cell<*const ParseSess> = Cell::new(0 as *const _); - } - - pub fn set_parse_sess(sess: &ParseSess, f: F) -> R - where F: FnOnce() -> R - { - struct Reset { prev: *const ParseSess } - - impl Drop for Reset { - fn drop(&mut self) { - CURRENT_SESS.with(|p| p.set(self.prev)); - } - } - - CURRENT_SESS.with(|p| { - let _reset = Reset { prev: p.get() }; - p.set(sess); - f() - }) - } - - pub fn with_parse_sess(f: F) -> R - where F: FnOnce(&ParseSess) -> R - { - let p = CURRENT_SESS.with(|p| p.get()); - assert!(!p.is_null()); - f(unsafe { &*p }) - } -} - -impl FromStr for TokenStream { - type Err = LexError; - - fn from_str(src: &str) -> Result { - __internal::with_parse_sess(|sess| { - let src = src.to_string(); - let cfg = Vec::new(); - let name = "".to_string(); - let mut parser = parse::new_parser_from_source_str(sess, cfg, name, - src); - let mut ret = TokenStream { inner: Vec::new() }; - loop { - match parser.parse_item() { - Ok(Some(item)) => ret.inner.push(item), - Ok(None) => return Ok(ret), - Err(mut err) => { - err.cancel(); - return Err(LexError { _inner: () }) - } - } - } - }) - } -} - -impl fmt::Display for TokenStream { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - for item in self.inner.iter() { - let item = syntax::print::pprust::item_to_string(item); - try!(f.write_str(&item)); - try!(f.write_str("\n")); - } - Ok(()) - } -} diff --git a/src/librustc_metadata/Cargo.toml b/src/librustc_metadata/Cargo.toml index 680d55955bb..6f7f03ca216 100644 --- a/src/librustc_metadata/Cargo.toml +++ b/src/librustc_metadata/Cargo.toml @@ -11,13 +11,13 @@ crate-type = ["dylib"] [dependencies] flate = { path = "../libflate" } log = { path = "../liblog" } +proc_macro = { path = "../libproc_macro" } rustc = { path = "../librustc" } rustc_back = { path = "../librustc_back" } rustc_const_math = { path = "../librustc_const_math" } rustc_data_structures = { path = "../librustc_data_structures" } rustc_errors = { path = "../librustc_errors" } rustc_llvm = { path = "../librustc_llvm" } -rustc_macro = { path = "../librustc_macro" } serialize = { path = "../libserialize" } syntax = { path = "../libsyntax" } syntax_ext = { path = "../libsyntax_ext" } diff --git a/src/librustc_metadata/creader.rs b/src/librustc_metadata/creader.rs index 0c7f6204438..a57207dc089 100644 --- a/src/librustc_metadata/creader.rs +++ b/src/librustc_metadata/creader.rs @@ -311,7 +311,7 @@ impl<'a> CrateReader<'a> { let cnum_map = self.resolve_crate_deps(root, &crate_root, &metadata, cnum, span); if crate_root.macro_derive_registrar.is_some() { - self.sess.span_err(span, "crates of the `rustc-macro` crate type \ + self.sess.span_err(span, "crates of the `proc-macro` crate type \ cannot be linked at runtime"); } @@ -609,11 +609,11 @@ impl<'a> CrateReader<'a> { match root.macro_derive_registrar { Some(id) => ret.custom_derive_registrar = Some(id), - // If this crate is not a rustc-macro crate then we might be able to + // If this crate is not a proc-macro crate then we might be able to // register it with the local crate store to prevent loading the // metadata twice. // - // If it's a rustc-macro crate, though, then we definitely don't + // If it's a proc-macro crate, though, then we definitely don't // want to register it with the local crate store as we're just // going to use it as we would a plugin. None => { @@ -625,11 +625,11 @@ impl<'a> CrateReader<'a> { self.cstore.add_used_for_derive_macros(item); ret.dylib = ekrate.dylib.clone(); if ret.dylib.is_none() { - span_bug!(item.span, "rustc-macro crate not dylib"); + span_bug!(item.span, "proc-macro crate not dylib"); } if ekrate.target_only { - let message = format!("rustc-macro crate is not available for \ + let message = format!("proc-macro crate is not available for \ triple `{}` (only found {})", config::host_triple(), self.sess.opts.target_triple); @@ -804,7 +804,7 @@ impl<'a> CrateReader<'a> { match *ct { config::CrateTypeExecutable => need_exe_alloc = true, config::CrateTypeDylib | - config::CrateTypeRustcMacro | + config::CrateTypeProcMacro | config::CrateTypeCdylib | config::CrateTypeStaticlib => need_lib_alloc = true, config::CrateTypeRlib => {} diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 4d18462848e..01b106682bb 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -23,7 +23,7 @@ use rustc::traits::specialization_graph; use rustc::ty::{self, Ty, TyCtxt}; use rustc::mir::mir_map::MirMap; -use rustc::session::config::{self, CrateTypeRustcMacro}; +use rustc::session::config::{self, CrateTypeProcMacro}; use rustc::util::nodemap::{FnvHashMap, NodeSet}; use rustc_serialize::{Encodable, Encoder, SpecializedEncoder, opaque}; @@ -1286,7 +1286,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let tcx = self.tcx; let link_meta = self.link_meta; - let is_rustc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeRustcMacro); + let is_proc_macro = tcx.sess.crate_types.borrow().contains(&CrateTypeProcMacro); let root = self.lazy(&CrateRoot { rustc_version: rustc_version(), name: link_meta.crate_name.clone(), @@ -1297,7 +1297,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { plugin_registrar_fn: tcx.sess.plugin_registrar_fn.get().map(|id| { tcx.map.local_def_id(id).index }), - macro_derive_registrar: if is_rustc_macro { + macro_derive_registrar: if is_proc_macro { let id = tcx.sess.derive_registrar_fn.get().unwrap(); Some(tcx.map.local_def_id(id).index) } else { diff --git a/src/librustc_metadata/lib.rs b/src/librustc_metadata/lib.rs index 4fc5a46762d..acaafb35425 100644 --- a/src/librustc_metadata/lib.rs +++ b/src/librustc_metadata/lib.rs @@ -17,15 +17,15 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![cfg_attr(not(stage0), deny(warnings))] +#![feature(box_patterns)] #![feature(conservative_impl_trait)] #![feature(core_intrinsics)] -#![feature(box_patterns)] #![feature(dotdot_in_tuple_patterns)] +#![feature(proc_macro_internals)] +#![feature(proc_macro_lib)] #![feature(question_mark)] #![feature(quote)] #![feature(rustc_diagnostic_macros)] -#![feature(rustc_macro_lib)] -#![feature(rustc_macro_internals)] #![feature(rustc_private)] #![feature(specialization)] #![feature(staged_api)] @@ -37,14 +37,14 @@ extern crate flate; extern crate serialize as rustc_serialize; // used by deriving extern crate rustc_errors as errors; extern crate syntax_ext; +extern crate proc_macro; #[macro_use] extern crate rustc; -extern crate rustc_data_structures; extern crate rustc_back; -extern crate rustc_llvm; -extern crate rustc_macro; extern crate rustc_const_math; +extern crate rustc_data_structures; +extern crate rustc_llvm; mod diagnostics; diff --git a/src/librustc_metadata/macro_import.rs b/src/librustc_metadata/macro_import.rs index 385f582e2d3..7cd03b2d5b9 100644 --- a/src/librustc_metadata/macro_import.rs +++ b/src/librustc_metadata/macro_import.rs @@ -17,13 +17,13 @@ use std::mem; use creader::{CrateLoader, Macros}; +use proc_macro::TokenStream; +use proc_macro::__internal::Registry; use rustc::hir::def_id::DefIndex; use rustc::middle::cstore::{LoadedMacro, LoadedMacroKind}; use rustc::session::Session; use rustc::util::nodemap::FnvHashMap; use rustc_back::dynamic_lib::DynamicLibrary; -use rustc_macro::TokenStream; -use rustc_macro::__internal::Registry; use syntax::ast; use syntax::attr; use syntax::parse::token; @@ -145,13 +145,13 @@ impl<'a> CrateLoader<'a> { assert_eq!(ret.len(), 0); if let ImportSelection::Some(..) = import { - self.sess.span_err(vi.span, "`rustc-macro` crates cannot be \ + self.sess.span_err(vi.span, "`proc-macro` crates cannot be \ selectively imported from, must \ use `#[macro_use]`"); } if reexport.len() > 0 { - self.sess.span_err(vi.span, "`rustc-macro` crates cannot be \ + self.sess.span_err(vi.span, "`proc-macro` crates cannot be \ reexported from"); } diff --git a/src/librustc_resolve/build_reduced_graph.rs b/src/librustc_resolve/build_reduced_graph.rs index 2bf517600b7..eb4e3b2a3be 100644 --- a/src/librustc_resolve/build_reduced_graph.rs +++ b/src/librustc_resolve/build_reduced_graph.rs @@ -535,10 +535,10 @@ impl<'b> Resolver<'b> { } fn insert_custom_derive(&mut self, name: &str, ext: Rc, sp: Span) { - if !self.session.features.borrow().rustc_macro { + if !self.session.features.borrow().proc_macro { let sess = &self.session.parse_sess; let msg = "loading custom derive macro crates is experimentally supported"; - emit_feature_err(sess, "rustc_macro", sp, feature_gate::GateIssue::Language, msg); + emit_feature_err(sess, "proc_macro", sp, feature_gate::GateIssue::Language, msg); } if self.derive_modes.insert(token::intern(name), ext).is_some() { self.session.span_err(sp, &format!("cannot shadow existing derive mode `{}`", name)); diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 5dab82dbc7a..5a8c5cb4b82 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -239,7 +239,7 @@ pub fn invalid_output_for_target(sess: &Session, match (sess.target.target.options.dynamic_linking, sess.target.target.options.executables, crate_type) { (false, _, config::CrateTypeCdylib) | - (false, _, config::CrateTypeRustcMacro) | + (false, _, config::CrateTypeProcMacro) | (false, _, config::CrateTypeDylib) => true, (_, false, config::CrateTypeExecutable) => true, _ => false @@ -263,7 +263,7 @@ pub fn filename_for_input(sess: &Session, outputs.out_directory.join(&format!("lib{}.rlib", libname)) } config::CrateTypeCdylib | - config::CrateTypeRustcMacro | + config::CrateTypeProcMacro | config::CrateTypeDylib => { let (prefix, suffix) = (&sess.target.target.options.dll_prefix, &sess.target.target.options.dll_suffix); @@ -295,7 +295,7 @@ pub fn each_linked_rlib(sess: &Session, let fmts = fmts.get(&config::CrateTypeExecutable) .or_else(|| fmts.get(&config::CrateTypeStaticlib)) .or_else(|| fmts.get(&config::CrateTypeCdylib)) - .or_else(|| fmts.get(&config::CrateTypeRustcMacro)); + .or_else(|| fmts.get(&config::CrateTypeProcMacro)); let fmts = fmts.unwrap_or_else(|| { bug!("could not find formats for rlibs") }); @@ -736,7 +736,7 @@ fn link_args(cmd: &mut Linker, // executable. This metadata is in a separate object file from the main // object file, so we link that in here. if crate_type == config::CrateTypeDylib || - crate_type == config::CrateTypeRustcMacro { + crate_type == config::CrateTypeProcMacro { cmd.add_object(&outputs.with_extension("metadata.o")); } diff --git a/src/librustc_trans/back/linker.rs b/src/librustc_trans/back/linker.rs index dd14f98c920..3222571a76e 100644 --- a/src/librustc_trans/back/linker.rs +++ b/src/librustc_trans/back/linker.rs @@ -245,7 +245,7 @@ impl<'a> Linker for GnuLinker<'a> { // have far more public symbols than we actually want to export, so we // hide them all here. if crate_type == CrateType::CrateTypeDylib || - crate_type == CrateType::CrateTypeRustcMacro { + crate_type == CrateType::CrateTypeProcMacro { return } @@ -450,7 +450,7 @@ fn exported_symbols(scx: &SharedCrateContext, // See explanation in GnuLinker::export_symbols, for // why we don't ever need dylib symbols on non-MSVC. if crate_type == CrateType::CrateTypeDylib || - crate_type == CrateType::CrateTypeRustcMacro { + crate_type == CrateType::CrateTypeProcMacro { if !scx.sess().target.target.options.is_like_msvc { return vec![]; } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index b1d828d0e3e..3abe7626efc 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -862,7 +862,7 @@ impl<'feat> ExpansionConfig<'feat> { fn enable_allow_internal_unstable = allow_internal_unstable, fn enable_custom_derive = custom_derive, fn enable_pushpop_unsafe = pushpop_unsafe, - fn enable_rustc_macro = rustc_macro, + fn enable_proc_macro = proc_macro, } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 079d7175822..9eed1d61244 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -292,7 +292,7 @@ declare_features! ( (active, item_like_imports, "1.13.0", Some(35120)), // Macros 1.1 - (active, rustc_macro, "1.13.0", Some(35900)), + (active, proc_macro, "1.13.0", Some(35900)), // Allows untagged unions `union U { ... }` (active, untagged_unions, "1.13.0", Some(32836)), @@ -576,10 +576,10 @@ pub const KNOWN_ATTRIBUTES: &'static [(&'static str, AttributeType, AttributeGat is an experimental feature", cfg_fn!(linked_from))), - ("rustc_macro_derive", Normal, Gated("rustc_macro", - "the `#[rustc_macro_derive]` attribute \ - is an experimental feature", - cfg_fn!(rustc_macro))), + ("proc_macro_derive", Normal, Gated("proc_macro", + "the `#[proc_macro_derive]` attribute \ + is an experimental feature", + cfg_fn!(proc_macro))), ("rustc_copy_clone_marker", Whitelisted, Gated("rustc_attrs", "internal implementation detail", @@ -658,7 +658,7 @@ const GATED_CFGS: &'static [(&'static str, &'static str, fn(&Features) -> bool)] ("target_vendor", "cfg_target_vendor", cfg_fn!(cfg_target_vendor)), ("target_thread_local", "cfg_target_thread_local", cfg_fn!(cfg_target_thread_local)), ("target_has_atomic", "cfg_target_has_atomic", cfg_fn!(cfg_target_has_atomic)), - ("rustc_macro", "rustc_macro", cfg_fn!(rustc_macro)), + ("proc_macro", "proc_macro", cfg_fn!(proc_macro)), ]; #[derive(Debug, Eq, PartialEq)] diff --git a/src/libsyntax_ext/Cargo.toml b/src/libsyntax_ext/Cargo.toml index 6910e6400d4..960db792a62 100644 --- a/src/libsyntax_ext/Cargo.toml +++ b/src/libsyntax_ext/Cargo.toml @@ -11,7 +11,7 @@ crate-type = ["dylib"] [dependencies] fmt_macros = { path = "../libfmt_macros" } log = { path = "../liblog" } +proc_macro = { path = "../libproc_macro" } rustc_errors = { path = "../librustc_errors" } -rustc_macro = { path = "../librustc_macro" } syntax = { path = "../libsyntax" } syntax_pos = { path = "../libsyntax_pos" } diff --git a/src/libsyntax_ext/deriving/custom.rs b/src/libsyntax_ext/deriving/custom.rs index 624fabd1424..f8cb1294a66 100644 --- a/src/libsyntax_ext/deriving/custom.rs +++ b/src/libsyntax_ext/deriving/custom.rs @@ -11,7 +11,7 @@ use std::panic; use errors::FatalError; -use rustc_macro::{TokenStream, __internal}; +use proc_macro::{TokenStream, __internal}; use syntax::ast::{self, ItemKind}; use syntax::codemap::{ExpnInfo, MacroAttribute, NameAndSpan, Span}; use syntax::ext::base::*; diff --git a/src/libsyntax_ext/lib.rs b/src/libsyntax_ext/lib.rs index 6e4f3dde4bd..e9d2c0a503b 100644 --- a/src/libsyntax_ext/lib.rs +++ b/src/libsyntax_ext/lib.rs @@ -20,8 +20,8 @@ #![cfg_attr(not(stage0), deny(warnings))] #![feature(dotdot_in_tuple_patterns)] -#![feature(rustc_macro_lib)] -#![feature(rustc_macro_internals)] +#![feature(proc_macro_lib)] +#![feature(proc_macro_internals)] #![feature(rustc_private)] #![feature(staged_api)] @@ -31,7 +31,7 @@ extern crate log; #[macro_use] extern crate syntax; extern crate syntax_pos; -extern crate rustc_macro; +extern crate proc_macro; extern crate rustc_errors as errors; mod asm; @@ -43,7 +43,7 @@ mod format; mod log_syntax; mod trace_macros; -pub mod rustc_macro_registrar; +pub mod proc_macro_registrar; // for custom_derive pub mod deriving; diff --git a/src/libsyntax_ext/rustc_macro_registrar.rs b/src/libsyntax_ext/proc_macro_registrar.rs similarity index 81% rename from src/libsyntax_ext/rustc_macro_registrar.rs rename to src/libsyntax_ext/proc_macro_registrar.rs index ce3e53cdf97..b96fb08e59e 100644 --- a/src/libsyntax_ext/rustc_macro_registrar.rs +++ b/src/libsyntax_ext/proc_macro_registrar.rs @@ -36,45 +36,45 @@ struct CollectCustomDerives<'a> { derives: Vec, in_root: bool, handler: &'a errors::Handler, - is_rustc_macro_crate: bool, + is_proc_macro_crate: bool, } pub fn modify(sess: &ParseSess, resolver: &mut ::syntax::ext::base::Resolver, mut krate: ast::Crate, - is_rustc_macro_crate: bool, + is_proc_macro_crate: bool, num_crate_types: usize, handler: &errors::Handler, features: &Features) -> ast::Crate { - let ecfg = ExpansionConfig::default("rustc_macro".to_string()); + let ecfg = ExpansionConfig::default("proc_macro".to_string()); let mut cx = ExtCtxt::new(sess, Vec::new(), ecfg, resolver); let mut collect = CollectCustomDerives { derives: Vec::new(), in_root: true, handler: handler, - is_rustc_macro_crate: is_rustc_macro_crate, + is_proc_macro_crate: is_proc_macro_crate, }; visit::walk_crate(&mut collect, &krate); - if !is_rustc_macro_crate { + if !is_proc_macro_crate { return krate - } else if !features.rustc_macro { - let mut err = handler.struct_err("the `rustc-macro` crate type is \ + } else if !features.proc_macro { + let mut err = handler.struct_err("the `proc-macro` crate type is \ experimental"); - err.help("add #![feature(rustc_macro)] to the crate attributes to \ + err.help("add #![feature(proc_macro)] to the crate attributes to \ enable"); err.emit(); } if num_crate_types > 1 { - handler.err("cannot mix `rustc-macro` crate type with others"); + handler.err("cannot mix `proc-macro` crate type with others"); } krate.module.items.push(mk_registrar(&mut cx, &collect.derives)); if krate.exported_macros.len() > 0 { - handler.err("cannot export macro_rules! macros from a `rustc-macro` \ + handler.err("cannot export macro_rules! macros from a `proc-macro` \ crate type currently"); } @@ -83,13 +83,13 @@ pub fn modify(sess: &ParseSess, impl<'a> CollectCustomDerives<'a> { fn check_not_pub_in_root(&self, vis: &ast::Visibility, sp: Span) { - if self.is_rustc_macro_crate && + if self.is_proc_macro_crate && self.in_root && *vis == ast::Visibility::Public { self.handler.span_err(sp, - "`rustc-macro` crate types cannot \ + "`proc-macro` crate types cannot \ export any items other than functions \ - tagged with `#[rustc_macro_derive]` \ + tagged with `#[proc_macro_derive]` \ currently"); } } @@ -100,7 +100,7 @@ impl<'a> Visitor for CollectCustomDerives<'a> { // First up, make sure we're checking a bare function. If we're not then // we're just not interested in this item. // - // If we find one, try to locate a `#[rustc_macro_derive]` attribute on + // If we find one, try to locate a `#[proc_macro_derive]` attribute on // it. match item.node { ast::ItemKind::Fn(..) => {} @@ -111,7 +111,7 @@ impl<'a> Visitor for CollectCustomDerives<'a> { } let mut attrs = item.attrs.iter() - .filter(|a| a.check_name("rustc_macro_derive")); + .filter(|a| a.check_name("proc_macro_derive")); let attr = match attrs.next() { Some(attr) => attr, None => { @@ -121,25 +121,25 @@ impl<'a> Visitor for CollectCustomDerives<'a> { }; if let Some(a) = attrs.next() { - self.handler.span_err(a.span(), "multiple `#[rustc_macro_derive]` \ + self.handler.span_err(a.span(), "multiple `#[proc_macro_derive]` \ attributes found"); } - if !self.is_rustc_macro_crate { + if !self.is_proc_macro_crate { self.handler.span_err(attr.span(), - "the `#[rustc_macro_derive]` attribute is \ - only usable with crates of the `rustc-macro` \ + "the `#[proc_macro_derive]` attribute is \ + only usable with crates of the `proc-macro` \ crate type"); } - // Once we've located the `#[rustc_macro_derive]` attribute, verify - // that it's of the form `#[rustc_macro_derive(Foo)]` + // Once we've located the `#[proc_macro_derive]` attribute, verify + // that it's of the form `#[proc_macro_derive(Foo)]` let list = match attr.meta_item_list() { Some(list) => list, None => { self.handler.span_err(attr.span(), "attribute must be of form: \ - #[rustc_macro_derive(TraitName)]"); + #[proc_macro_derive(TraitName)]"); return } }; @@ -177,7 +177,7 @@ impl<'a> Visitor for CollectCustomDerives<'a> { function_name: item.ident, }); } else { - let msg = "functions tagged with `#[rustc_macro_derive]` must \ + let msg = "functions tagged with `#[proc_macro_derive]` must \ currently reside in the root of the crate"; self.handler.span_err(item.span, msg); } @@ -202,9 +202,9 @@ impl<'a> Visitor for CollectCustomDerives<'a> { // Creates a new module which looks like: // // mod $gensym { -// extern crate rustc_macro; +// extern crate proc_macro; // -// use rustc_macro::__internal::Registry; +// use proc_macro::__internal::Registry; // // #[plugin_registrar] // fn registrar(registrar: &mut Registry) { @@ -218,16 +218,16 @@ fn mk_registrar(cx: &mut ExtCtxt, let eid = cx.codemap().record_expansion(ExpnInfo { call_site: DUMMY_SP, callee: NameAndSpan { - format: MacroAttribute(token::intern("rustc_macro")), + format: MacroAttribute(token::intern("proc_macro")), span: None, allow_internal_unstable: true, } }); let span = Span { expn_id: eid, ..DUMMY_SP }; - let rustc_macro = token::str_to_ident("rustc_macro"); + let proc_macro = token::str_to_ident("proc_macro"); let krate = cx.item(span, - rustc_macro, + proc_macro, Vec::new(), ast::ItemKind::ExternCrate(None)); @@ -241,7 +241,7 @@ fn mk_registrar(cx: &mut ExtCtxt, (path, trait_name) }).map(|(path, trait_name)| { let registrar = cx.expr_ident(span, registrar); - let ufcs_path = cx.path(span, vec![rustc_macro, __internal, registry, + let ufcs_path = cx.path(span, vec![proc_macro, __internal, registry, register_custom_derive]); cx.expr_call(span, cx.expr_path(ufcs_path), @@ -250,7 +250,7 @@ fn mk_registrar(cx: &mut ExtCtxt, cx.stmt_expr(expr) }).collect::>(); - let path = cx.path(span, vec![rustc_macro, __internal, registry]); + let path = cx.path(span, vec![proc_macro, __internal, registry]); let registrar_path = cx.ty_path(path); let arg_ty = cx.ty_rptr(span, registrar_path, None, ast::Mutability::Mutable); let func = cx.item_fn(span, diff --git a/src/rustc/Cargo.lock b/src/rustc/Cargo.lock index 69e3eab22e9..192d14b8fb1 100644 --- a/src/rustc/Cargo.lock +++ b/src/rustc/Cargo.lock @@ -43,6 +43,13 @@ version = "0.0.0" [[package]] name = "proc_macro" version = "0.0.0" +dependencies = [ + "syntax 0.0.0", +] + +[[package]] +name = "proc_macro_plugin" +version = "0.0.0" dependencies = [ "log 0.0.0", "rustc_plugin 0.0.0", @@ -137,7 +144,7 @@ dependencies = [ "flate 0.0.0", "graphviz 0.0.0", "log 0.0.0", - "proc_macro 0.0.0", + "proc_macro_plugin 0.0.0", "rustc 0.0.0", "rustc_back 0.0.0", "rustc_borrowck 0.0.0", @@ -204,26 +211,19 @@ dependencies = [ "rustc_bitflags 0.0.0", ] -[[package]] -name = "rustc_macro" -version = "0.0.0" -dependencies = [ - "syntax 0.0.0", -] - [[package]] name = "rustc_metadata" version = "0.0.0" dependencies = [ "flate 0.0.0", "log 0.0.0", + "proc_macro 0.0.0", "rustc 0.0.0", "rustc_back 0.0.0", "rustc_const_math 0.0.0", "rustc_data_structures 0.0.0", "rustc_errors 0.0.0", "rustc_llvm 0.0.0", - "rustc_macro 0.0.0", "serialize 0.0.0", "syntax 0.0.0", "syntax_ext 0.0.0", @@ -396,8 +396,8 @@ version = "0.0.0" dependencies = [ "fmt_macros 0.0.0", "log 0.0.0", + "proc_macro 0.0.0", "rustc_errors 0.0.0", - "rustc_macro 0.0.0", "syntax 0.0.0", "syntax_pos 0.0.0", ] diff --git a/src/test/compile-fail-fulldeps/rustc-macro/at-the-root.rs b/src/test/compile-fail-fulldeps/proc-macro/at-the-root.rs similarity index 73% rename from src/test/compile-fail-fulldeps/rustc-macro/at-the-root.rs rename to src/test/compile-fail-fulldeps/proc-macro/at-the-root.rs index 46724523d1c..b03e1e4f919 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/at-the-root.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/at-the-root.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] -extern crate rustc_macro; +extern crate proc_macro; -pub mod a { //~ `rustc-macro` crate types cannot export any items - use rustc_macro::TokenStream; +pub mod a { //~ `proc-macro` crate types cannot export any items + use proc_macro::TokenStream; - #[rustc_macro_derive(B)] + #[proc_macro_derive(B)] pub fn bar(a: TokenStream) -> TokenStream { //~^ ERROR: must currently reside in the root of the crate a diff --git a/src/test/compile-fail-fulldeps/proc-macro/attribute.rs b/src/test/compile-fail-fulldeps/proc-macro/attribute.rs new file mode 100644 index 00000000000..d1b2aa330ed --- /dev/null +++ b/src/test/compile-fail-fulldeps/proc-macro/attribute.rs @@ -0,0 +1,46 @@ +// Copyright 2016 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +#![crate_type = "proc-macro"] +#![feature(proc_macro)] + +extern crate proc_macro; + +#[proc_macro_derive] +//~^ ERROR: attribute must be of form: #[proc_macro_derive(TraitName)] +pub fn foo1(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive = "foo"] +//~^ ERROR: attribute must be of form: #[proc_macro_derive(TraitName)] +pub fn foo2(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive( + a = "b" +)] +//~^^ ERROR: must only be one word +pub fn foo3(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive(b, c)] +//~^ ERROR: attribute must only have one argument +pub fn foo4(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} + +#[proc_macro_derive(d(e))] +//~^ ERROR: must only be one word +pub fn foo5(input: proc_macro::TokenStream) -> proc_macro::TokenStream { + input +} diff --git a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-a-2.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-2.rs similarity index 77% rename from src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-a-2.rs rename to src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-2.rs index ff00a9d96a3..4aa4238611d 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-a-2.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a-2.rs @@ -11,15 +11,15 @@ // force-host // no-prefer-dynamic -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] -#![crate_type = "rustc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] +#![crate_type = "proc-macro"] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(A)] +#[proc_macro_derive(A)] pub fn derive_a(input: TokenStream) -> TokenStream { input } diff --git a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-a.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a.rs similarity index 77% rename from src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-a.rs rename to src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a.rs index ff00a9d96a3..4aa4238611d 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-a.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-a.rs @@ -11,15 +11,15 @@ // force-host // no-prefer-dynamic -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] -#![crate_type = "rustc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] +#![crate_type = "proc-macro"] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(A)] +#[proc_macro_derive(A)] pub fn derive_a(input: TokenStream) -> TokenStream { input } diff --git a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-bad.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-bad.rs similarity index 78% rename from src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-bad.rs rename to src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-bad.rs index 5dd42d28b7b..aae8b63e253 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-bad.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-bad.rs @@ -11,15 +11,15 @@ // no-prefer-dynamic // force-host -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] -#![crate_type = "rustc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] +#![crate_type = "proc-macro"] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(A)] +#[proc_macro_derive(A)] pub fn derive_a(_input: TokenStream) -> TokenStream { "struct A { inner }".parse().unwrap() } diff --git a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-panic.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-panic.rs similarity index 77% rename from src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-panic.rs rename to src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-panic.rs index d867082ed5e..f426fe54376 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-panic.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-panic.rs @@ -11,15 +11,15 @@ // no-prefer-dynamic // force-host -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] -#![crate_type = "rustc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] +#![crate_type = "proc-macro"] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(A)] +#[proc_macro_derive(A)] pub fn derive_a(_input: TokenStream) -> TokenStream { panic!("nope!"); } diff --git a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-unstable-2.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable-2.rs similarity index 78% rename from src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-unstable-2.rs rename to src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable-2.rs index 9eebad89756..d8952e3478b 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-unstable-2.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable-2.rs @@ -11,15 +11,15 @@ // force-host // no-prefer-dynamic -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] -#![crate_type = "rustc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] +#![crate_type = "proc-macro"] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(Unstable)] +#[proc_macro_derive(Unstable)] pub fn derive(_input: TokenStream) -> TokenStream { " diff --git a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-unstable.rs b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable.rs similarity index 78% rename from src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-unstable.rs rename to src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable.rs index f4a1ec99700..1187b5102e2 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/auxiliary/derive-unstable.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/auxiliary/derive-unstable.rs @@ -11,15 +11,15 @@ // force-host // no-prefer-dynamic -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] -#![crate_type = "rustc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] +#![crate_type = "proc-macro"] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(Unstable)] +#[proc_macro_derive(Unstable)] pub fn derive(_input: TokenStream) -> TokenStream { "unsafe fn foo() -> u32 { ::std::intrinsics::init() }".parse().unwrap() diff --git a/src/test/compile-fail-fulldeps/rustc-macro/cannot-link.rs b/src/test/compile-fail-fulldeps/proc-macro/cannot-link.rs similarity index 87% rename from src/test/compile-fail-fulldeps/rustc-macro/cannot-link.rs rename to src/test/compile-fail-fulldeps/proc-macro/cannot-link.rs index 1f135330a99..f6f1be37fc3 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/cannot-link.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/cannot-link.rs @@ -11,6 +11,6 @@ // aux-build:derive-a.rs extern crate derive_a; -//~^ ERROR: crates of the `rustc-macro` crate type cannot be linked at runtime +//~^ ERROR: crates of the `proc-macro` crate type cannot be linked at runtime fn main() {} diff --git a/src/test/compile-fail-fulldeps/rustc-macro/define-two.rs b/src/test/compile-fail-fulldeps/proc-macro/define-two.rs similarity index 74% rename from src/test/compile-fail-fulldeps/rustc-macro/define-two.rs rename to src/test/compile-fail-fulldeps/proc-macro/define-two.rs index e4f21dc2384..420249b2581 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/define-two.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/define-two.rs @@ -10,19 +10,19 @@ // no-prefer-dynamic -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(A)] +#[proc_macro_derive(A)] pub fn foo(input: TokenStream) -> TokenStream { input } -#[rustc_macro_derive(A)] //~ ERROR: derive mode defined twice in this crate +#[proc_macro_derive(A)] //~ ERROR: derive mode defined twice in this crate pub fn bar(input: TokenStream) -> TokenStream { input } diff --git a/src/test/compile-fail-fulldeps/rustc-macro/derive-bad.rs b/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs similarity index 96% rename from src/test/compile-fail-fulldeps/rustc-macro/derive-bad.rs rename to src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs index f3a73af2993..4cc6b9f984c 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/derive-bad.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/derive-bad.rs @@ -10,7 +10,7 @@ // aux-build:derive-bad.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #[macro_use] extern crate derive_bad; diff --git a/src/test/compile-fail-fulldeps/rustc-macro/derive-still-gated.rs b/src/test/compile-fail-fulldeps/proc-macro/derive-still-gated.rs similarity index 96% rename from src/test/compile-fail-fulldeps/rustc-macro/derive-still-gated.rs rename to src/test/compile-fail-fulldeps/proc-macro/derive-still-gated.rs index a46d79f517f..eb0bb00be91 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/derive-still-gated.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/derive-still-gated.rs @@ -10,7 +10,7 @@ // aux-build:derive-a.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #![allow(warnings)] #[macro_use] diff --git a/src/test/compile-fail-fulldeps/rustc-macro/expand-to-unstable-2.rs b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs similarity index 96% rename from src/test/compile-fail-fulldeps/rustc-macro/expand-to-unstable-2.rs rename to src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs index 14c3d84e75b..23dcbe03b5f 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/expand-to-unstable-2.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable-2.rs @@ -10,7 +10,7 @@ // aux-build:derive-unstable-2.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #![allow(warnings)] #[macro_use] diff --git a/src/test/compile-fail-fulldeps/rustc-macro/expand-to-unstable.rs b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs similarity index 96% rename from src/test/compile-fail-fulldeps/rustc-macro/expand-to-unstable.rs rename to src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs index aa9aaa81156..fb86f6f1b65 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/expand-to-unstable.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/expand-to-unstable.rs @@ -10,7 +10,7 @@ // aux-build:derive-unstable.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #![allow(warnings)] #[macro_use] diff --git a/src/test/compile-fail-fulldeps/rustc-macro/export-macro.rs b/src/test/compile-fail-fulldeps/proc-macro/export-macro.rs similarity index 79% rename from src/test/compile-fail-fulldeps/rustc-macro/export-macro.rs rename to src/test/compile-fail-fulldeps/proc-macro/export-macro.rs index 759f3d32e16..48b73e73331 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/export-macro.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/export-macro.rs @@ -8,10 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: cannot export macro_rules! macros from a `rustc-macro` crate +// error-pattern: cannot export macro_rules! macros from a `proc-macro` crate -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] #[macro_export] macro_rules! foo { diff --git a/src/test/compile-fail-fulldeps/rustc-macro/exports.rs b/src/test/compile-fail-fulldeps/proc-macro/exports.rs similarity index 95% rename from src/test/compile-fail-fulldeps/rustc-macro/exports.rs rename to src/test/compile-fail-fulldeps/proc-macro/exports.rs index e985356dc58..41b94d04e8c 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/exports.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/exports.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_type = "rustc-macro"] +#![crate_type = "proc-macro"] #![allow(warnings)] pub fn a() {} //~ ERROR: cannot export any items diff --git a/src/test/compile-fail-fulldeps/rustc-macro/feature-gate-1.rs b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-1.rs similarity index 83% rename from src/test/compile-fail-fulldeps/rustc-macro/feature-gate-1.rs rename to src/test/compile-fail-fulldeps/proc-macro/feature-gate-1.rs index 86afc08cae8..f5618fc6425 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/feature-gate-1.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-1.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: the `rustc-macro` crate type is experimental +// error-pattern: the `proc-macro` crate type is experimental -#![crate_type = "rustc-macro"] +#![crate_type = "proc-macro"] diff --git a/src/test/compile-fail-fulldeps/rustc-macro/feature-gate-2.rs b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-2.rs similarity index 87% rename from src/test/compile-fail-fulldeps/rustc-macro/feature-gate-2.rs rename to src/test/compile-fail-fulldeps/proc-macro/feature-gate-2.rs index 1a19f6046d9..9c4053266f4 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/feature-gate-2.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-2.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate rustc_macro; //~ ERROR: use of unstable library feature +extern crate proc_macro; //~ ERROR: use of unstable library feature fn main() {} diff --git a/src/test/compile-fail-fulldeps/rustc-macro/feature-gate-3.rs b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-3.rs similarity index 83% rename from src/test/compile-fail-fulldeps/rustc-macro/feature-gate-3.rs rename to src/test/compile-fail-fulldeps/proc-macro/feature-gate-3.rs index 9f47f07bd02..bb6b5759622 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/feature-gate-3.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-3.rs @@ -8,8 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_type = "rustc-macro"] +#![crate_type = "proc-macro"] -#[rustc_macro_derive(Foo)] //~ ERROR: is an experimental feature +#[proc_macro_derive(Foo)] //~ ERROR: is an experimental feature pub fn foo() { } diff --git a/src/test/compile-fail-fulldeps/rustc-macro/feature-gate-4.rs b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-4.rs similarity index 100% rename from src/test/compile-fail-fulldeps/rustc-macro/feature-gate-4.rs rename to src/test/compile-fail-fulldeps/proc-macro/feature-gate-4.rs diff --git a/src/test/compile-fail-fulldeps/rustc-macro/feature-gate-5.rs b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-5.rs similarity index 87% rename from src/test/compile-fail-fulldeps/rustc-macro/feature-gate-5.rs rename to src/test/compile-fail-fulldeps/proc-macro/feature-gate-5.rs index e44b29a1705..672579ce8f1 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/feature-gate-5.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/feature-gate-5.rs @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#[cfg(rustc_macro)] //~ ERROR: experimental and subject to change +#[cfg(proc_macro)] //~ ERROR: experimental and subject to change fn foo() {} diff --git a/src/test/compile-fail-fulldeps/rustc-macro/import.rs b/src/test/compile-fail-fulldeps/proc-macro/import.rs similarity index 96% rename from src/test/compile-fail-fulldeps/rustc-macro/import.rs rename to src/test/compile-fail-fulldeps/proc-macro/import.rs index c1d0823cb6b..8f907183cc3 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/import.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/import.rs @@ -10,7 +10,7 @@ // aux-build:derive-a.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #![allow(warnings)] #[macro_use] diff --git a/src/test/compile-fail-fulldeps/rustc-macro/load-panic.rs b/src/test/compile-fail-fulldeps/proc-macro/load-panic.rs similarity index 96% rename from src/test/compile-fail-fulldeps/rustc-macro/load-panic.rs rename to src/test/compile-fail-fulldeps/proc-macro/load-panic.rs index 0d08d27c38e..39c27e82fa5 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/load-panic.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/load-panic.rs @@ -10,7 +10,7 @@ // aux-build:derive-panic.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #[macro_use] extern crate derive_panic; diff --git a/src/test/compile-fail-fulldeps/rustc-macro/require-rustc-macro-crate-type.rs b/src/test/compile-fail-fulldeps/proc-macro/require-rustc-macro-crate-type.rs similarity index 69% rename from src/test/compile-fail-fulldeps/rustc-macro/require-rustc-macro-crate-type.rs rename to src/test/compile-fail-fulldeps/proc-macro/require-rustc-macro-crate-type.rs index cdc50acea92..44397cdde0c 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/require-rustc-macro-crate-type.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/require-rustc-macro-crate-type.rs @@ -8,13 +8,13 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(rustc_macro)] +#![feature(proc_macro)] -extern crate rustc_macro; +extern crate proc_macro; -#[rustc_macro_derive(Foo)] -//~^ ERROR: only usable with crates of the `rustc-macro` crate type -pub fn foo(a: rustc_macro::TokenStream) -> rustc_macro::TokenStream { +#[proc_macro_derive(Foo)] +//~^ ERROR: only usable with crates of the `proc-macro` crate type +pub fn foo(a: proc_macro::TokenStream) -> proc_macro::TokenStream { a } diff --git a/src/test/compile-fail-fulldeps/rustc-macro/shadow-builtin.rs b/src/test/compile-fail-fulldeps/proc-macro/shadow-builtin.rs similarity index 80% rename from src/test/compile-fail-fulldeps/rustc-macro/shadow-builtin.rs rename to src/test/compile-fail-fulldeps/proc-macro/shadow-builtin.rs index 1353a234b48..5cb2cc59aab 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/shadow-builtin.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/shadow-builtin.rs @@ -8,14 +8,14 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(PartialEq)] +#[proc_macro_derive(PartialEq)] //~^ ERROR: cannot override a built-in #[derive] mode pub fn foo(input: TokenStream) -> TokenStream { input diff --git a/src/test/compile-fail-fulldeps/rustc-macro/shadow.rs b/src/test/compile-fail-fulldeps/proc-macro/shadow.rs similarity index 96% rename from src/test/compile-fail-fulldeps/rustc-macro/shadow.rs rename to src/test/compile-fail-fulldeps/proc-macro/shadow.rs index 33330ed8f6a..7b1a73d50f6 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/shadow.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/shadow.rs @@ -11,7 +11,7 @@ // aux-build:derive-a.rs // aux-build:derive-a-2.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #[macro_use] extern crate derive_a; diff --git a/src/test/compile-fail-fulldeps/rustc-macro/signature.rs b/src/test/compile-fail-fulldeps/proc-macro/signature.rs similarity index 78% rename from src/test/compile-fail-fulldeps/rustc-macro/signature.rs rename to src/test/compile-fail-fulldeps/proc-macro/signature.rs index 9662cc69e1e..468c970599e 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/signature.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/signature.rs @@ -8,17 +8,17 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] #![allow(warnings)] -extern crate rustc_macro; +extern crate proc_macro; -#[rustc_macro_derive(A)] +#[proc_macro_derive(A)] unsafe extern fn foo(a: i32, b: u32) -> u32 { //~^ ERROR: mismatched types //~| NOTE: expected normal fn, found unsafe fn - //~| NOTE: expected type `fn(rustc_macro::TokenStream) -> rustc_macro::TokenStream` + //~| NOTE: expected type `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` //~| NOTE: found type `unsafe extern "C" fn(i32, u32) -> u32 {foo}` loop {} } diff --git a/src/test/compile-fail-fulldeps/rustc-macro/two-crate-types-1.rs b/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-1.rs similarity index 83% rename from src/test/compile-fail-fulldeps/rustc-macro/two-crate-types-1.rs rename to src/test/compile-fail-fulldeps/proc-macro/two-crate-types-1.rs index 35f6149ad49..db646fb7815 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/two-crate-types-1.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: cannot mix `rustc-macro` crate type with others +// error-pattern: cannot mix `proc-macro` crate type with others -#![crate_type = "rustc-macro"] +#![crate_type = "proc-macro"] #![crate_type = "rlib"] diff --git a/src/test/compile-fail-fulldeps/rustc-macro/two-crate-types-2.rs b/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-2.rs similarity index 78% rename from src/test/compile-fail-fulldeps/rustc-macro/two-crate-types-2.rs rename to src/test/compile-fail-fulldeps/proc-macro/two-crate-types-2.rs index ec95e3e4685..97b0f844604 100644 --- a/src/test/compile-fail-fulldeps/rustc-macro/two-crate-types-2.rs +++ b/src/test/compile-fail-fulldeps/proc-macro/two-crate-types-2.rs @@ -8,5 +8,5 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: cannot mix `rustc-macro` crate type with others -// compile-flags: --crate-type rlib --crate-type rustc-macro +// error-pattern: cannot mix `proc-macro` crate type with others +// compile-flags: --crate-type rlib --crate-type proc-macro diff --git a/src/test/compile-fail-fulldeps/rustc-macro/attribute.rs b/src/test/compile-fail-fulldeps/rustc-macro/attribute.rs deleted file mode 100644 index 7740238aeac..00000000000 --- a/src/test/compile-fail-fulldeps/rustc-macro/attribute.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright 2016 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] - -extern crate rustc_macro; - -#[rustc_macro_derive] -//~^ ERROR: attribute must be of form: #[rustc_macro_derive(TraitName)] -pub fn foo1(input: rustc_macro::TokenStream) -> rustc_macro::TokenStream { - input -} - -#[rustc_macro_derive = "foo"] -//~^ ERROR: attribute must be of form: #[rustc_macro_derive(TraitName)] -pub fn foo2(input: rustc_macro::TokenStream) -> rustc_macro::TokenStream { - input -} - -#[rustc_macro_derive( - a = "b" -)] -//~^^ ERROR: must only be one word -pub fn foo3(input: rustc_macro::TokenStream) -> rustc_macro::TokenStream { - input -} - -#[rustc_macro_derive(b, c)] -//~^ ERROR: attribute must only have one argument -pub fn foo4(input: rustc_macro::TokenStream) -> rustc_macro::TokenStream { - input -} - -#[rustc_macro_derive(d(e))] -//~^ ERROR: must only be one word -pub fn foo5(input: rustc_macro::TokenStream) -> rustc_macro::TokenStream { - input -} diff --git a/src/test/run-make/rustc-macro-dep-files/Makefile b/src/test/run-make/rustc-macro-dep-files/Makefile index d27b5d0f3c4..e3a6776c808 100644 --- a/src/test/run-make/rustc-macro-dep-files/Makefile +++ b/src/test/run-make/rustc-macro-dep-files/Makefile @@ -3,4 +3,4 @@ all: $(RUSTC) foo.rs $(RUSTC) bar.rs --emit dep-info - grep "rustc-macro source" $(TMPDIR)/bar.d && exit 1 || exit 0 + grep "proc-macro source" $(TMPDIR)/bar.d && exit 1 || exit 0 diff --git a/src/test/run-make/rustc-macro-dep-files/bar.rs b/src/test/run-make/rustc-macro-dep-files/bar.rs index dac652797e6..a2db98049d2 100644 --- a/src/test/run-make/rustc-macro-dep-files/bar.rs +++ b/src/test/run-make/rustc-macro-dep-files/bar.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(rustc_macro)] +#![feature(proc_macro)] #[macro_use] extern crate foo; diff --git a/src/test/run-make/rustc-macro-dep-files/foo.rs b/src/test/run-make/rustc-macro-dep-files/foo.rs index c302ca824d0..bd9e9158c50 100644 --- a/src/test/run-make/rustc-macro-dep-files/foo.rs +++ b/src/test/run-make/rustc-macro-dep-files/foo.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(A)] +#[proc_macro_derive(A)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); assert!(input.contains("struct A;")); diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs index 6aee63e2858..78589546084 100644 --- a/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/cond_noprelude_plugin.rs @@ -12,13 +12,13 @@ #![feature(plugin)] #![feature(plugin_registrar)] #![feature(rustc_private)] -#![plugin(proc_macro)] +#![plugin(proc_macro_plugin)] extern crate rustc_plugin; -extern crate proc_macro; +extern crate proc_macro_plugin; extern crate syntax; -use proc_macro::build::ident_eq; +use proc_macro_plugin::build::ident_eq; use syntax::ext::base::{ExtCtxt, MacResult}; use syntax::ext::proc_macro_shim::build_block_emitter; diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs index 8291c8a1e41..11322bf76ff 100644 --- a/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/cond_plugin.rs @@ -12,13 +12,13 @@ #![feature(plugin)] #![feature(plugin_registrar)] #![feature(rustc_private)] -#![plugin(proc_macro)] +#![plugin(proc_macro_plugin)] extern crate rustc_plugin; -extern crate proc_macro; +extern crate proc_macro_plugin; extern crate syntax; -use proc_macro::prelude::*; +use proc_macro_plugin::prelude::*; use rustc_plugin::Registry; diff --git a/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs b/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs index 2d92a0ef181..232a7166e3b 100644 --- a/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs +++ b/src/test/run-pass-fulldeps/auxiliary/cond_prelude_plugin.rs @@ -12,14 +12,14 @@ #![feature(plugin)] #![feature(plugin_registrar)] #![feature(rustc_private)] -#![plugin(proc_macro)] +#![plugin(proc_macro_plugin)] extern crate rustc_plugin; -extern crate proc_macro; +extern crate proc_macro_plugin; extern crate syntax; use syntax::ext::proc_macro_shim::prelude::*; -use proc_macro::prelude::*; +use proc_macro_plugin::prelude::*; use rustc_plugin::Registry; diff --git a/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs b/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs index 52c38a6ee03..961df6d5c0c 100644 --- a/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs +++ b/src/test/run-pass-fulldeps/auxiliary/proc_macro_def.rs @@ -10,11 +10,11 @@ #![feature(plugin, plugin_registrar, rustc_private)] -extern crate proc_macro; +extern crate proc_macro_plugin; extern crate rustc_plugin; extern crate syntax; -use proc_macro::prelude::*; +use proc_macro_plugin::prelude::*; use rustc_plugin::Registry; use syntax::ext::base::SyntaxExtension; use syntax::ext::proc_macro_shim::prelude::*; diff --git a/src/test/run-pass-fulldeps/macro-quote-1.rs b/src/test/run-pass-fulldeps/macro-quote-1.rs index 4ee775dec0c..a5ac546cba4 100644 --- a/src/test/run-pass-fulldeps/macro-quote-1.rs +++ b/src/test/run-pass-fulldeps/macro-quote-1.rs @@ -12,10 +12,10 @@ #![feature(plugin)] #![feature(rustc_private)] -#![plugin(proc_macro)] +#![plugin(proc_macro_plugin)] -extern crate proc_macro; -use proc_macro::prelude::*; +extern crate proc_macro_plugin; +use proc_macro_plugin::prelude::*; extern crate syntax; use syntax::ast::Ident; diff --git a/src/test/run-pass-fulldeps/rustc-macro/add-impl.rs b/src/test/run-pass-fulldeps/proc-macro/add-impl.rs similarity index 96% rename from src/test/run-pass-fulldeps/rustc-macro/add-impl.rs rename to src/test/run-pass-fulldeps/proc-macro/add-impl.rs index 226c082564a..e82282f3d8c 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/add-impl.rs +++ b/src/test/run-pass-fulldeps/proc-macro/add-impl.rs @@ -10,7 +10,7 @@ // aux-build:add-impl.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #[macro_use] extern crate add_impl; diff --git a/src/test/run-pass-fulldeps/rustc-macro/append-impl.rs b/src/test/run-pass-fulldeps/proc-macro/append-impl.rs similarity index 96% rename from src/test/run-pass-fulldeps/rustc-macro/append-impl.rs rename to src/test/run-pass-fulldeps/proc-macro/append-impl.rs index b7025c61fb6..f062111df9d 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/append-impl.rs +++ b/src/test/run-pass-fulldeps/proc-macro/append-impl.rs @@ -10,7 +10,7 @@ // aux-build:append-impl.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #![allow(warnings)] #[macro_use] diff --git a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/add-impl.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs similarity index 78% rename from src/test/run-pass-fulldeps/rustc-macro/auxiliary/add-impl.rs rename to src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs index 8aab423af0a..99586b0bb49 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/add-impl.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/add-impl.rs @@ -10,16 +10,16 @@ // no-prefer-dynamic -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(AddImpl)] -// #[cfg(rustc_macro)] +#[proc_macro_derive(AddImpl)] +// #[cfg(proc_macro)] pub fn derive(input: TokenStream) -> TokenStream { (input.to_string() + " impl B { diff --git a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/append-impl.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs similarity index 80% rename from src/test/run-pass-fulldeps/rustc-macro/auxiliary/append-impl.rs rename to src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs index c3d295e02c1..27c3d643ca4 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/append-impl.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/append-impl.rs @@ -11,15 +11,15 @@ // force-host // no-prefer-dynamic -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] -#![crate_type = "rustc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] +#![crate_type = "proc-macro"] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(Append)] +#[proc_macro_derive(Append)] pub fn derive_a(input: TokenStream) -> TokenStream { let mut input = input.to_string(); input.push_str(" diff --git a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-a.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs similarity index 82% rename from src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-a.rs rename to src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs index 42155383dec..c2de173568b 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-a.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-a.rs @@ -10,15 +10,15 @@ // no-prefer-dynamic -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(A)] +#[proc_macro_derive(A)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); assert!(input.contains("struct A;")); diff --git a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-atob.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs similarity index 79% rename from src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-atob.rs rename to src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs index 5b85e2b2a7c..b9e31fc3329 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-atob.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-atob.rs @@ -10,15 +10,15 @@ // no-prefer-dynamic -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(AToB)] +#[proc_macro_derive(AToB)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); assert_eq!(input, "struct A;\n"); diff --git a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-ctod.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs similarity index 79% rename from src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-ctod.rs rename to src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs index 54f8dff509a..50f1a390b29 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-ctod.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-ctod.rs @@ -10,15 +10,15 @@ // no-prefer-dynamic -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(CToD)] +#[proc_macro_derive(CToD)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); assert_eq!(input, "struct C;\n"); diff --git a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-same-struct.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs similarity index 80% rename from src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-same-struct.rs rename to src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs index d83e352e3b1..bd283ca57eb 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/derive-same-struct.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/derive-same-struct.rs @@ -9,23 +9,23 @@ // except according to those terms. // no-prefer-dynamic -// compile-flags:--crate-type rustc-macro +// compile-flags:--crate-type proc-macro -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(AToB)] +#[proc_macro_derive(AToB)] pub fn derive1(input: TokenStream) -> TokenStream { println!("input1: {:?}", input.to_string()); assert_eq!(input.to_string(), "#[derive(BToC)]\nstruct A;\n"); "#[derive(BToC)] struct B;".parse().unwrap() } -#[rustc_macro_derive(BToC)] +#[proc_macro_derive(BToC)] pub fn derive2(input: TokenStream) -> TokenStream { assert_eq!(input.to_string(), "struct B;\n"); "struct C;".parse().unwrap() diff --git a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/expand-with-a-macro.rs b/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs similarity index 82% rename from src/test/run-pass-fulldeps/rustc-macro/auxiliary/expand-with-a-macro.rs rename to src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs index 96aea407e6e..155b125690c 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/auxiliary/expand-with-a-macro.rs +++ b/src/test/run-pass-fulldeps/proc-macro/auxiliary/expand-with-a-macro.rs @@ -10,16 +10,16 @@ // no-prefer-dynamic -#![crate_type = "rustc-macro"] -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] +#![crate_type = "proc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] #![deny(warnings)] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(A)] +#[proc_macro_derive(A)] pub fn derive(input: TokenStream) -> TokenStream { let input = input.to_string(); assert!(input.contains("struct A;")); diff --git a/src/test/run-pass-fulldeps/rustc-macro/derive-same-struct.rs b/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs similarity index 96% rename from src/test/run-pass-fulldeps/rustc-macro/derive-same-struct.rs rename to src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs index ee0d5945648..b3edc8f1c31 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/derive-same-struct.rs +++ b/src/test/run-pass-fulldeps/proc-macro/derive-same-struct.rs @@ -10,7 +10,7 @@ // aux-build:derive-same-struct.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #[macro_use] extern crate derive_same_struct; diff --git a/src/test/run-pass-fulldeps/rustc-macro/expand-with-a-macro.rs b/src/test/run-pass-fulldeps/proc-macro/expand-with-a-macro.rs similarity index 96% rename from src/test/run-pass-fulldeps/rustc-macro/expand-with-a-macro.rs rename to src/test/run-pass-fulldeps/proc-macro/expand-with-a-macro.rs index cc59be2d75d..16f3535adae 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/expand-with-a-macro.rs +++ b/src/test/run-pass-fulldeps/proc-macro/expand-with-a-macro.rs @@ -11,7 +11,7 @@ // aux-build:expand-with-a-macro.rs // ignore-stage1 -#![feature(rustc_macro)] +#![feature(proc_macro)] #![deny(warnings)] #[macro_use] diff --git a/src/test/run-pass-fulldeps/rustc-macro/load-two.rs b/src/test/run-pass-fulldeps/proc-macro/load-two.rs similarity index 96% rename from src/test/run-pass-fulldeps/rustc-macro/load-two.rs rename to src/test/run-pass-fulldeps/proc-macro/load-two.rs index 1500970f02d..56f9768764c 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/load-two.rs +++ b/src/test/run-pass-fulldeps/proc-macro/load-two.rs @@ -11,7 +11,7 @@ // aux-build:derive-atob.rs // aux-build:derive-ctod.rs -#![feature(rustc_macro)] +#![feature(proc_macro)] #[macro_use] extern crate derive_atob; diff --git a/src/test/run-pass-fulldeps/rustc-macro/smoke.rs b/src/test/run-pass-fulldeps/proc-macro/smoke.rs similarity index 96% rename from src/test/run-pass-fulldeps/rustc-macro/smoke.rs rename to src/test/run-pass-fulldeps/proc-macro/smoke.rs index 588380f1140..cd7edb72644 100644 --- a/src/test/run-pass-fulldeps/rustc-macro/smoke.rs +++ b/src/test/run-pass-fulldeps/proc-macro/smoke.rs @@ -11,7 +11,7 @@ // aux-build:derive-a.rs // ignore-stage1 -#![feature(rustc_macro)] +#![feature(proc_macro)] #[macro_use] extern crate derive_a; diff --git a/src/test/rustdoc/rustc-macro-crate.rs b/src/test/rustdoc/rustc-macro-crate.rs index c8bf5b2b912..fe80a909550 100644 --- a/src/test/rustdoc/rustc-macro-crate.rs +++ b/src/test/rustdoc/rustc-macro-crate.rs @@ -10,15 +10,15 @@ // no-prefer-dynamic -#![feature(rustc_macro)] -#![feature(rustc_macro_lib)] -#![crate_type = "rustc-macro"] +#![feature(proc_macro)] +#![feature(proc_macro_lib)] +#![crate_type = "proc-macro"] -extern crate rustc_macro; +extern crate proc_macro; -use rustc_macro::TokenStream; +use proc_macro::TokenStream; -#[rustc_macro_derive(Foo)] +#[proc_macro_derive(Foo)] pub fn foo(input: TokenStream) -> TokenStream { input } diff --git a/src/tools/cargotest/main.rs b/src/tools/cargotest/main.rs index 354cce69127..633ff6271b7 100644 --- a/src/tools/cargotest/main.rs +++ b/src/tools/cargotest/main.rs @@ -24,7 +24,7 @@ struct Test { const TEST_REPOS: &'static [Test] = &[Test { name: "cargo", repo: "https://github.com/rust-lang/cargo", - sha: "d8936af1390ab0844e5e68b459214f2529c9f647", + sha: "d3bad1ab29efae414e9b4c24534b2d02b3a59782", lock: None, }, Test { diff --git a/src/tools/tidy/src/cargo.rs b/src/tools/tidy/src/cargo.rs index 4932fd5147a..a7784e65c5b 100644 --- a/src/tools/tidy/src/cargo.rs +++ b/src/tools/tidy/src/cargo.rs @@ -88,9 +88,11 @@ fn verify(tomlfile: &Path, libfile: &Path, bad: &mut bool) { continue } - // We want the compiler to depend on the proc_macro crate so that it is built and - // included in the end, but we don't want to actually use it in the compiler. - if toml.contains("name = \"rustc_driver\"") && krate == "proc_macro" { + // We want the compiler to depend on the proc_macro_plugin crate so + // that it is built and included in the end, but we don't want to + // actually use it in the compiler. + if toml.contains("name = \"rustc_driver\"") && + krate == "proc_macro_plugin" { continue }