Description
Now that #30533 has landed, we can change how we report trait errors to give a complete backtrace. In fact, I suspect the most intuitive thing would be to start from the root obligation and print that, and then show the chain of reasoning which ultimately failed. For example, if we had Vec<Box<Foo>>: Debug
and it turns out that Foo: ?Debug
, then we would print something like:
Vec<Box<Foo>>: Debug
does not hold- impl from stdlib for
Vec
does not apply becauseBox<Foo>: Debug
does not hold: - impl from stdlib for
Box
does not apply becauseFoo: Debug
does not hold: - no impl of
Debug
forFoo
found
- impl from stdlib for
As part of this, we will want to (I think) change how we assign "causes" to the subobligations. Currently, we propagate the cause of the root obligation. I think what we want to do instead is to assign a cause that indicates the impl whence the subobligation was created. That way, when printing the backtrace, we can walk through the impls and show them to the user.
PS, I know there is a duplicate of various existing bug reports. I didn't really look, but we should try to gather up all the various examples into one master bug. Perhaps this one?