Convert libraries to use #[plugin_registrar]
This commit is contained in:
parent
ed41b71fbe
commit
aca0bac29f
@ -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,
|
||||
|
@ -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])
|
||||
|
@ -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),
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user