Skip to content

RFC: add lint warning when ignoring return values #10928

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

Closed
brendanzab opened this issue Dec 12, 2013 · 2 comments
Closed

RFC: add lint warning when ignoring return values #10928

brendanzab opened this issue Dec 12, 2013 · 2 comments
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.

Comments

@brendanzab
Copy link
Member

Currently rustc will allow you to silently ignore return values:

 fn hi() -> int { 1 }

fn main() {
     hi();
}

This has the potential to introduce subtle bugs to code. Perhaps it would be a good idea to have a warning like:

test.rs:4:9: 4:14 warning: unused variable: `x`, #[warn(ignored_return_values)] on by default. Use `let _ = hi();` to silence. 
test.rs:4         hi();
                  ^~~~~

This lint could be disabled using #[allow(ignored_return_values)].

@alexcrichton
Copy link
Member

Closing as a dupe of #2974, but certainly an interesting idea! Tricky to get right...

@brendanzab
Copy link
Member Author

Woops, sorry about that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lints Area: Lints (warnings about flaws in source code) such as unused_mut.
Projects
None yet
Development

No branches or pull requests

2 participants