1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-06-26 23:17:42 +02:00

fix: wrap attribute codegen regression when using expression (#3119)

This commit is contained in:
Rob Ede
2023-08-29 21:27:36 +01:00
committed by GitHub
parent 39abe3ae5e
commit 76f6106f8f
6 changed files with 29 additions and 12 deletions

View File

@ -224,7 +224,7 @@ struct Args {
path: syn::LitStr,
resource_name: Option<syn::LitStr>,
guards: Vec<Path>,
wrappers: Vec<syn::Type>,
wrappers: Vec<syn::Expr>,
methods: HashSet<MethodTypeExt>,
}
@ -251,7 +251,7 @@ impl Args {
} else {
return Err(syn::Error::new_spanned(
nv.value,
"Attribute name expects literal string!",
"Attribute name expects literal string",
));
}
} else if nv.path.is_ident("guard") {
@ -264,7 +264,7 @@ impl Args {
} else {
return Err(syn::Error::new_spanned(
nv.value,
"Attribute guard expects literal string!",
"Attribute guard expects literal string",
));
}
} else if nv.path.is_ident("wrap") {
@ -283,9 +283,9 @@ impl Args {
} else if nv.path.is_ident("method") {
if !is_route_macro {
return Err(syn::Error::new_spanned(
&nv,
"HTTP method forbidden here. To handle multiple methods, use `route` instead",
));
&nv,
"HTTP method forbidden here; to handle multiple methods, use `route` instead",
));
} else if let syn::Expr::Lit(syn::ExprLit {
lit: syn::Lit::Str(lit),
..
@ -300,13 +300,13 @@ impl Args {
} else {
return Err(syn::Error::new_spanned(
nv.value,
"Attribute method expects literal string!",
"Attribute method expects literal string",
));
}
} else {
return Err(syn::Error::new_spanned(
nv.path,
"Unknown attribute key is specified. Allowed: guard, method and wrap",
"Unknown attribute key is specified; allowed: guard, method and wrap",
));
}
}