Skip to content

Commit

Permalink
Use mixed-site spans to avoid clippy 'uri!' error.
Browse files Browse the repository at this point in the history
Closes #2630.
  • Loading branch information
SergioBenitez committed Oct 27, 2023
1 parent 07fe797 commit 260e671
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 2 additions & 1 deletion core/codegen/src/attribute/route/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use crate::proc_macro_ext::StringLit;
use crate::syn_ext::{IdentExt, TypeExt as _};
use crate::http_codegen::{Method, Optional};
use crate::attribute::param::Guard;
use crate::exports::mixed;

use self::parse::{Route, Attribute, MethodAttribute};

Expand Down Expand Up @@ -242,7 +243,7 @@ fn responder_outcome_expr(route: &Route) -> TokenStream {
.map(|a| quote_spanned!(a.span() => .await));

define_spanned_export!(ret_span => __req, _route);
quote_spanned! { Span::mixed_site().located_at(ret_span) =>
quote_spanned! { mixed(ret_span) =>
let ___responder = #user_handler_fn_name(#(#parameter_names),*) #_await;
#_route::Outcome::from(#__req, ___responder)
}
Expand Down
2 changes: 1 addition & 1 deletion core/codegen/src/bang/uri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn add_binding<P: fmt::Part>(to: &mut Vec<TokenStream>, ident: &Ident, ty: &Type
let tmp_ident = ident.clone().with_span(expr.span());
let let_stmt = quote_spanned!(span => let #tmp_ident = #expr);

to.push(quote_spanned!(span =>
to.push(quote_spanned!(mixed(span) =>
#[allow(non_snake_case)] #let_stmt;
let #ident = <#ty as #_fmt::FromUriParam<#part, _>>::from_uri_param(#tmp_ident);
));
Expand Down
6 changes: 6 additions & 0 deletions core/codegen/src/exports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,9 @@ define_exported_paths! {
macro_rules! define_spanned_export {
($span:expr => $($name:ident),*) => ($(define!($span => $name $name);)*)
}

/// Convenience: returns a "mixed site" span located at `span`.
#[inline(always)]
pub fn mixed(span: Span) -> Span {
Span::mixed_site().located_at(span)
}

0 comments on commit 260e671

Please sign in to comment.