An unused output of some macros in std (e.g., format!()
) should produce a unused_must_use warning. #126475
Open
Description
opened on Jun 14, 2024
Code
fn main() {
format!("{}", 1);
}
Current output
No errors or warnings
Desired output
warning: unused return value of `format!()` that must be used
Rationale and extra context
The format!()
macro could probably expand to code containing std::hint::must_use
.
List of macros with similar issues:
cfg!()
column!()
,line!()
,file!()
,module_path!()
concat!()
,stringify!()
env!()
,option_env!()
format!()
,format_args!()
include_bytes!()
,include_str!()
matches!()
vec!()
pin::pin!()
Other cases
No response
Rust Version
Nightly rust on playground: 1.81.0-nightly (2024-06-13 f1586001ace26df7cafe)
Anything else?
No response
Activity