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 because Box<Foo>: Debug does not hold:
- impl from stdlib for
Box does not apply because Foo: Debug does not hold:
- no impl of
Debug for Foo found
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?
cc @aturon @arielb1
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>>: Debugand it turns out thatFoo: ?Debug, then we would print something like:Vec<Box<Foo>>: Debugdoes not holdVecdoes not apply becauseBox<Foo>: Debugdoes not hold:Boxdoes not apply becauseFoo: Debugdoes not hold:DebugforFoofoundAs 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?
cc @aturon @arielb1