Skip to content

#[must_use] error does not show type #42688

Closed
@jethrogb

Description

@jethrogb

The unused_must_use lint doesn't tell you which type needs to be used. This can get confusing if multiple must_use types are involved, especially because the language used includes the word “result”:

This code:

#[must_use]
struct A;

fn a() -> Result<A, ()> {
    Ok(A)
}

fn main() {
    a().unwrap();
}

Results in:

warning: unused result which must be used
 --> <anon>:9:5
  |
9 |     a().unwrap();
  |     ^^^^^^^^^^^^^

Suggested message: unused [TYPE] which must be used

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions