Closed
Description
Given the following code (playground):
use std::ops::Add;
fn main() {
let mut x = 2_u32;
x += 3;
x.add(4);
println!("{}", x);
}
The current output is:
warning: unused return value of `add` that must be used
--> src/main.rs:6:5
|
6 | x.add(4);
| ^^^^^^^^^
|
= note: `#[warn(unused_must_use)]` on by default
Ideally the output should include:
= note: this returns the result of the operation, without modifying the original
Precedent
Many other std
methods have this exact must_use
message, e.g. (playground):
use std::path::Path;
fn f(p: &Path) {
p.to_str();
}
which gives the warning:
warning: unused return value of `Path::to_str` that must be used
--> src/lib.rs:4:5
|
4 | p.to_str();
| ^^^^^^^^^^^
|
= note: this returns the result of the operation, without modifying the original
= note: `#[warn(unused_must_use)]` on by default