diff options
| author | Matthew <mjjasper1@gmail.com> | 2017-05-23 14:00:20 +0100 |
|---|---|---|
| committer | Matthew <mjjasper1@gmail.com> | 2017-05-23 14:00:20 +0100 |
| commit | 6627ef228c1396c045b3e9f24edaf66b76516cbd (patch) | |
| tree | fbead309f0165e668a895b2b33ce607aa0f4d2cb /src/libproc_macro_plugin | |
| parent | 158b085f06a41004ebf36d87afa3548f8b60861a (diff) | |
| parent | 852b7cb91ed44f6cc77f855bd8281da4accbd2fb (diff) | |
| download | rust-6627ef228c1396c045b3e9f24edaf66b76516cbd.tar.gz rust-6627ef228c1396c045b3e9f24edaf66b76516cbd.zip | |
Stabilize in 1.19
Diffstat (limited to 'src/libproc_macro_plugin')
| -rw-r--r-- | src/libproc_macro_plugin/lib.rs | 6 | ||||
| -rw-r--r-- | src/libproc_macro_plugin/quote.rs | 16 |
2 files changed, 16 insertions, 6 deletions
diff --git a/src/libproc_macro_plugin/lib.rs b/src/libproc_macro_plugin/lib.rs index a6dad641253..68c5d495918 100644 --- a/src/libproc_macro_plugin/lib.rs +++ b/src/libproc_macro_plugin/lib.rs @@ -72,7 +72,7 @@ //! } //! ``` #![crate_name = "proc_macro_plugin"] -#![unstable(feature = "rustc_private", issue = "27812")] +#![cfg_attr(stage0, unstable(feature = "rustc_private", issue = "27812"))] #![feature(plugin_registrar)] #![crate_type = "dylib"] #![crate_type = "rlib"] @@ -81,9 +81,9 @@ html_root_url = "https://doc.rust-lang.org/nightly/")] #![deny(warnings)] -#![feature(staged_api)] +#![cfg_attr(stage0, feature(staged_api))] #![feature(rustc_diagnostic_macros)] -#![feature(rustc_private)] +#![cfg_attr(stage0, feature(rustc_private))] extern crate rustc_plugin; extern crate syntax; diff --git a/src/libproc_macro_plugin/quote.rs b/src/libproc_macro_plugin/quote.rs index ad71584b61a..09675564291 100644 --- a/src/libproc_macro_plugin/quote.rs +++ b/src/libproc_macro_plugin/quote.rs @@ -133,6 +133,14 @@ impl<'a> Quote for &'a str { } } +impl Quote for usize { + fn quote(&self) -> TokenStream { + let integer_symbol = Symbol::intern(&self.to_string()); + TokenTree::Token(DUMMY_SP, Token::Literal(token::Lit::Integer(integer_symbol), None)) + .into() + } +} + impl Quote for Ident { fn quote(&self) -> TokenStream { // FIXME(jseyfried) quote hygiene @@ -193,15 +201,17 @@ impl Quote for token::BinOpToken { impl Quote for Lit { fn quote(&self) -> TokenStream { macro_rules! gen_match { - ($($i:ident),*) => { + ($($i:ident),*; $($raw:ident),*) => { match *self { $( Lit::$i(lit) => quote!(::syntax::parse::token::Lit::$i((quote lit))), )* - _ => panic!("Unsupported literal"), + $( Lit::$raw(lit, n) => { + quote!(::syntax::parse::token::Lit::$raw((quote lit), (quote n))) + })* } } } - gen_match!(Byte, Char, Float, Str_, Integer, ByteStr) + gen_match!(Byte, Char, Float, Str_, Integer, ByteStr; StrRaw, ByteStrRaw) } } |
