Closed
Description
This code:
#[must_use]
fn foo() {}
fn main() {
foo();
}
Gives (rustc 1.31.0-nightly 2c2e2c5 2018-10-12):
warning: unused return value of `foo` which must be used
--> ...\test.rs:4:5
|
4 | foo();
| ^^^^^^
|
= note: #[warn(unused_must_use)] on by default
But what I expected is no warning on the foo call, and an error (or warning) for adding #[must_use] on a function without return value.
In (rare) code like this, where the unit (empty tuple) is returned in an explicit way, I expect no errors nor warnings:
#[must_use]
fn foo() -> () {}
fn main() {
let _ = foo();
}
Metadata
Metadata
Assignees
Labels
No labels