Stream: general

Topic: Fixing #22590

mikeyhew (Jan 15 2019 at 01:58, on Zulip):

Ever since I started using Rust, there's been this issue of bad error messages when a type doesn't implement a trait, but there are blanket impls for that trait which don't apply. This is documented in issue #22590. You can see my latest comment on the issue for an example, but I'll describe it here too:

Let's say there is a failing trait bound: T: Foo. If there are no blanket impls of Foo, the error message is the trait bound `T: Foo` is not satisfied. This is OK. It's maybe not the best error message ever, but it's not horrible.

But if there exists a blanket impl of Foo for T that has certain restrictions, let's say T: Bar. Then the error message will be the trait bound `T: Bar` is not satisfied, even the the real problem is that T does not implement Foo. This gets even more confusing if the blanket impl has a requirement like T: 'static, or an implicit T: Sized.

@nikomatsakis you suggested a better way to report these errors - starting with the "top-level" thing that failed. In this case it would be T: Foo, or perhaps the function call that the T: Foo obligation came from. Do you have any ideas about how that could be implemented?

mikeyhew (Jan 23 2019 at 20:13, on Zulip):

@nikomatsakis you may not have gotten a notification when I posted this

Last update: Jul 16 2020 at 15:20UTC