-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
At times, our compiler errors just flat out suck. While in this issue I will list several cases that I've specifically noticed are frequently problematic or have personally encountered, it should not be treated as exhaustive. If you've ever received a non-helpful compiler message from this lib, please comment with details. I do not think we will be able to fix all of them, but we should try to improve this issue before 1.0.
Truly "fixing" this will probably require significantly more control over the "trait not implemented" error, both on the trait itself (e.g. we can give a much better message for any case where SelectableExpression
isn't implemented), and also at the function level (e.g. when find
doesn't work, we can probably be more specific, even though none of the traits failing are specific to find).
As we attempt to make sure we create good error messages, we should update our compile-fail
suite to be significantly more specific about the error messages we generate. While that will make those tests much more brittle, I'd rather have to update them frequently (and thus ensure that the new error message is still reasonable), than accidentally start generating a nonsense error for a common case.
Problem Cases
Recommending Expression
instead of AsExpression
A consistent source of confusion is rustc
's recommendation to implement Expression
, NonAggregate
, and QueryFragment
, when the missing piece is actually AsExpression
. Ultimately this is due to rust-lang/rust#28894. If we can't fix that issue in the language, we should probably just remove that blanket impl and brute force it instead (I'm honestly surprised the coherence rules haven't forced this already, I think this is the only blanket impl that's survived).
Some types are too long to ever appear in error messages
Another case that we should look for is any case where SelectStatement
or FilterQuerySource
end up in the final error message. It doesn't matter what trait is missing, the error message SelectStatement<(type1, type2, type3, 10moretypes), (col1, col2, col3, 10morecolumns), InnerJoinQuerySource<left_table, right_table>, NoWhereClause, NoOrderClause, NoLimitClause, NoOffsetClause> does not implement AsQuery
will always be too noisy to be helpful. That specific error is actually one of the simpler cases, and even with that exact case, every type would have the fully qualified path, and be repeated 3 times (saying it looked at SelectStatement
, &SelectStatement
, and &mut SelectStatement
). It's not uncommon for that kind of error message to take up the entire terminal window.