diff options
| author | Keegan McAllister <kmcallister@mozilla.com> | 2014-05-24 21:38:16 -0700 |
|---|---|---|
| committer | Keegan McAllister <kmcallister@mozilla.com> | 2014-06-09 14:29:30 -0700 |
| commit | 5084de3aafa4b8e014a1b8698fdd2e5e62b97fa7 (patch) | |
| tree | b535ba6822c97d46c4cd0ab568653d69fe10b02c | |
| parent | aca0bac29f7d7e86edfb5850cef1ab9b5e4797f2 (diff) | |
| download | rust-5084de3aafa4b8e014a1b8698fdd2e5e62b97fa7.tar.gz rust-5084de3aafa4b8e014a1b8698fdd2e5e62b97fa7.zip | |
Convert tests to use #[plugin_registrar]
| -rw-r--r-- | src/test/auxiliary/macro_crate_test.rs | 21 | ||||
| -rw-r--r-- | src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs (renamed from src/test/auxiliary/macro_crate_outlive_expansion_phase.rs) | 11 | ||||
| -rw-r--r-- | src/test/auxiliary/syntax-extension-with-dll-deps-2.rs | 18 | ||||
| -rw-r--r-- | src/test/compile-fail/gated-plugin_registrar.rs (renamed from src/test/compile-fail/gated-macro_registrar.rs) | 4 | ||||
| -rw-r--r-- | src/test/compile-fail/multiple-plugin-registrars.rs (renamed from src/test/compile-fail/multiple-macro-registrars.rs) | 8 | ||||
| -rw-r--r-- | src/test/run-pass-fulldeps/macro-crate-outlive-expansion-phase.rs | 4 |
6 files changed, 30 insertions, 36 deletions
diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index 95f2a8c1ca1..805b8a894cb 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -10,29 +10,28 @@ // force-host -#![feature(globs, macro_registrar, macro_rules, quote, managed_boxes)] +#![feature(globs, plugin_registrar, macro_rules, quote, managed_boxes)] extern crate syntax; +extern crate rustc; -use syntax::ast::{Name, TokenTree, Item, MetaItem}; +use syntax::ast::{TokenTree, Item, MetaItem}; use syntax::codemap::Span; use syntax::ext::base::*; use syntax::parse::token; +use rustc::plugin::Registry; #[macro_export] macro_rules! exported_macro (() => (2)) macro_rules! unexported_macro (() => (3)) -#[macro_registrar] -pub fn macro_registrar(register: |Name, SyntaxExtension|) { - register(token::intern("make_a_1"), - NormalTT(box BasicMacroExpander { - expander: expand_make_a_1, - span: None, - }, - None)); - register(token::intern("into_foo"), ItemModifier(expand_into_foo)); +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_macro("make_a_1", expand_make_a_1); + reg.register_syntax_extension( + token::intern("into_foo"), + ItemModifier(expand_into_foo)); } fn expand_make_a_1(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) diff --git a/src/test/auxiliary/macro_crate_outlive_expansion_phase.rs b/src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs index 670673fe047..213fdd6b74a 100644 --- a/src/test/auxiliary/macro_crate_outlive_expansion_phase.rs +++ b/src/test/auxiliary/plugin_crate_outlive_expansion_phase.rs @@ -10,13 +10,12 @@ // force-host -#![feature(macro_registrar)] +#![feature(plugin_registrar)] -extern crate syntax; +extern crate rustc; use std::any::Any; -use syntax::ast::Name; -use syntax::ext::base::SyntaxExtension; +use rustc::plugin::Registry; struct Foo { foo: int @@ -26,8 +25,8 @@ impl Drop for Foo { fn drop(&mut self) {} } -#[macro_registrar] -pub fn registrar(_: |Name, SyntaxExtension|) { +#[plugin_registrar] +pub fn registrar(_: &mut Registry) { local_data_key!(foo: Box<Any:Send>); foo.replace(Some(box Foo { foo: 10 } as Box<Any:Send>)); } diff --git a/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs b/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs index 93b56a7600d..04318fcae27 100644 --- a/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs +++ b/src/test/auxiliary/syntax-extension-with-dll-deps-2.rs @@ -12,24 +12,20 @@ // no-prefer-dynamic #![crate_type = "dylib"] -#![feature(macro_registrar, quote, globs)] +#![feature(plugin_registrar, quote, globs)] extern crate other = "syntax-extension-with-dll-deps-1"; extern crate syntax; +extern crate rustc; -use syntax::ast::{Name, TokenTree, Item, MetaItem}; +use syntax::ast::{TokenTree, Item, MetaItem}; use syntax::codemap::Span; use syntax::ext::base::*; -use syntax::parse::token; +use rustc::plugin::Registry; -#[macro_registrar] -pub fn macro_registrar(register: |Name, SyntaxExtension|) { - register(token::intern("foo"), - NormalTT(box BasicMacroExpander { - expander: expand_foo, - span: None, - }, - None)); +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_macro("foo", expand_foo); } fn expand_foo(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) diff --git a/src/test/compile-fail/gated-macro_registrar.rs b/src/test/compile-fail/gated-plugin_registrar.rs index 54274ccb847..f6e11ffd9e5 100644 --- a/src/test/compile-fail/gated-macro_registrar.rs +++ b/src/test/compile-fail/gated-plugin_registrar.rs @@ -9,7 +9,7 @@ // except according to those terms. // the registration function isn't typechecked yet -#[macro_registrar] -pub fn registrar() {} //~ ERROR cross-crate macro exports are experimental +#[plugin_registrar] +pub fn registrar() {} //~ ERROR compiler plugins are experimental fn main() {} diff --git a/src/test/compile-fail/multiple-macro-registrars.rs b/src/test/compile-fail/multiple-plugin-registrars.rs index 321c0ff0193..f5ebf84b8e0 100644 --- a/src/test/compile-fail/multiple-macro-registrars.rs +++ b/src/test/compile-fail/multiple-plugin-registrars.rs @@ -8,15 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// error-pattern: multiple macro registration functions found +// error-pattern: multiple plugin registration functions found -#![feature(macro_registrar)] +#![feature(plugin_registrar)] // the registration function isn't typechecked yet -#[macro_registrar] +#[plugin_registrar] pub fn one() {} -#[macro_registrar] +#[plugin_registrar] pub fn two() {} fn main() {} diff --git a/src/test/run-pass-fulldeps/macro-crate-outlive-expansion-phase.rs b/src/test/run-pass-fulldeps/macro-crate-outlive-expansion-phase.rs index 15f5e84b2a7..dd585ea9794 100644 --- a/src/test/run-pass-fulldeps/macro-crate-outlive-expansion-phase.rs +++ b/src/test/run-pass-fulldeps/macro-crate-outlive-expansion-phase.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -// aux-build:macro_crate_outlive_expansion_phase.rs +// aux-build:plugin_crate_outlive_expansion_phase.rs // ignore-stage1 #![feature(phase)] #[phase(plugin)] -extern crate macro_crate_outlive_expansion_phase; +extern crate plugin_crate_outlive_expansion_phase; pub fn main() {} |
