# Missing trait hint

**URL:** <https://internals.rust-lang.org/t/missing-trait-hint/15182>\
**Category:** language design\
**Created:** [August 15, 2021, 8:37pm UTC](https://internals.rust-lang.org/t/missing-trait-hint/15182 "2021-08-15T20:37:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![almindor](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/almindor/32/5069_2.png) [@almindor](https://internals.rust-lang.org/u/almindor)\
**Post date:** [August 15, 2021, 8:37pm UTC](https://internals.rust-lang.org/t/missing-trait-hint/15182/1 "2021-08-15T20:37:58Z")

</div>

Would it make sense to allow use of something like `#[rustc_on_unimplemented()]` for general library authors?

Right now if a missing trait is encountered a rather cumbersome error is shown. The authors could possibly provide an additional hint to the error as an annotation such as it is done with `Fn` already using `#[rustc_on_unimplemented()]`

There are some good uses cases especially in the embedded space where traits or their lack thereof is used as compile time checks. Missing one then results in very complex errors, but if this annotation could be made public the authors could provide meaningful hints for the context.

[Example case](https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=235b9f89e1a778c1b52c1157838ecd03)

See [this reddit topic](https://www.reddit.com/r/rust/comments/p2oz44/missing_trait_hint/) for more disscussion.

---

<div class="post-metadata">

**Author:** ![ekuber](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/ekuber/32/1646_2.png) [@ekuber](https://internals.rust-lang.org/u/ekuber)\
**Post date:** [August 16, 2021, 1:44pm UTC](https://internals.rust-lang.org/t/missing-trait-hint/15182/2 "2021-08-16T13:44:16Z")

</div>

We definitely want something that can fill this void. The reason `rustc_on_unimplemented` isn't stabilized is that the current API is very ad-hoc and less than ideal. It has grown as we needed specific features for stdlib, we added them without much rhyme or reason. Stabilizing it outright would make us commit to maintaining that subpar API working indefinitely. I would love to see an RFC for an alternative.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/system/32/14092_2.png) [@system](https://internals.rust-lang.org/u/system)\
**Post date:** [November 14, 2021, 1:44pm UTC](https://internals.rust-lang.org/t/missing-trait-hint/15182/3 "2021-11-14T13:44:23Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
