You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have the following code (minimized from the code linked above, so names will seem weird out of context; that doesn't have any bearing on the example):
error[[E0282]](https://doc.rust-lang.org/stable/error_codes/E0282.html): type annotations needed
--> src/lib.rs:22:60
|
22 | let inner_to_field = |inner| ::core::ptr::addr_of!((*inner) $($f)*);
| ^^^^^^^^ cannot infer type
...
34 | project!(&m.1)
| -------------- in this macro invocation
|
= note: this error originates in the macro `project` (in Nightly builds, run with -Z macro-backtrace for more info)
This is surprising to me, as the type constraints haven't changed at all. I'd assume that, if type inference had enough information to succeed with the first version of the code, it'd have enough information to succeed with the second version of the code.
Reporting this in case it's an inference bug.
The text was updated successfully, but these errors were encountered:
This is essentially expected. Closure signature inference relies on the fact that it's an argument to project to provide sufficient information about the signature to then be able to type-check the body of the closure.
I see. I assume that that the type information provided when the closure is used in argument position is just a special case to help out that use case?
Prompted by @SkiFire13's suggestion in google/zerocopy#196 (comment).
I have the following code (minimized from the code linked above, so names will seem weird out of context; that doesn't have any bearing on the example):
This compiles fine. However, if I move the
|inner| ...
closure to first be assigned to a variable:...it results in a type inference failure:
This is surprising to me, as the type constraints haven't changed at all. I'd assume that, if type inference had enough information to succeed with the first version of the code, it'd have enough information to succeed with the second version of the code.
Reporting this in case it's an inference bug.
The text was updated successfully, but these errors were encountered: