remove use of hidden api in support procedural (#2383)

This commit is contained in:
thiolliere
2019-04-25 15:48:19 +02:00
committed by Bastian Köcher
parent 93bc03cfe6
commit 07d495d905
6 changed files with 81 additions and 137 deletions
@@ -23,7 +23,6 @@ use syn::parse::{
ParseStream,
Result,
};
use syn::token::CustomKeyword;
use proc_macro2::TokenStream as T2;
use quote::{ToTokens, quote};
use std::iter::once;
@@ -72,32 +71,6 @@ groups_impl!(Braces, Brace, Brace, parse_braces);
groups_impl!(Brackets, Bracket, Bracket, parse_brackets);
groups_impl!(Parens, Paren, Parenthesis, parse_parens);
#[derive(Debug, Clone)]
pub struct CustomToken<T>(std::marker::PhantomData<T>);
impl<T: CustomKeyword> Parse for CustomToken<T> {
fn parse(input: ParseStream) -> Result<Self> {
let ident: syn::Ident = input.parse()?;
if ident.to_string().as_str() != T::ident() {
return Err(syn::parse::Error::new_spanned(ident, "expected another custom token"))
}
Ok(CustomToken(std::marker::PhantomData))
}
}
impl<T: CustomKeyword> ToTokens for CustomToken<T> {
fn to_tokens(&self, tokens: &mut T2) {
use std::str::FromStr;
tokens.extend(T2::from_str(T::ident()).expect("custom keyword should parse to ident"));
}
}
impl<T: CustomKeyword> CustomKeyword for CustomToken<T> {
fn ident() -> &'static str { <T as CustomKeyword>::ident() }
fn display() -> &'static str { <T as CustomKeyword>::display() }
}
#[derive(Debug)]
pub struct PunctuatedInner<P,T,V> {
pub inner: syn::punctuated::Punctuated<P,T>,