Skip to content
Open
Show file tree
Hide file tree
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 core/codegen/src/attribute/route/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn query_decls(route: &Route) -> Option<TokenStream> {
_ => quote!(#name)
};

define_spanned_export!(ty.span() => FromForm, _form);
define_spanned_export!(Span::call_site() => FromForm, _form);

let ty = quote_spanned!(ty.span() => <#ty as #FromForm>);
let init = quote_spanned!(ty.span() => #ty::init(#_form::Options::Lenient));
Expand Down Expand Up @@ -124,8 +124,8 @@ fn query_decls(route: &Route) -> Option<TokenStream> {

fn request_guard_decl(guard: &Guard) -> TokenStream {
let (ident, ty) = (guard.fn_ident.rocketized(), &guard.ty);
define_spanned_export!(ty.span() =>
__req, __data, _request, display_hack, FromRequest, Outcome
define_spanned_export!(Span::call_site() =>
__req, __data, display_hack, FromRequest, Outcome
);

quote_spanned! { ty.span() =>
Expand Down Expand Up @@ -162,7 +162,7 @@ fn request_guard_decl(guard: &Guard) -> TokenStream {

fn param_guard_decl(guard: &Guard) -> TokenStream {
let (i, name, ty) = (guard.index, &guard.name, &guard.ty);
define_spanned_export!(ty.span() =>
define_spanned_export!(Span::call_site() =>
__req, __data, _None, _Some, _Ok, _Err,
Outcome, FromSegments, FromParam, Status, display_hack
);
Expand Down Expand Up @@ -219,7 +219,7 @@ fn param_guard_decl(guard: &Guard) -> TokenStream {

fn data_guard_decl(guard: &Guard) -> TokenStream {
let (ident, ty) = (guard.fn_ident.rocketized(), &guard.ty);
define_spanned_export!(ty.span() => __req, __data, display_hack, FromData, Outcome);
define_spanned_export!(Span::call_site() => __req, __data, display_hack, FromData, Outcome);

quote_spanned! { ty.span() =>
let #ident: #ty = match <#ty as #FromData>::from_data(#__req, #__data).await {
Expand Down Expand Up @@ -307,7 +307,7 @@ fn responder_outcome_expr(route: &Route) -> TokenStream {
let _await = route.handler.sig.asyncness
.map(|a| quote_spanned!(a.span() => .await));

define_spanned_export!(ret_span => __req, _route);
define_spanned_export!(Span::call_site() => __req, _route);
quote_spanned! { mixed(ret_span) =>
let ___responder = #user_handler_fn_name(#(#parameter_names),*) #_await;
#_route::Outcome::from(#__req, ___responder)
Expand Down Expand Up @@ -363,7 +363,7 @@ fn sentinels_expr(route: &Route) -> TokenStream {
.map(|child| (child.parent, child.ty));

let sentinel = eligible_types.map(|(parent, ty)| {
define_spanned_export!(ty.span() => _sentinel);
define_spanned_export!(Span::call_site() => _sentinel);

match parent {
Some(p) if p.is_concrete(&generic_idents) => {
Expand Down
10 changes: 10 additions & 0 deletions core/codegen/tests/route.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,3 +347,13 @@ fn test_inclusive_segments() {
assert_eq!(get("//a//b////c/d/e"), "nonempty+c/d/e");
assert_eq!(get("//a//b////c/d/e/"), "nonempty+c/d/e/");
}

macro_rules! empty_get {
($name:ident) => {
#[allow(dead_code)]
#[get("/")]
async fn $name() {}
}
}

empty_get!(test);