rwf2 / Rocket

A web framework for Rust.
https://rocket.rs
Other
24.55k stars 1.57k forks source link

A new warning on rust beta: unreachable pattern #2864

Open komar007 opened 2 months ago

komar007 commented 2 months ago

Rocket Version

0.5.1

Operating System

Ubuntu 22.04.4

Rust Toolchain Version

1.82.0-beta.3

What happened?

Just letting you know of a potential problem coming. I have a CI running my code at work on beta rust, clippy, fmt, etc and recently there's been a new warning when using rocket_ws::WebSocket. It seems it could originate somewhere in rocket's macro:

warning: unreachable pattern
 --> src/main.rs:5:9
  |
5 |     ws: rocket_ws::WebSocket,
  |         ^^^^^^^^^ matches no values because `(rocket::http::Status, Infallible)` is uninhabited
  |
  = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
  = note: `#[warn(unreachable_patterns)]` on by default

Below is a somewhat minimal reproduction code.

Test Case

use rocket::{get, response::status::NotFound};

#[get("/endpoint")]
pub async fn endpoint(
    ws: rocket_ws::WebSocket,
) -> Result<rocket_ws::Channel<'static>, NotFound<()>> {
    Ok(ws.channel(|_| Box::pin(async { Ok(()) })))
}

fn main() {}

Log Output

warning: unreachable pattern
 --> src/main.rs:5:9
  |
5 |     ws: rocket_ws::WebSocket,
  |         ^^^^^^^^^ matches no values because `(rocket::http::Status, Infallible)` is uninhabited
  |
  = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types
  = note: `#[warn(unreachable_patterns)]` on by default

Additional Context

No response

System Checks

mikemoore13 commented 1 month ago

On my side this warning get fixed by updating rust rustup update

komar007 commented 1 month ago

Indeed, no warning on 1.82.0-beta.4 anymore.