diff --git a/src/doc/rust.md b/src/doc/rust.md index 38883118114..35d356bb1b5 100644 --- a/src/doc/rust.md +++ b/src/doc/rust.md @@ -1819,9 +1819,8 @@ type int8_t = i8; ### Function-only attributes -- `macro_registrar` - when using loadable syntax extensions, mark this - function as the registration point for the current crate's syntax - extensions. +- `plugin_registrar` - mark this function as the registration point for + compiler plugins, such as loadable syntax extensions. - `main` - indicates that this function should be passed to the entry point, rather than the function in the crate root named `main`. - `start` - indicates that this function should be used as the entry point, diff --git a/src/libfourcc/lib.rs b/src/libfourcc/lib.rs index 9cd62fcdd23..694fe7d0f48 100644 --- a/src/libfourcc/lib.rs +++ b/src/libfourcc/lib.rs @@ -48,29 +48,25 @@ fn main() { html_root_url = "http://doc.rust-lang.org/")] #![deny(deprecated_owned_vector)] -#![feature(macro_registrar, managed_boxes)] +#![feature(plugin_registrar, managed_boxes)] extern crate syntax; +extern crate rustc; use syntax::ast; -use syntax::ast::Name; use syntax::attr::contains; use syntax::codemap::{Span, mk_sp}; use syntax::ext::base; -use syntax::ext::base::{SyntaxExtension, BasicMacroExpander, NormalTT, ExtCtxt, MacExpr}; +use syntax::ext::base::{ExtCtxt, MacExpr}; use syntax::ext::build::AstBuilder; use syntax::parse; use syntax::parse::token; use syntax::parse::token::InternedString; +use rustc::plugin::Registry; -#[macro_registrar] -pub fn macro_registrar(register: |Name, SyntaxExtension|) { - register(token::intern("fourcc"), - NormalTT(box BasicMacroExpander { - expander: expand_syntax_ext, - span: None, - }, - None)); +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_macro("fourcc", expand_syntax_ext); } pub fn expand_syntax_ext(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) diff --git a/src/libhexfloat/lib.rs b/src/libhexfloat/lib.rs index 448f23eaedb..54bc2802b09 100644 --- a/src/libhexfloat/lib.rs +++ b/src/libhexfloat/lib.rs @@ -45,27 +45,23 @@ fn main() { html_root_url = "http://doc.rust-lang.org/")] #![deny(deprecated_owned_vector)] -#![feature(macro_registrar, managed_boxes)] +#![feature(plugin_registrar, managed_boxes)] extern crate syntax; +extern crate rustc; use syntax::ast; -use syntax::ast::Name; use syntax::codemap::{Span, mk_sp}; use syntax::ext::base; -use syntax::ext::base::{SyntaxExtension, BasicMacroExpander, NormalTT, ExtCtxt, MacExpr}; +use syntax::ext::base::{ExtCtxt, MacExpr}; use syntax::ext::build::AstBuilder; use syntax::parse; use syntax::parse::token; +use rustc::plugin::Registry; -#[macro_registrar] -pub fn macro_registrar(register: |Name, SyntaxExtension|) { - register(token::intern("hexfloat"), - NormalTT(box BasicMacroExpander { - expander: expand_syntax_ext, - span: None, - }, - None)); +#[plugin_registrar] +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_macro("hexfloat", expand_syntax_ext); } //Check if the literal is valid (as LLVM expects), diff --git a/src/libregex_macros/lib.rs b/src/libregex_macros/lib.rs index fb7e4211d49..bbee09d0f38 100644 --- a/src/libregex_macros/lib.rs +++ b/src/libregex_macros/lib.rs @@ -19,24 +19,24 @@ html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/")] -#![feature(macro_registrar, managed_boxes, quote)] +#![feature(plugin_registrar, managed_boxes, quote)] extern crate regex; extern crate syntax; +extern crate rustc; use std::rc::Rc; use syntax::ast; use syntax::codemap; use syntax::ext::build::AstBuilder; -use syntax::ext::base::{ - SyntaxExtension, ExtCtxt, MacResult, MacExpr, DummyResult, - NormalTT, BasicMacroExpander, -}; +use syntax::ext::base::{ExtCtxt, MacResult, MacExpr, DummyResult}; use syntax::parse; use syntax::parse::token; use syntax::print::pprust; +use rustc::plugin::Registry; + use regex::Regex; use regex::native::{ OneChar, CharClass, Any, Save, Jump, Split, @@ -46,11 +46,10 @@ use regex::native::{ }; /// For the `regex!` syntax extension. Do not use. -#[macro_registrar] +#[plugin_registrar] #[doc(hidden)] -pub fn macro_registrar(register: |ast::Name, SyntaxExtension|) { - let expander = box BasicMacroExpander { expander: native, span: None }; - register(token::intern("regex"), NormalTT(expander, None)) +pub fn plugin_registrar(reg: &mut Registry) { + reg.register_macro("regex", native); } /// Generates specialized code for the Pike VM for a particular regular