Rocket icon indicating copy to clipboard operation
Rocket copied to clipboard

A new warning on rust beta: unreachable pattern

Open komar007 opened this issue 1 year ago • 2 comments

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

  • [X] My bug report relates to functionality.
  • [X] I have tested against the latest Rocket release or a recent git commit.
  • [X] I have tested against the latest stable rustc toolchain.
  • [X] I was unable to find this issue previously reported.

komar007 avatar Sep 10 '24 16:09 komar007

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

mikemoore13 avatar Sep 23 '24 09:09 mikemoore13

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

komar007 avatar Sep 25 '24 05:09 komar007

Looks like a false positive that's been resolved!

SergioBenitez avatar Dec 02 '24 10:12 SergioBenitez