Skip to content

Missing #[must_use] attribute for many float functions #154854

@tyilo

Description

@tyilo

The following floating point functions seems to be missing a #[must_use] attribute:

impl f32 { // also f16, f64, f128
	fn classify(self) -> FpCategory;
	fn next_up(self) -> Self;
	fn next_down(self) -> Self;
	fn midpoint(self, other: Self) -> Self;
        fn sin_cos(self) -> (Self, Self);
}

It seems like that the other floating point functions have one of the following reasons:

#[must_use]
#[must_use = "method returns a new number and does not mutate the original value"]
#[must_use = "this returns the clamped value and does not modify the original"]
#[must_use = "this returns the result of the comparison, without modifying either input"]
#[must_use = "this returns the result of the operation, without modifying the original"]

Edit: This original mentioned 13 functions, but there is actually only 5 functions without the attribute, so the list has been updated. (tyilo/std-traits@e012d28)

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-floating-pointArea: Floating point numbers and arithmeticC-cleanupCategory: PRs that clean code up or issues documenting cleanup.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions