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

View file

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

View file

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