-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Demote self to an (almost) regular argument and remove the env param. #11595
Conversation
} | ||
|
||
for arg in decl.inputs.iter() { | ||
// HACK(eddyb) ignore the sepparately printed self argument. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
ast::ExprMethodCall(_, rcvr, _, _, ref args, _) => { | ||
self.call(expr, pred, rcvr, *args) | ||
ast::ExprMethodCall(_, _, _, ref args, _) => { | ||
self.call(expr, pred, args[0], args.slice_from(1)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
@@ -777,50 +774,41 @@ fn check_loans_in_expr<'a>(this: &mut CheckLoanCtxt<'a>, | |||
|
|||
let method_map = this.bccx.method_map.borrow(); | |||
match expr.node { | |||
ast::ExprSelf | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
debug!("after subst, fty={}", self.ty_to_str(fty)); | ||
|
||
// Replace any bound regions that appear in the function | ||
// signature with region variables | ||
let bare_fn_ty = match ty::get(fty).sty { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
Can we make the |
@huonw it's all happening inside LLVM, both the wrapper and the original function are internal. |
It seems like this is an error in the reachability computation. |
Non-exhaustive change list: * `self` is now present in argument lists (modulo type-checking code I don't trust myself to refactor) * methods have the same calling convention as bare functions (including the self argument) * the env param is gone from all bare functions (and methods), only used by closures and `proc`s * bare functions can only be coerced to closures and `proc`s if they are statically resolved, as they now require creating a wrapper specific to that function, to avoid indirect wrappers (equivalent to `impl<..Args, Ret> Fn<..Args, Ret> for fn(..Args) -> Ret`) that might not be optimizable by LLVM and don't work for `proc`s * refactored some `trans::closure` code, leading to the removal of `trans::glue::make_free_glue` and `ty_opaque_closure_ptr`
…et,GuillaumeGomez Allow more attributes in `clippy::useless_attribute` Fixes rust-lang#12753 Fixes rust-lang#4467 Fixes rust-lang#11595 Fixes rust-lang#10878 changelog: [`useless_attribute`]: Attributes allowed on `use` items now include `ambiguous_glob_exports`, `hidden_glob_reexports`, `dead_code`, `unused_braces`, and `clippy::disallowed_types`.
Non-exhaustive change list:
self
is now present in argument lists (modulo type-checking code I don't trust myself to refactor)proc
sproc
s 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 forproc
strans::closure
code, leading to the removal oftrans::glue::make_free_glue
andty_opaque_closure_ptr