Fully translate closures, also handle closure casts #716
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
TypeDecl.src: ItemKind
, with the type's source (eitherTopLevel
orClosure
)fn_once_impl: TraitImplRef
,fn_mut_impl: Option<TraitImplRef>
,fn_impl: Option<TraitImplRef>
toClosureInfo
This also means that closure's functions/traits are translated even when they're not used, however that's necessary to properly translate e.g. closure-casts.
For instance for the following code, if we don't translate the closure's function then it is never translated in the (U)LLBC, as it is never referred to directly (instead, only the ADT was translated).
Now instead we generate all three Fn[Once,Mut] trait impls, functions, as well as an additional function that looks like