-
Notifications
You must be signed in to change notification settings - Fork 4
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
Roadmap for closures, fn pointers, and traits #30
Comments
David's proposalThe function creating a closure or function pointer is responsible to ensure not just that that function pointer is used safely within the function, but also that it is safely called in any other context outside of that function. If not, it must be marked completely unsafe during an audit. Example:
Unfortunately |
Alternative proposalThe advantage of David's proposal is it's very simple, and easy to audit things; the disadvantage of it is that any crates which use functions like An alternative approach is to consider all uses of function pointers and closures to be unsafe, rather than their creation. Under this proposal, all of
Under David's proposal, we don't need to audit the call to |
RFC on the above! Both of these just handle the case of fn pointers and closures, and not the case of traits. |
I'd go with @DavidThien 's proposal -- which seems simpler. We can always do fancier things if we turn out they are needed in practice? |
Actually IMO both proposals are almost equally simple to implement -- but the alternative proposal might lead to more noise during an audit. In terms of implementation, the second just means adding "unknown call to a callable type" as a first-class category of unsafe effect. |
Decision for function pointers and closuresDECISION: for v0 of the tool, we're going with David's proposal. This is because the alternate proposal seems to have serious problems! Even for very simple uses of closures, like the typical case of maps and filters over iterators. See the following example:
Updated RoadmapTherefore, an updated roadmap for function pointers and closures is:
Discussion for traitsWe are still deciding what to do about traits, hopefully discussing tomorrow. |
This is a work-in-progress, discussion welcome!
A possible short-term roadmap is:
UnknownCall
: an additional type of unsafety that must be audited. This is used for calls to closures and calls to function pointers.UnknownTraitCall
: this applies to calls to dynamic trait objects, and calls to traits in a generic context. In other words, if we callt.foo()
where we don't know the exact type oft
.t.foo()
where we do know the type oft
), fix resolution: currently we are resolving them to the trait path, we need to resolve them to the path where the trait is implemented instead.Longer term:
UnknownCall
The text was updated successfully, but these errors were encountered: