Add missing lifetime parameter in codegen for routes and catchers.

This is linted against by `elided_lifetimes_in_paths`, which is not
enabled by default but is part of the `rust_2018_idioms` lint group.
This commit is contained in:
Rudi Floren 2021-02-26 19:13:06 +01:00 committed by Jeb Rosen
parent 59346ccfdc
commit e332ee83da
3 changed files with 8 additions and 2 deletions

View File

@ -127,7 +127,7 @@ pub fn _catch(
fn from(_: #user_catcher_fn_name) -> #StaticCatcherInfo {
fn monomorphized_function<'_b>(
#status: #Status,
#req: &'_b #Request
#req: &'_b #Request<'_>
) -> #ErrorHandlerFuture<'_b> {
#_Box::pin(async move {
let __response = #catcher_response;

View File

@ -432,7 +432,7 @@ fn codegen_route(route: Route) -> Result<TokenStream> {
impl From<#user_handler_fn_name> for #StaticRouteInfo {
fn from(_: #user_handler_fn_name) -> #StaticRouteInfo {
fn monomorphized_function<'_b>(
#req: &'_b #Request,
#req: &'_b #Request<'_>,
#data: #Data
) -> #HandlerFuture<'_b> {
#_Box::pin(async move {

View File

@ -1,3 +1,4 @@
#![warn(rust_2018_idioms)]
#[cfg(test)] mod tests;
#[rocket::get("/")]
@ -9,3 +10,8 @@ fn hello() -> &'static str {
fn rocket() -> rocket::Rocket {
rocket::ignite().mount("/", rocket::routes![hello])
}
#[rocket::catch(404)]
fn not_found(_req: &'_ rocket::Request<'_>) -> String {
"404 Not Found".to_owned()
}