Missing trait hint

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

See this reddit topic for more disscussion.

4 Likes

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.

2 Likes

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