Skip to content

Commit

Permalink
Support proc-macro2/nightly
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 committed Mar 4, 2018
1 parent 0b04aac commit 5151b8a
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ default = ["syn/full"]
[dependencies]
ident_case = "1.0.0"
syn = { version = "0.12.10", features = ["extra-traits"] }
proc-macro2 = "0.2"
quote = "0.4"
4 changes: 2 additions & 2 deletions core/src/codegen/default_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl<'a> ToTokens for DefaultExpression<'a> {
fn to_tokens(&self, tokens: &mut Tokens) {
tokens.append_all(match *self {
DefaultExpression::Inherit(ident) => {
let dsn = Ident::from(DEFAULT_STRUCT_NAME);
let dsn = Ident::new(DEFAULT_STRUCT_NAME, ::proc_macro2::Span::call_site());
quote!(#dsn.#ident)
},
DefaultExpression::Explicit(path) => quote!(#path()),
Expand All @@ -38,7 +38,7 @@ pub struct DefaultDeclaration<'a>(&'a DefaultExpression<'a>);

impl<'a> ToTokens for DefaultDeclaration<'a> {
fn to_tokens(&self, tokens: &mut Tokens) {
let name = Ident::from(DEFAULT_STRUCT_NAME);
let name = Ident::new(DEFAULT_STRUCT_NAME, ::proc_macro2::Span::call_site());
let expr = self.0;
tokens.append_all(quote!(let #name: Self = #expr;));
}
Expand Down
2 changes: 1 addition & 1 deletion core/src/from_meta_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl FromMetaItem for isize {

impl FromMetaItem for syn::Ident {
fn from_string(value: &str) -> Result<Self> {
Ok(syn::Ident::from(value))
Ok(syn::Ident::new(value, ::proc_macro2::Span::call_site()))
}
}

Expand Down
1 change: 1 addition & 0 deletions core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern crate quote;

#[macro_use]
extern crate syn;
extern crate proc_macro2;

extern crate ident_case;

Expand Down
6 changes: 6 additions & 0 deletions core/src/macros.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
macro_rules! quote {
($($tt:tt)*) => {
quote_spanned!(::proc_macro2::Span::call_site() => $($tt)*)
};
}

macro_rules! path {
($($path:tt)+) => {
parse_quote!($($path)+)
Expand Down
2 changes: 1 addition & 1 deletion core/src/options/input_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl InputField {
}

pub fn from_field(f: &syn::Field, parent: Option<&Core>) -> Result<Self> {
let ident = f.ident.clone().unwrap_or(syn::Ident::from("__unnamed"));
let ident = f.ident.clone().unwrap_or(syn::Ident::new("__unnamed", ::proc_macro2::Span::call_site()));
let ty = f.ty.clone();
let base = Self::new(ident, ty).parse_attributes(&f.attrs)?;

Expand Down

0 comments on commit 5151b8a

Please sign in to comment.