rust-clippy icon indicating copy to clipboard operation
rust-clippy copied to clipboard

redundant_locals incorrectly emitted when binding in new local scope for early drop

Open SUPERCILEX opened this issue 1 year ago • 0 comments

Summary

let (result_stream, threads) = {
    let query = query; // ERROR
    ringboard_sdk::search(
        if regex {
            Query::Regex(Regex::new(&query)?)
        } else if ignore_case {
            Query::PlainIgnoreCase(CaselessQuery::new(query).trim())
        } else {
            Query::Plain(query.as_bytes())
        },
        reader.clone(),
    )
};

I'm rebinding an outside scope variable to get it to drop after starting the search.

Lint Name

redundant_locals

Reproducer

No response

Version

rustc 1.82.0-nightly (64ebd39da 2024-08-03)
binary: rustc
commit-hash: 64ebd39da5ec28caa3bd7cbb3f22f5949432fe2b
commit-date: 2024-08-03
host: x86_64-unknown-linux-gnu
release: 1.82.0-nightly
LLVM version: 19.1.0

Additional Labels

No response

SUPERCILEX avatar Aug 06 '24 20:08 SUPERCILEX