Skip to content

Linter incorrectly marks the #[allow()] macro as being unused variable/unused mut #21959

@tsj845

Description

@tsj845

rust-analyzer version: rust-analyzer version: 0.3.2845-standalone (f1297b2 2026-03-29)

rustc version: rustc 1.83.0 (90b35a623 2024-11-26)

editor or extension: VSCode

relevant settings: N/A

repository link (if public, optional): N/A

code snippet to reproduce:

// tokio = { version = "^1.50.0", features = ["full"] }

use tokio_tungstenite::connect_async; // tokio-tungstenite = "^0.29.0"
use futures_util::{SinkExt, StreamExt}; // futures-util = { version = "^0.3.32", default-features = false, features = ["std"]}


let (ws_stream, _) = connect_async("some URI").await?;
#[allow(unused_variables,unused_mut)]
let (mut ws_write, mut ws_read) = ws_stream.split();
let _: tokio::task::JoinHandle<Result<(), Box<dyn Error + Send>>> = tokio::spawn(async move {
    while let Some(msg) = ws_read.next().await {
        // do things with msg
    }
    return Ok(());
});
Image

Addendum: this issue persisted after restarting the rust analyzer extension.
Addendum: this issue persisted after reinstalling the extension.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions