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

debug_handler macro is incompatible with use of #![deny(unreachable_code)] #2004

Closed
1 task done
taladar opened this issue May 12, 2023 · 1 comment · Fixed by #2014
Closed
1 task done

debug_handler macro is incompatible with use of #![deny(unreachable_code)] #2004

taladar opened this issue May 12, 2023 · 1 comment · Fixed by #2014
Labels
A-axum-macros C-bug Category: This is a bug. E-easy Call for participation: Experience needed to fix: Easy / not much

Comments

@taladar
Copy link

taladar commented May 12, 2023

  • I have looked for existing issues (including closed) about this

Bug Report

Version

├── axum v0.6.18
│   ├── axum-core v0.3.4
│   ├── axum-macros v0.3.7 (proc-macro)
├── axum-extra v0.7.4
│   ├── axum v0.6.18 (*)
│   ├── axum-core v0.3.4 (*)
│   ├── axum-macros v0.3.7 (proc-macro) (*)
├── axum-server v0.5.0
├── axum_session v0.2.2
│   ├── axum-core v0.3.4 (*)
├── axum_session_auth v0.2.1
│   ├── axum-core v0.3.4 (*)
│   ├── axum_session v0.2.2 (*)
    ├── axum v0.6.18 (*)
├── axum-test-helper v0.2.0
│   ├── axum v0.6.18 (*)

Platform

Linux hostname-removed 6.2.12 #124 SMP PREEMPT_DYNAMIC Fri Apr 21 10:31:26 CEST 2023 x86_64 AMD Ryzen 9 3900X 12-Core Processor AuthenticAMD GNU/Linux

Crates

axum-macros

Description

I tried adding

#[debug_handler]

to my handler functions and got a compiler error due to

#![deny(unreachable_code)]
error: unreachable statement
  --> src/handler/example.rs:48:1
   |
48 | #[debug_handler]
   | ^^^^^^^^^^^^^^^^
   | |
   | unreachable statement
   | any code following this expression is unreachable
   |
error: unreachable expression
  --> src/handler/example.rs:49:10
   |
49 | async fn list_examples(_: ListExamplesEndpoint, Extension(_database_pool) : Extension<PgPool>) -> Result<Json<Vec<Example>>, crate::Error> {
   |          ^^^^^^^^^^^^^
   |          |
   |          unreachable expression
   |          any code following this expression is unreachable
   |
   = note: this error originates in the macro `$crate::panic::panic_2021` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)

Trying an

#[allow(unreachable_code)]

above the macro did not solve the problem.

@davidpdrsn davidpdrsn added C-bug Category: This is a bug. E-easy Call for participation: Experience needed to fix: Easy / not much A-axum-macros labels May 12, 2023
@davidpdrsn
Copy link
Member

Thanks for the report! Should just be a matter of adding #[allow(unreachable_code)] to the generated functions.

alexander-jackson added a commit to alexander-jackson/axum that referenced this issue May 19, 2023
As reported in tokio-rs#2004, the usage of `#[debug_handler]` conflicts with
`#![deny(unreachable_code)]` since the macro itself generates
unreachable code by design.

This change:
* Adds allow rules to the generated code to prevent this

Closes tokio-rs#2004
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-axum-macros C-bug Category: This is a bug. E-easy Call for participation: Experience needed to fix: Easy / not much
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants