Skip to content

Commit

Permalink
Fix cargo clippy build failure with Rust 1.82
Browse files Browse the repository at this point in the history
CI reports:

error: irrefutable `if let` pattern
   --> x11rb-async/examples/xclock_utc_async.rs:243:20
    |
243 |                 if let Err(e) = drive.await {
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: this pattern will always match, so the `if let` is useless
    = help: consider replacing the `if let` with a `let`

Trying the suggested fix does not work with older rustc:

error[E0005]: refutable pattern in local binding
   --> x11rb-async/examples/xclock_utc_async.rs:243:21
    |
243 |                 let Err(e) = drive.await;
    |                     ^^^^^^ pattern `Ok(_)` not covered

So change this "if let" into a "match" that works everywhere.

Signed-off-by: Uli Schlachter <[email protected]>
  • Loading branch information
psychon committed Nov 1, 2024
1 parent 8d43dd0 commit 5bfe912
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions x11rb-async/examples/shared_memory_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,9 @@ async fn main2(file: File) -> Result<(), Box<dyn std::error::Error>> {
async move {
// Spawn a task to read from the connection.
ex.spawn(async move {
if let Err(e) = drive.await {
tracing::error!("Error while driving the connection: {}", e);
match drive.await {
Err(e) => tracing::error!("Error while driving the connection: {}", e),
_ => unreachable!(),
}
})
.detach();
Expand Down
5 changes: 3 additions & 2 deletions x11rb-async/examples/xclock_utc_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,9 @@ async fn main2() -> Result<(), Box<dyn std::error::Error>> {
async move {
// Spawn a task to poll for events.
let driver = ex.spawn(async move {
if let Err(e) = drive.await {
tracing::error!("Error while driving the connection: {}", e);
match drive.await {
Err(e) => tracing::error!("Error while driving the connection: {}", e),
_ => unreachable!(),
}
});

Expand Down

0 comments on commit 5bfe912

Please sign in to comment.