Skip to content

let_underscore_drop complains about idiomatic let _ = ignorable_result; #8003

Closed
@birkenfeld

Description

@birkenfeld

Lint name: let_underscore_drop

I tried this code:

#![allow(unused)]
#![deny(clippy::let_underscore_drop)]

struct Test;

impl Test {
    fn causes_error(&self) -> Result<(), std::io::Error> {
        todo!()
    }
    
    fn bug(&self) {
        let _ = self.causes_error();
    }
}

I expected to see this happen: no clippy errors

Instead, this happened: clippy wants to keep the Result around until end of scope, while let _ = is the normally suggested way to deal with results where there is no useful Ok and the Err needs to be ignored.

[edit: this originally suggested that the Drop bound is wrongly inferred.]

Meta

Rust version: Nightly on Playground (2021-11-19 a77da2d)

Metadata

Metadata

Assignees

No one assigned

    Labels

    S-needs-discussionStatus: Needs further discussion before merging or work can be started

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions