Open
Description
Feature gate: #![feature(hint_must_use)]
This is a tracking issue for the function core::hint::must_use
Public API
// core::hint
#[must_use]
pub const fn must_use<T>(value: T) -> T {
value
}
Steps / History
- Implementation: Add core::hint::must_use #94723
- Final comment period (FCP)
- Stabilization PR
Unresolved Questions
-
Alternative:
#[must_use]
on an arbitrary block or expression?#[must_use] { some_expr }
This feels more native, and might behave slightly better in some subtle edge cases—type inference may not always 'see through' the identity function in terms of whether unsize coercions occur before or after the call, whereas through a block that isn't an issue.
Blocked on Tracking issue for stmt_expr_attributes: Add attributes to expressions, etc. #15701.
-
Alternative:
#[must_use]
integrated into macro_rules, perhaps on each arm, or on the whole macro, perhaps with a lint or error if the macro does not produce an expression.
Activity