librustc: Implement the unboxed closure trait hierarchy.#17543
librustc: Implement the unboxed closure trait hierarchy.#17543pcwalton wants to merge 1 commit intorust-lang:masterfrom
Conversation
This makes `FnMut` require `FnOnce` and `Fn` require `FnMut`. Therefore, this change breaks code that implements the `FnMut` and/or `Fn` traits directly, without also implementing their dependencies. A simple forwarding implementation that defines `FnOnce` in terms of `FnMut` and/or `Fn` in terms of `FnMut` will suffice. This does not affect code that simply uses the `|&:|`/`|&mut:|`/`|:|` unboxed closure construction notation. Part of RFC rust-lang#44; needed to implement RFC rust-lang#63. Part of issue rust-lang#12831. [breaking-change]
|
OK, so, I read through this patch and it all makes sense. However, I also remembered that what I originally had in mind was that we could (I think) alternatively create an impl for all |
|
@pcwalton the aliasing restrictions don't matter to trans...but by-value self is potentially different LLVM bitcode, yes. |
|
@pcwalton I just drew up a quick sketch showing what I mean -- it seems to work, at least when all the impls are user-defined: 82d37da Hat tip: @glaebhoerl suggested this approach first. |
|
ping @pcwalton, any progres here? |
|
This should be fairly trivial to do now. I'm going to check it out. |
|
Closing in favor of #18388 |
This makes
FnMutrequireFnOnceandFnrequireFnMut. Therefore,this change breaks code that implements the
FnMutand/orFntraitsdirectly, without also implementing their dependencies. A simple
forwarding implementation that defines
FnOncein terms ofFnMutand/or
Fnin terms ofFnMutwill suffice.This does not affect code that simply uses the
|&:|/|&mut:|/|:|unboxed closure construction notation.
Part of RFC #44; needed to implement RFC #63.
Part of issue #12831.
[breaking-change]
r? @nikomatsakis