# Use of #\[must\_use\] in the standard library

**URL:** <https://internals.rust-lang.org/t/use-of-must-use-in-the-standard-library/15425>\
**Category:** libs\
**Created:** [October 8, 2021, 3:42am UTC](https://internals.rust-lang.org/t/use-of-must-use-in-the-standard-library/15425 "2021-10-08T03:42:40Z")\
**Posts on this page:** 1\
**Showing post:** 14

<div class="post-metadata">

**Author:** ![matklad](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/matklad/32/12266_2.png) [@matklad](https://internals.rust-lang.org/u/matklad)\
**Post date:** [October 13, 2021, 10:06am UTC](https://internals.rust-lang.org/t/use-of-must-use-in-the-standard-library/15425/14 "2021-10-13T10:06:09Z")

</div>

Note:

It's probably true that majority of functions can be `#[must_use]`. However, that alone doesn't imply that `#[must_use]` is a better default -- the cost of mistake needs to be taken into account.

In particular, cost of missing `#[must_use]` is low -- the attribute is actually important only for a small fraction of functions, and it's easy to add it manually for them. For majority of the functions which are not confusable, utility of `#[must_use]` is low.

On the other hand, cost of missing `#[discardable]` is high. Today we derive a lot of value from almost all warning being true warnings, actionable and useful. Making `#[must_use]` default, we'll add an unbounded number of false warnings (new written code which forgets about `#[discardable]` adds false warnings). As a maximally pessimistic scenario, error handling today relies on `#[must_use]`; `let _ = ` is rare and stands out, and allows you to quickly notice important places where errors are silent. In the `#[discardable]` world, `let _ =` might become frequent enough to not make it jump out at you, reducing error handling reliability.

To clarify, I am not arguing one way or another, I don't know how to weigh the tradeoff. I do want to point out that it is not `which one is more common`, but `which one is more common * cost of wrong classification`.

---

_[View the full topic](https://internals.rust-lang.org/t/use-of-must-use-in-the-standard-library/15425)._
