-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Diagnostics for blanket impl of closure traits are suboptimal #24210
Comments
triage: P-high (1.0) I consider this a nice to have, but it's prob not too hard to really improve this error message. |
You don’t even need a blanket trait impl to get a poor error message; using an intermediate variable binding also gives no hint as to what stops the closure from implementing fn foo<T: Fn()>(_: T) {}
fn main() {
let a = Box::new(1);
let x = || {
a;
};
foo(x);
} gives
|
hahahaha yes, I'm glad I'm not the only one that thinks this. I think this is the weakest area I've witnessed in Rust's error diagnostics and I think it will be a major pain-point for newcomers, which will probably lead them to see Rust closures as very complex and difficult to understand. I had a lot of trouble with this myself until I ran into it multiple times and @p1start helped me track down the problem, so I think I know what to look for now. I'm happy to see that this is a high priority! |
Replace consider_unification_despite_ambiguity with new obligation variant Is work towards #32730. Addresses part one of #32286. Addresses #24210 and #26046 to some degree. r? @nikomatsakis
triage: P-low Note a P-medium issue by today's standards, and also hasn't gone fixed for quite awhile! Also cc @jonathandturner, issue about diagnostics. Also removing the assignee of @nikomatsakis as I believe this isn't actively being worked on |
@arielb1 Unassigning you since this isn't being worked on as far as I know. with x:
with y:
|
Today, the
|
The
x
line giveswhile the
y
line gives:The latter doesn't really give much information about the problem (moving out of
y
) and, AFAIK, the most effective way to debug is to find the offending statement via binary search commenting out chunks of code. :(The text was updated successfully, but these errors were encountered: