about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorKeegan McAllister <kmcallister@mozilla.com>2014-05-24 21:31:50 -0700
committerKeegan McAllister <kmcallister@mozilla.com>2014-06-09 14:29:30 -0700
commitaca0bac29f7d7e86edfb5850cef1ab9b5e4797f2 (patch)
tree789fc211a957d515b86cc1b99421cf17e975d9fb /src
parented41b71fbe69cc920a3a021ac4e96dc4d5cc488c (diff)
downloadrust-aca0bac29f7d7e86edfb5850cef1ab9b5e4797f2.tar.gz
rust-aca0bac29f7d7e86edfb5850cef1ab9b5e4797f2.zip
Convert libraries to use #[plugin_registrar]
Diffstat (limited to 'src')
-rw-r--r--src/doc/rust.md5
-rw-r--r--src/libfourcc/lib.rs18
-rw-r--r--src/libhexfloat/lib.rs18
-rw-r--r--src/libregex_macros/lib.rs17
4 files changed, 24 insertions, 34 deletions
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