⬆️ syn, quote, proc_macro2

This commit is contained in:
Aleksey Kladov 2019-08-22 16:21:46 +03:00
parent 4815e14796
commit 04ecedd6ec
3 changed files with 12 additions and 13 deletions

View file

@ -1,6 +1,6 @@
[package] [package]
name = "salsa-macros" name = "salsa-macros"
version = "0.13.0" version = "0.13.1"
authors = ["Salsa developers"] authors = ["Salsa developers"]
edition = "2018" edition = "2018"
license = "Apache-2.0 OR MIT" license = "Apache-2.0 OR MIT"
@ -13,6 +13,6 @@ proc-macro = true
[dependencies] [dependencies]
heck = "0.3" heck = "0.3"
proc-macro2 = "0.4" proc-macro2 = "1.0"
quote = "0.6" quote = "1.0"
syn = { version = "0.15.29", features = ["full", "extra-traits"] } syn = { version = "1.0", features = ["full", "extra-traits"] }

View file

@ -193,7 +193,6 @@ impl QueryGroup {
.segments .segments
.last() .last()
.unwrap() .unwrap()
.value()
.ident .ident
.clone() .clone()
} }

View file

@ -89,26 +89,26 @@ pub(crate) fn query_group(args: TokenStream, input: TokenStream) -> TokenStream
} }
// Extract keys. // Extract keys.
let mut iter = method.sig.decl.inputs.iter(); let mut iter = method.sig.inputs.iter();
match iter.next() { match iter.next() {
Some(FnArg::SelfRef(sr)) if sr.mutability.is_none() => (), Some(FnArg::Receiver(sr)) if sr.mutability.is_none() => (),
_ => panic!( _ => panic!(
"first argument of query `{}` must be `&self`", "first argument of query `{}` must be `&self`",
method.sig.ident method.sig.ident
), ),
} }
let mut keys = vec![]; let mut keys: Vec<Type> = vec![];
for arg in iter { for arg in iter {
match *arg { match *arg {
FnArg::Captured(ref arg) => { FnArg::Typed(ref arg) => {
keys.push(arg.ty.clone()); keys.push((*arg.ty).clone());
} }
ref a => panic!("unsupported argument `{:?}` of `{}`", a, method.sig.ident), ref a => panic!("unsupported argument `{:?}` of `{}`", a, method.sig.ident),
} }
} }
// Extract value. // Extract value.
let value = match method.sig.decl.output { let value = match method.sig.output {
ReturnType::Type(_, ref ty) => ty.as_ref().clone(), ReturnType::Type(_, ref ty) => ty.as_ref().clone(),
ref r => panic!( ref r => panic!(
"unsupported return type `{:?}` of `{}`", "unsupported return type `{:?}` of `{}`",
@ -503,7 +503,7 @@ impl TryFrom<syn::Attribute> for SalsaAttr {
} }
let name = attr.path.segments[1].ident.to_string(); let name = attr.path.segments[1].ident.to_string();
let tts = attr.tts.into(); let tts = attr.tokens.into();
Ok(SalsaAttr { name, tts }) Ok(SalsaAttr { name, tts })
} }
} }
@ -511,7 +511,7 @@ impl TryFrom<syn::Attribute> for SalsaAttr {
fn is_not_salsa_attr_path(path: &syn::Path) -> bool { fn is_not_salsa_attr_path(path: &syn::Path) -> bool {
path.segments path.segments
.first() .first()
.map(|s| s.value().ident != "salsa") .map(|s| s.ident != "salsa")
.unwrap_or(true) .unwrap_or(true)
|| path.segments.len() != 2 || path.segments.len() != 2
} }