Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Mismatched Types Error in Macro Expansion #500

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions crates/oapi-macros/src/endpoint/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ fn handle_fn(salvo: &Ident, oapi: &Ident, sig: &Signature) -> syn::Result<(Token
let idv = id.to_token_stream().to_string();
let idv = idv.trim_start_matches('_');
extract_ts.push(quote! {
let #id: #ty = match <#ty as #salvo::Extractible>::extract_with_arg(req, #idv).await {
let #id: #ty = match <#ty as #salvo::Extractible>::extract_with_arg(__macro_generated_req, #idv).await {
Ok(data) => {
data
},
Expand Down Expand Up @@ -223,15 +223,15 @@ fn handle_fn(salvo: &Ident, oapi: &Ident, sig: &Signature) -> syn::Result<(Token
if sig.asyncness.is_none() {
quote! {
#[inline]
async fn handle(&self, req: &mut #salvo::Request, depot: &mut #salvo::Depot, res: &mut #salvo::Response, ctrl: &mut #salvo::FlowCtrl) {
async fn handle(&self, __macro_generated_req: &mut #salvo::Request, depot: &mut #salvo::Depot, res: &mut #salvo::Response, ctrl: &mut #salvo::FlowCtrl) {
#(#extract_ts)*
Self::#name(#(#call_args),*)
}
}
} else {
quote! {
#[inline]
async fn handle(&self, req: &mut #salvo::Request, depot: &mut #salvo::Depot, res: &mut #salvo::Response, ctrl: &mut #salvo::FlowCtrl) {
async fn handle(&self, __macro_generated_req: &mut #salvo::Request, depot: &mut #salvo::Depot, res: &mut #salvo::Response, ctrl: &mut #salvo::FlowCtrl) {
#(#extract_ts)*
Self::#name(#(#call_args),*).await
}
Expand All @@ -245,17 +245,17 @@ fn handle_fn(salvo: &Ident, oapi: &Ident, sig: &Signature) -> syn::Result<(Token
if sig.asyncness.is_none() {
quote! {
#[inline]
async fn handle(&self, req: &mut #salvo::Request, depot: &mut #salvo::Depot, res: &mut #salvo::Response, ctrl: &mut #salvo::FlowCtrl) {
async fn handle(&self, __macro_generated_req: &mut #salvo::Request, depot: &mut #salvo::Depot, res: &mut #salvo::Response, ctrl: &mut #salvo::FlowCtrl) {
#(#extract_ts)*
#salvo::Writer::write(Self::#name(#(#call_args),*), req, depot, res).await;
#salvo::Writer::write(Self::#name(#(#call_args),*), __macro_generated_req, depot, res).await;
}
}
} else {
quote! {
#[inline]
async fn handle(&self, req: &mut #salvo::Request, depot: &mut #salvo::Depot, res: &mut #salvo::Response, ctrl: &mut #salvo::FlowCtrl) {
async fn handle(&self, __macro_generated_req: &mut #salvo::Request, depot: &mut #salvo::Depot, res: &mut #salvo::Response, ctrl: &mut #salvo::FlowCtrl) {
#(#extract_ts)*
#salvo::Writer::write(Self::#name(#(#call_args),*).await, req, depot, res).await;
#salvo::Writer::write(Self::#name(#(#call_args),*).await, __macro_generated_req, depot, res).await;
}
}
}
Expand Down
Loading