Skip to content

add #[must_use] macros for floats#154979

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
ArtemIsmagilov:must-use-floats
Apr 19, 2026
Merged

add #[must_use] macros for floats#154979
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
ArtemIsmagilov:must-use-floats

Conversation

@ArtemIsmagilov
Copy link
Copy Markdown
Contributor

@ArtemIsmagilov ArtemIsmagilov commented Apr 8, 2026

try resolve #154854

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 8, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 8, 2026

r? @scottmcm

rustbot has assigned @scottmcm.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @scottmcm, libs
  • @scottmcm, libs expanded to 8 candidates
  • Random selection from Mark-Simulacrum, jhpratt, scottmcm

@tyilo
Copy link
Copy Markdown
Contributor

tyilo commented Apr 10, 2026

You haven't added it to all the functions in the issue.

@ArtemIsmagilov
Copy link
Copy Markdown
Contributor Author

ArtemIsmagilov commented Apr 10, 2026

I checked f16-32-64-128 in core/num/ and in std/num and see that must_use is added in all funcs.
Tell me where I might have missed it?

@tyilo
Copy link
Copy Markdown
Contributor

tyilo commented Apr 10, 2026

I checked f16-32-64-128 in core/num/ and in std/num and see that must_use is added in all methods. Tell me where I might have missed it?

Look at the original issue?

@ArtemIsmagilov
Copy link
Copy Markdown
Contributor Author

ArtemIsmagilov commented Apr 10, 2026

I read it, do you mean i didn't add a description?
example
#[must_use = "method returns a new number and does not mutate the original value"]

Or do you mean that i missed some functions for float in other modules rs?

@tyilo
Copy link
Copy Markdown
Contributor

tyilo commented Apr 10, 2026

I read it, do you mean i didn't add a description? example #[must_use = "method returns a new number and does not mutate the original value"]

Or do you mean that i missed some functions for float in other modules rs?

I mentioned 13 functions, you only added to it 4?

@ArtemIsmagilov
Copy link
Copy Markdown
Contributor Author

ArtemIsmagilov commented Apr 10, 2026

Oh, that's what you're talking about. Well, those attributes were already there, you can check.

@ArtemIsmagilov
Copy link
Copy Markdown
Contributor Author

ArtemIsmagilov commented Apr 10, 2026

for example

#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_float_classify", since = "1.83.0")]
#[inline]
#[allow(clippy::eq_op)] // > if you intended to check if the operand is NaN, use `.is_nan()` instead :)
pub const fn is_nan(self) -> bool {
self != self

@tyilo
Copy link
Copy Markdown
Contributor

tyilo commented Apr 11, 2026

@ArtemIsmagilov I am so sorry, I had a bug in my code that found the functions without the #[must_use] attribute (tyilo/std-traits@e012d28).

Looks good.

@scottmcm
Copy link
Copy Markdown
Member

@rustbot reroll

@rustbot rustbot assigned jhpratt and unassigned scottmcm Apr 17, 2026
@jhpratt
Copy link
Copy Markdown
Member

jhpratt commented Apr 18, 2026

Can you add a message to these?

@rustbot author

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 18, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 18, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 18, 2026
@ArtemIsmagilov
Copy link
Copy Markdown
Contributor Author

ArtemIsmagilov commented Apr 18, 2026

I didn't write the message for fn classify(self) -> Fp Category; after all, we get a category, not a number.
@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 18, 2026
@jhpratt
Copy link
Copy Markdown
Member

jhpratt commented Apr 19, 2026

That's fine, as it's much clearer when it already returns a different type.

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 19, 2026

📌 Commit 607021c has been approved by jhpratt

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 19, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Apr 19, 2026
…jhpratt

add #[must_use] macros for floats

try resolve rust-lang#154854
rust-bors Bot pushed a commit that referenced this pull request Apr 19, 2026
Rollup of 10 pull requests

Successful merges:

 - #155370 (Add regression test for dead code elimination with drop + panic)
 - #154823 (Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser)
 - #155294 (Add test for coalescing of diagnostic attribute duplicates)
 - #155352 (triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`)
 - #155431 (Add temporary scope to assert_matches)
 - #152995 (ACP Implementation of PermissionsExt for Windows )
 - #153873 (deprecate `std::char` constants and functions)
 - #154865 (libtest: use binary search for --exact test filtering)
 - #154979 (add #[must_use] macros for floats)
 - #155504 (Remove `AttributeLintKind` variants - part 2)
rust-bors Bot pushed a commit that referenced this pull request Apr 19, 2026
…uwer

Rollup of 12 pull requests

Successful merges:

 - #155370 (Add regression test for dead code elimination with drop + panic)
 - #154823 (Replace the spdx-rs dependency with a minimal in-tree SPDX tag-value parser)
 - #155294 (Add test for coalescing of diagnostic attribute duplicates)
 - #155352 (triagebot.toml: Sync `assign.owners` with `autolabel."T-compiler"`)
 - #155431 (Add temporary scope to assert_matches)
 - #153873 (deprecate `std::char` constants and functions)
 - #154865 (libtest: use binary search for --exact test filtering)
 - #154979 (add #[must_use] macros for floats)
 - #155486 (c-variadic: add roundtrip test)
 - #155504 (Remove `AttributeLintKind` variants - part 2)
 - #155510 (Update Tidy python executable path)
 - #155514 (codegen-options docs: remove -Csoft-float)
@rust-bors rust-bors Bot merged commit e7c135e into rust-lang:main Apr 19, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 19, 2026
rust-timer added a commit that referenced this pull request Apr 19, 2026
Rollup merge of #154979 - ArtemIsmagilov:must-use-floats, r=jhpratt

add #[must_use] macros for floats

try resolve #154854
@ArtemIsmagilov ArtemIsmagilov deleted the must-use-floats branch April 19, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing #[must_use] attribute for many float functions

5 participants