Error message does not list the relevant trait bounds that were not satisfied #68131
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-trait-system
Area: Trait system
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I don't know for sure, but this feels like an interaction between method dispatch, deref, and possibly
Send
.Here's a fairly minimal reproduction of the issue: (Playground)
The error message in question:
The type of
x
isVec<Rc<i32>>
. Rayon has an impl with the following signature:The problem here is that
Vec<Rc<i32>>: IntoParallelIterator
is not satisfied becauseRc<i32>: Send
is not satisfied.Because
Vec<Rc<i32>>
derefs to[Rc<i32>]
, the error message lists that as the trait bound to be satisfied. This is very unhelpful because there is no way you could ever satisfy that constraint.While fixing the message to also list
Vec<Rc<i32>>
in addition to[Rc<i32>]
would be helpful, it doesn't help solve the actual problem which is thatRc<i32>
is notSend
. The code I initially ran into this with had anRc
about ~15 structs down, so it was not obvious at all what the problem was until I looked at the relevant impl in the rayon docs and added the following to my code:Once I did that, I got a full error message that nicely lists the entire stack of obligations that led to
Send
not being fulfilled.It would be very helpful if the compiler could tell me that
Rc<i32>: Send
is not satisfied so I could skip all of those steps. (Rc<i32>: Send
in my minimal example,MyType: Send
in actual code)The text was updated successfully, but these errors were encountered: