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

panic does not compile intoResponse in Rust 1.85 and edition2024 #3169

Open
1 task done
Havunen opened this issue Jan 10, 2025 · 4 comments
Open
1 task done

panic does not compile intoResponse in Rust 1.85 and edition2024 #3169

Havunen opened this issue Jan 10, 2025 · 4 comments
Labels
A-axum-core S-blocked Status: marked as blocked ❌ on something else such as a PR or other implementation work.

Comments

@Havunen
Copy link

Havunen commented Jan 10, 2025

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

Bug Report

Version

cargo tree | grep axum

├── axum v0.8.1
│   ├── axum-core v0.5.0

Platform

Linux linuxdesktop 6.12.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 02 Jan 2025 22:52:26 +0000 x86_64 GNU/Linux

Steps to reproduce code:

Cargo.toml

edition = "2024"
rust-version = "1.85.0"

main.rs

use axum::Router;
use axum::routing::get;

#[tokio::main]
async fn main() {
    let app = Router::new()
        .route("/fail2", get(|| async { panic!("panic") }));

    let listener = tokio::net::TcpListener::bind("0.0.0.0").await.unwrap();
    axum::serve(listener, app).await.unwrap();
}

compiler errors:

error[E0277]: the trait bound `!: IntoResponse` is not satisfied
   --> crates/ae_api/src/main.rs:7:30
    |
7   |         .route("/fail2", get(|| async { panic!("panic") }));
    |                          --- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoResponse` is not implemented for `!`
    |                          |
    |                          required by a bound introduced by this call
    |
    = help: the following other types implement trait `IntoResponse`:
              &'static [u8; N]
              &'static [u8]
              &'static str
              ()
              (R,)
              (Response<()>, R)
              (Response<()>, T1, R)
              (Response<()>, T1, T2, R)
            and 120 others
    = note: this error might have been caused by changes to Rust's type-inference algorithm (see issue #48950 <https://github.com/rust-lang/rust/issues/48950> for more information)
    = help: did you intend to use the type `()` here instead?
    = note: required for `{closure@crates/ae_api/src/main.rs:7:30: 7:32}` to implement `Handler<((),), ()>`
note: required by a bound in `axum::routing::get`
   --> /.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/axum-0.8.1/src/routing/method_routing.rs:440:1
    |
440 | top_level_handler_fn!(get, GET);
    | ^^^^^^^^^^^^^^^^^^^^^^---^^^^^^
    | |                     |
    | |                     required by a bound in this function
    | required by this bound in `get`
    = note: this error originates in the macro `top_level_handler_fn` (in Nightly builds, run with -Z macro-backtrace for more info)

edition2021 compiles without errors.

Maybe its related to this: rust-lang/rust#123748

@Havunen Havunen changed the title panic does not compile intoResponse in Rust 1.85 panic does not compile intoResponse in Rust 1.85 and edition2024 Jan 10, 2025
@Turbo87
Copy link
Collaborator

Turbo87 commented Jan 10, 2025

Since we can't impl IntoResponse for ! due to rust-lang/rust#35121, I don't think there is much we can do about this 🤔

@jplatte
Copy link
Member

jplatte commented Jan 10, 2025

Yeah we can impl this once ! is stable.

@jplatte jplatte added S-blocked Status: marked as blocked ❌ on something else such as a PR or other implementation work. A-axum-core labels Jan 10, 2025
@Havunen
Copy link
Author

Havunen commented Jan 10, 2025

I quickly skimmed through that issue.
Can Infallible be used to impl IntoResponse?

https://doc.rust-lang.org/std/convert/enum.Infallible.html

@jplatte
Copy link
Member

jplatte commented Jan 10, 2025

That's already implemented: https://docs.rs/axum-core/0.5.0/axum_core/response/trait.IntoResponse.html#impl-IntoResponse-for-Infallible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-axum-core S-blocked Status: marked as blocked ❌ on something else such as a PR or other implementation work.
Projects
None yet
Development

No branches or pull requests

3 participants