about summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-01-07 17:36:16 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-01-07 17:36:16 -0800
commit662132560133a17cb598083f44de2fbf3d74f157 (patch)
tree57d34853ce7360561dd9c80c260ce3025b3bd951 /src/libsyntax/ext
parentbcebec508422e3dc88215a621f3b51beb88b0330 (diff)
parent209c701bf9e95542aec69455bc12c7ca295109c4 (diff)
downloadrust-662132560133a17cb598083f44de2fbf3d74f157.tar.gz
rust-662132560133a17cb598083f44de2fbf3d74f157.zip
rollup merge of #20657: alexcrichton/stabilize-macros
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/base.rs11
-rw-r--r--src/libsyntax/ext/bytes.rs117
-rw-r--r--src/libsyntax/ext/deriving/mod.rs10
-rw-r--r--src/libsyntax/ext/fmt.rs29
-rw-r--r--src/libsyntax/ext/source_util.rs6
5 files changed, 0 insertions, 173 deletions
diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs
index 11edf214435..9b9d8a9ceb3 100644
--- a/src/libsyntax/ext/base.rs
+++ b/src/libsyntax/ext/base.rs
@@ -341,9 +341,6 @@ fn initial_syntax_expander_table(ecfg: &expand::ExpansionConfig) -> SyntaxEnv {
 
     let mut syntax_expanders = SyntaxEnv::new();
     syntax_expanders.insert(intern("macro_rules"), MacroRulesTT);
-    syntax_expanders.insert(intern("fmt"),
-                            builtin_normal_expander(
-                                ext::fmt::expand_syntax_ext));
     syntax_expanders.insert(intern("format_args"),
                             builtin_normal_expander(
                                 ext::format::expand_format_args));
@@ -353,9 +350,6 @@ fn initial_syntax_expander_table(ecfg: &expand::ExpansionConfig) -> SyntaxEnv {
     syntax_expanders.insert(intern("option_env"),
                             builtin_normal_expander(
                                     ext::env::expand_option_env));
-    syntax_expanders.insert(intern("bytes"),
-                            builtin_normal_expander(
-                                    ext::bytes::expand_syntax_ext));
     syntax_expanders.insert(intern("concat_idents"),
                             builtin_normal_expander(
                                     ext::concat_idents::expand_syntax_ext));
@@ -367,8 +361,6 @@ fn initial_syntax_expander_table(ecfg: &expand::ExpansionConfig) -> SyntaxEnv {
                                     ext::log_syntax::expand_syntax_ext));
     syntax_expanders.insert(intern("derive"),
                             Decorator(box ext::deriving::expand_meta_derive));
-    syntax_expanders.insert(intern("deriving"),
-                            Decorator(box ext::deriving::expand_meta_deriving));
 
     if ecfg.enable_quotes {
         // Quasi-quoting expanders
@@ -416,9 +408,6 @@ fn initial_syntax_expander_table(ecfg: &expand::ExpansionConfig) -> SyntaxEnv {
     syntax_expanders.insert(intern("include_str"),
                             builtin_normal_expander(
                                     ext::source_util::expand_include_str));
-    syntax_expanders.insert(intern("include_bin"),
-                            builtin_normal_expander(
-                                    ext::source_util::expand_include_bin));
     syntax_expanders.insert(intern("include_bytes"),
                             builtin_normal_expander(
                                     ext::source_util::expand_include_bytes));
diff --git a/src/libsyntax/ext/bytes.rs b/src/libsyntax/ext/bytes.rs
deleted file mode 100644
index 9f225d55b44..00000000000
--- a/src/libsyntax/ext/bytes.rs
+++ /dev/null
@@ -1,117 +0,0 @@
-// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/* The compiler code necessary to support the bytes! extension. */
-
-use ast;
-use codemap::Span;
-use ext::base::*;
-use ext::base;
-use ext::build::AstBuilder;
-use std::ascii::AsciiExt;
-
-pub fn expand_syntax_ext<'cx>(cx: &'cx mut ExtCtxt,
-                              sp: Span,
-                              tts: &[ast::TokenTree])
-                              -> Box<base::MacResult+'cx> {
-    cx.span_warn(sp, "`bytes!` is deprecated, use `b\"foo\"` literals instead");
-    cx.parse_sess.span_diagnostic.span_help(sp,
-        "see http://doc.rust-lang.org/reference.html#byte-and-byte-string-literals \
-         for documentation");
-    cx.parse_sess.span_diagnostic.span_help(sp,
-        "see https://github.com/rust-lang/rust/blob/master/src/etc/2014-06-rewrite-bytes-macros.py \
-         for an automated migration");
-
-    // Gather all argument expressions
-    let exprs = match get_exprs_from_tts(cx, sp, tts) {
-        None => return DummyResult::expr(sp),
-        Some(e) => e,
-    };
-    let mut bytes = Vec::new();
-    let mut err = false;
-
-    for expr in exprs.iter() {
-        match expr.node {
-            // expression is a literal
-            ast::ExprLit(ref lit) => match lit.node {
-                // string literal, push each byte to vector expression
-                ast::LitStr(ref s, _) => {
-                    for byte in s.get().bytes() {
-                        bytes.push(cx.expr_u8(expr.span, byte));
-                    }
-                }
-
-                // u8 literal, push to vector expression
-                ast::LitInt(v, ast::UnsignedIntLit(ast::TyU8)) => {
-                    if v > 0xFF {
-                        cx.span_err(expr.span, "too large u8 literal in bytes!");
-                        err = true;
-                    } else {
-                        bytes.push(cx.expr_u8(expr.span, v as u8));
-                    }
-                }
-
-                // integer literal, push to vector expression
-                ast::LitInt(_, ast::UnsuffixedIntLit(ast::Minus)) => {
-                    cx.span_err(expr.span, "negative integer literal in bytes!");
-                    err = true;
-                }
-                ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => {
-                    if v > 0xFF {
-                        cx.span_err(expr.span, "too large integer literal in bytes!");
-                        err = true;
-                    } else {
-                        bytes.push(cx.expr_u8(expr.span, v as u8));
-                    }
-                }
-
-                // char literal, push to vector expression
-                ast::LitChar(v) => {
-                    if v.is_ascii() {
-                        bytes.push(cx.expr_u8(expr.span, v as u8));
-                    } else {
-                        cx.span_err(expr.span, "non-ascii char literal in bytes!");
-                        err = true;
-                    }
-                }
-
-                _ => {
-                    cx.span_err(expr.span, "unsupported literal in bytes!");
-                    err = true;
-                }
-            },
-
-            _ => {
-                cx.span_err(expr.span, "non-literal in bytes!");
-                err = true;
-            }
-        }
-    }
-
-    // For some reason using quote_expr!() here aborts if we threw an error.
-    // I'm assuming that the end of the recursive parse tricks the compiler
-    // into thinking this is a good time to stop. But we'd rather keep going.
-    if err {
-        // Since the compiler will stop after the macro expansion phase anyway, we
-        // don't need type info, so we can just return a DummyResult
-        return DummyResult::expr(sp);
-    }
-
-    let len = bytes.len();
-    let e = cx.expr_vec(sp, bytes);
-    let ty = cx.ty(sp, ast::TyFixedLengthVec(cx.ty_ident(sp, cx.ident_of("u8")),
-                                             cx.expr_uint(sp, len)));
-    let item = cx.item_static(sp, cx.ident_of("BYTES"), ty, ast::MutImmutable, e);
-    let ret = cx.expr_ident(sp, cx.ident_of("BYTES"));
-    let ret = cx.expr_addr_of(sp, ret);
-    let e = cx.expr_block(cx.block(sp, vec![cx.stmt_item(sp, item)],
-                                   Some(ret)));
-    MacExpr::new(e)
-}
diff --git a/src/libsyntax/ext/deriving/mod.rs b/src/libsyntax/ext/deriving/mod.rs
index 6040d4ee547..603c4478007 100644
--- a/src/libsyntax/ext/deriving/mod.rs
+++ b/src/libsyntax/ext/deriving/mod.rs
@@ -40,16 +40,6 @@ pub mod totalord;
 
 pub mod generic;
 
-pub fn expand_meta_deriving(cx: &mut ExtCtxt,
-                            _span: Span,
-                            mitem: &MetaItem,
-                            item: &Item,
-                            push: Box<FnMut(P<Item>)>) {
-    cx.span_warn(mitem.span, "`deriving` is deprecated; use `derive`");
-
-    expand_meta_derive(cx, _span, mitem, item, push)
-}
-
 pub fn expand_meta_derive(cx: &mut ExtCtxt,
                           _span: Span,
                           mitem: &MetaItem,
diff --git a/src/libsyntax/ext/fmt.rs b/src/libsyntax/ext/fmt.rs
deleted file mode 100644
index 5352cfaf749..00000000000
--- a/src/libsyntax/ext/fmt.rs
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-/// Deprecated fmt! syntax extension
-
-use ast;
-use codemap::Span;
-use ext::base;
-use ext::build::AstBuilder;
-
-
-pub fn expand_syntax_ext(ecx: &mut base::ExtCtxt,
-                         sp: Span,
-                         _tts: &[ast::TokenTree])
-                         -> Box<base::MacResult+'static> {
-    ecx.span_err(sp, "`fmt!` is deprecated, use `format!` instead");
-    ecx.parse_sess.span_diagnostic.span_note(sp,
-        "see http://doc.rust-lang.org/std/fmt/ \
-         for documentation");
-
-    base::MacExpr::new(ecx.expr_uint(sp, 2))
-}
diff --git a/src/libsyntax/ext/source_util.rs b/src/libsyntax/ext/source_util.rs
index b671b1a71b0..31a1a838b13 100644
--- a/src/libsyntax/ext/source_util.rs
+++ b/src/libsyntax/ext/source_util.rs
@@ -161,12 +161,6 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
     }
 }
 
-pub fn expand_include_bin(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
-                          -> Box<base::MacResult+'static> {
-    cx.span_warn(sp, "include_bin! is deprecated; use include_bytes! instead");
-    expand_include_bytes(cx, sp, tts)
-}
-
 pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                             -> Box<base::MacResult+'static> {
     let file = match get_single_str_from_tts(cx, sp, tts, "include_bytes!") {