
must_use in std::hint - Rust
Dec 8, 2025 · An identity function that causes an `unused_must_use` warning to be triggered if the given value is not used (returned, stored in a variable, etc) by the caller.
Why is must_use an attribute instead of a trait? : r/rust - Reddit
That RFC proposes allowing one to use #[must_use] on functions. Doing so would cause the value returned from that function to be linted as if they were linear, similar to how types …
rust - Can I apply must_use to a function result? - Stack Overflow
Apr 29, 2016 · In older versions, #[must_use] only applied to types, not individual values. One alternative is to define a simple wrapper type that is #[must_use]:
1940-must-use-functions - The Rust RFC Book - GitHub Pages
Feb 18, 2015 · If a semicolon discards the result of a function or method tagged with #[must_use], the compiler will emit a lint message (under same lint as #[must_use] on types).
When to add # [must_use] - Standard library developers Guide
The #[must_use] attribute can be applied to types or functions when failing to explicitly consider them or their output is almost certainly a bug. As an example, Result is #[must_use] because …
E0139 in Rust: Unused must_use attribute on a function or type
Jan 6, 2025 · Among these attributes is must_use, which is applied to functions, methods, or types to indicate that the result should not be ignored. This attribute instructs the compiler to …
must_use in std3::hint - Rust - Docs.rs
An identity function that causes an `unused_must_use` warning to be triggered if the given value is not used (returned, stored in a variable, etc) by the caller.
Diagnostics - The Rust Reference
The must_use attribute is used to issue a diagnostic warning when a value is not "used". It can be applied to user-defined composite types (struct s, enum s, and union s), functions, and traits.
`#[must_use]` on traits should apply to all types that ... - GitHub
Sep 24, 2022 · If must_use on traits infected any type that implemented it, these duplicate annotations could be removed and there would be no risk of forgetting them for any future types.
must_use]' not being the default on functions goes against "Rust …
Feb 8, 2023 · Therefore, as a responsible programmer, I should put #[must_use] everywhere except in places where I intentionally decide that discarding a return value is not a bug. The …