1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2025-04-12 21:04:05 +00:00

chore(actix-web-codegen): Upgrade syn and quote to 1.0

This commit is contained in:
DanSnow 2019-10-13 14:04:03 +08:00
parent effa96f5e4
commit 68830dd154
No known key found for this signature in database
GPG key ID: 2B25949174178EBD
2 changed files with 12 additions and 14 deletions
actix-web-codegen

View file

@ -12,8 +12,8 @@ workspace = ".."
proc-macro = true
[dependencies]
quote = "0.6.12"
syn = { version = "0.15.34", features = ["full", "parsing", "extra-traits"] }
quote = "1"
syn = { version = "1", features = ["full", "parsing"] }
[dev-dependencies]
actix-web = { version = "1.0.0" }

View file

@ -121,39 +121,37 @@ impl Args {
}
let ast: syn::ItemFn = syn::parse(input).expect("Parse input as function");
let name = ast.ident.clone();
let name = ast.sig.ident.clone();
let mut extra_guards = Vec::new();
let mut path = None;
for arg in args {
match arg {
syn::NestedMeta::Literal(syn::Lit::Str(ref fname)) => {
syn::NestedMeta::Lit(syn::Lit::Str(ref fname)) => {
if path.is_some() {
panic!("Multiple paths specified! Should be only one!")
}
let fname = quote!(#fname).to_string();
path = Some(fname.as_str()[1..fname.len() - 1].to_owned())
}
syn::NestedMeta::Meta(syn::Meta::NameValue(ident)) => {
match ident.ident.to_string().to_lowercase().as_str() {
"guard" => match ident.lit {
syn::NestedMeta::Meta(syn::Meta::NameValue(nv)) => {
if nv.path.is_ident("guard") {
match nv.lit {
syn::Lit::Str(ref text) => extra_guards.push(text.value()),
_ => panic!("Attribute guard expects literal string!"),
},
attr => panic!(
"Unknown attribute key is specified: {}. Allowed: guard",
attr
),
}
} else {
panic!("Unknown attribute key is specified. Allowed: guard");
}
}
attr => panic!("Unknown attribute{:?}", attr),
}
}
let resource_type = if ast.asyncness.is_some() {
let resource_type = if ast.sig.asyncness.is_some() {
ResourceType::Async
} else {
match ast.decl.output {
match ast.sig.output {
syn::ReturnType::Default => panic!(
"Function {} has no return type. Cannot be used as handler",
name