Convert tests to use #[plugin_registrar]

This commit is contained in:
Keegan McAllister 2014-05-24 21:38:16 -07:00
parent aca0bac29f
commit 5084de3aaf
6 changed files with 30 additions and 36 deletions

View File

@ -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])

View File

@ -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>));
}

View File

@ -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])

View File

@ -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() {}

View File

@ -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() {}

View File

@ -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() {}