mirror of https://github.com/fafhrd91/actix-web
chore(actix-web-codegen): Upgrade syn and quote to 1.0
This commit is contained in:
parent
effa96f5e4
commit
68830dd154
|
@ -12,8 +12,8 @@ workspace = ".."
|
||||||
proc-macro = true
|
proc-macro = true
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
quote = "0.6.12"
|
quote = "1"
|
||||||
syn = { version = "0.15.34", features = ["full", "parsing", "extra-traits"] }
|
syn = { version = "1", features = ["full", "parsing"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
actix-web = { version = "1.0.0" }
|
actix-web = { version = "1.0.0" }
|
||||||
|
|
|
@ -121,39 +121,37 @@ impl Args {
|
||||||
}
|
}
|
||||||
|
|
||||||
let ast: syn::ItemFn = syn::parse(input).expect("Parse input as function");
|
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 extra_guards = Vec::new();
|
||||||
let mut path = None;
|
let mut path = None;
|
||||||
for arg in args {
|
for arg in args {
|
||||||
match arg {
|
match arg {
|
||||||
syn::NestedMeta::Literal(syn::Lit::Str(ref fname)) => {
|
syn::NestedMeta::Lit(syn::Lit::Str(ref fname)) => {
|
||||||
if path.is_some() {
|
if path.is_some() {
|
||||||
panic!("Multiple paths specified! Should be only one!")
|
panic!("Multiple paths specified! Should be only one!")
|
||||||
}
|
}
|
||||||
let fname = quote!(#fname).to_string();
|
let fname = quote!(#fname).to_string();
|
||||||
path = Some(fname.as_str()[1..fname.len() - 1].to_owned())
|
path = Some(fname.as_str()[1..fname.len() - 1].to_owned())
|
||||||
}
|
}
|
||||||
syn::NestedMeta::Meta(syn::Meta::NameValue(ident)) => {
|
syn::NestedMeta::Meta(syn::Meta::NameValue(nv)) => {
|
||||||
match ident.ident.to_string().to_lowercase().as_str() {
|
if nv.path.is_ident("guard") {
|
||||||
"guard" => match ident.lit {
|
match nv.lit {
|
||||||
syn::Lit::Str(ref text) => extra_guards.push(text.value()),
|
syn::Lit::Str(ref text) => extra_guards.push(text.value()),
|
||||||
_ => panic!("Attribute guard expects literal string!"),
|
_ => panic!("Attribute guard expects literal string!"),
|
||||||
},
|
}
|
||||||
attr => panic!(
|
} else {
|
||||||
"Unknown attribute key is specified: {}. Allowed: guard",
|
panic!("Unknown attribute key is specified. Allowed: guard");
|
||||||
attr
|
|
||||||
),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
attr => panic!("Unknown attribute{:?}", attr),
|
attr => panic!("Unknown attribute{:?}", attr),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let resource_type = if ast.asyncness.is_some() {
|
let resource_type = if ast.sig.asyncness.is_some() {
|
||||||
ResourceType::Async
|
ResourceType::Async
|
||||||
} else {
|
} else {
|
||||||
match ast.decl.output {
|
match ast.sig.output {
|
||||||
syn::ReturnType::Default => panic!(
|
syn::ReturnType::Default => panic!(
|
||||||
"Function {} has no return type. Cannot be used as handler",
|
"Function {} has no return type. Cannot be used as handler",
|
||||||
name
|
name
|
||||||
|
|
Loading…
Reference in New Issue