Skip to content

Warn about Results only used in println!() #2529

@pgerber

Description

@pgerber

A few times now, I've come across tests where a result wasn't verified. Most often, this happens when the result is printed for debugging purposes. See sample code below or have a look at this this real-word example.

While I haven't seen it, I guess this could also be an issue outside of tests or with error!(), warn!(), etc.

I believe it would make since to emit a warning in such cases.

Sample:

some_fn() -> Result<…, …> {
    unimplemented!()
}

#[test]
fn a_test() {let result = some_fn();
    println!("result: {:?}", result);   // This compiles with no warning because the `Result` is used by println!()
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    E-mediumCall for participation: Medium difficulty level problem and requires some initial experience.L-correctnessLint: Belongs in the correctness lint groupT-middleType: Probably requires verifiying types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions