Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support proc-macro2/nightly #24

Merged
merged 1 commit into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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