Demote self to an (almost) regular argument and remove the env param.#11595
Demote self to an (almost) regular argument and remove the env param.#11595bors merged 1 commit intorust-lang:masterfrom
Conversation
src/libsyntax/print/pprust.rs
Outdated
There was a problem hiding this comment.
Minor nit: there is a typo in separately here.
|
I don't really consider myself able to review, but it would be nice to have a summary of changes as opposed to "No description given" with one monolithic commit. It also looks like this changes language semantics (bare function pointers can no longer coerce to a closure?), so this should probably be discussed. |
There was a problem hiding this comment.
It makes me a bit weary seeing these args[0] all over the place. It seems like it could be pretty easy to treat a regular fn call's args[0] as a receiver, or forget to extract out the receiver from a method call. Since there are now only a few cases where regular fn arguments seem to be different from method arguments, could we combine the two into a ast::CallArgs enum? That might help make things more clear when we are dealing with a special case.
There was a problem hiding this comment.
actually it seems like moving the self into the args list makes things cleaner overall, I'd say
|
cc @luqmana, who has also mucked around with the |
|
I will review (not to say others shouldn't read). |
|
And yes, this will change language semantics -- per our recent discussion in meeting, I was initially opposed, but was swayed by @eddyb's argument concerning possible future extension to a |
|
@erickt about UFCS - only thing left is to allow calling them as functions - see |
|
We discussed this in today's meeting and agreed it's fine. |
There was a problem hiding this comment.
Can you please revert this reformatting? I don't see any changes here and I'd rather avoid unnecessary conflicts.
There was a problem hiding this comment.
I may have actually hit this during rebasing, will revert (there's actually a couple changes in there).
|
Still reading. Probably 50% of the way through (though I think I'm past the hard bits). Too tired to finish tonight, hopefully tomorrow morning. Really nice. |
There was a problem hiding this comment.
Under the new flow, bare_fn_ty here is always equal to candidate.method_ty.fty. Moreover, the construction of fty at the top of the function is unnecessary; it is only used here (where it is not needed) and in enforce_object_limitations(), where it appears it is not needed. I'd rather we just strip it out. The logic of this function is complex enough that unnecessary variables is rather distracting.
Perhaps add this comment:
// This method performs two sets of substitutions, one after the other:
// 1. Substitute values for any type/lifetime parameters from the impl and method declaration into the method type.
// This is the function type before it is called; it may still include late bound region variables.
// 2. Instantiate any late bound lifetime parameters in the method itself with fresh region variables.
|
OK, I finished the review. Very nice work. r+ given that comments are addressed and the following tests are added:
Sorry it took me some time! A lot of changes here, but good stuff to be sure. |
|
Seems I broke the test for #6919 (though it didn't actually fail locally - maybe it never ran as part of The issue is with a public I am not sure how to solve this, short of a wrapper cache mapping bare function symbol names to wrapper symbol names, exported in crate metadata, but that's a bit excessive, I would say. |
Non-exhaustive change list:
selfis now present in argument lists (modulo type-checking code I don't trust myself to refactor)procsprocs if they are statically resolved, as they now require creating a wrapper specific to that function, to avoid indirect wrappers (equivalent toimpl<..Args, Ret> Fn<..Args, Ret> for fn(..Args) -> Ret) that might not be optimizable by LLVM and don't work forprocstrans::closurecode, leading to the removal oftrans::glue::make_free_glueandty_opaque_closure_ptr