Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
pgerber opened this issue Mar 15, 2018 · 1 comment
Open

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

pgerber opened this issue Mar 15, 2018 · 1 comment
Labels
E-medium Call for participation: Medium difficulty level problem and requires some initial experience. L-correctness Lint: Belongs in the correctness lint group T-middle Type: Probably requires verifiying types

Comments

@pgerber
Copy link
Contributor

pgerber commented Mar 15, 2018

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!()
}
@oli-obk oli-obk added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-middle Type: Probably requires verifiying types L-correctness Lint: Belongs in the correctness lint group labels Apr 24, 2018
@apoelstra
Copy link

If you really didn't intend to do anything with the error but log it, how would you indicate that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-medium Call for participation: Medium difficulty level problem and requires some initial experience. L-correctness Lint: Belongs in the correctness lint group T-middle Type: Probably requires verifiying types
Projects
None yet
Development

No branches or pull requests

3 participants