You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following code generates a warning about using a deprecated function.
use rocket::{get,Build,Rocket, routes};#[get("/")]#[deprecated]fnhandler_without_docs() -> &'static str{"ok"}#[rocket::launch]#[allow(deprecated)]fnlaunch() -> Rocket<Build>{
rocket::build().mount("/",routes![handler_without_docs])}
The deprecation warning is emitted on line 5 where the function is declared. This appears to be because Rocket's code generation is producing a type which has a function that calls the handler. This doesn't seem useful. The warning is emitted whenever a deprecated handler exists, whether it's used or not.
Annoyingly, adding #[allow(deprecated)] to the handler function has no effect on this warning. That allows the handler function to call deprecated functions, but has no effect on the generated struct calling the function.
For contrast, the following code does not generate a warning about using a deprecated function even though it looks like it should.
When #[get] or similar is used on a deprecated function,
the generated struct has #[allow(deprecated)] where it uses the handler function so a warning is not emitted where the function is declared.
the generated struct may have #[deprecated] itself, such that mounting the route generates a deprecated warning. I'm not sure if this is useful, but it seems like an expected behavior since the user is using the struct as if it were the function and the function is deprecated.
Additional Context
This would allow crates like rocket_okapi to use the #[deprecated] attribute for setting the deprecated property on the API spec.
The text was updated successfully, but these errors were encountered:
Existing Functionality
The following code generates a warning about using a deprecated function.
The deprecation warning is emitted on line 5 where the function is declared. This appears to be because Rocket's code generation is producing a type which has a function that calls the handler. This doesn't seem useful. The warning is emitted whenever a deprecated handler exists, whether it's used or not.
Annoyingly, adding
#[allow(deprecated)]
to the handler function has no effect on this warning. That allows the handler function to call deprecated functions, but has no effect on the generated struct calling the function.For contrast, the following code does not generate a warning about using a deprecated function even though it looks like it should.
Suggested Changes
When
#[get]
or similar is used on a deprecated function,#[allow(deprecated)]
where it uses the handler function so a warning is not emitted where the function is declared.#[deprecated]
itself, such that mounting the route generates a deprecated warning. I'm not sure if this is useful, but it seems like an expected behavior since the user is using the struct as if it were the function and the function is deprecated.Additional Context
This would allow crates like
rocket_okapi
to use the#[deprecated]
attribute for setting thedeprecated
property on the API spec.The text was updated successfully, but these errors were encountered: