Skip to content

Tracking issue for core::hint::must_use #94745

Open
@dtolnay

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCT-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions