Skip to content

New lint: let _ binding of must use function #4812

Closed
@flip1995

Description

@flip1995

Extracted from #4655

A lint that detects let _ bindings of functions, that are must_use:

#[must_use]
fn foo() -> u32 { 42 }

fn bar() -> Result<(), ()> { Ok(()) }

let _ = foo();
let _ = bar();

On how to detect must use #4655 (comment):

We have a check for #[must_use] types in functions.rs already (IIRC is_must_use_ty(cx, ty), we best move this to utils/mod.rs), that you can call with the result of an expr_ty(cx, _) on the initializer.

Originally posted by @flip1995 in #4655 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintArea: New lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions