-
Notifications
You must be signed in to change notification settings - Fork 13.3k
[MIR] Handle overloaded call expressions during HIR -> HAIR translation. #30692
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
[MIR] Handle overloaded call expressions during HIR -> HAIR translation. #30692
Conversation
(rust_highfive has picked a reviewer for you, use r? to override) |
@@ -88,6 +88,19 @@ fn test8() -> isize { | |||
Two::two() | |||
} | |||
|
|||
#[rustc_mir(graphviz="method.dot")] |
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.
We do not want graphviz output during tests.
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.
Whoops, that shouldn't be in there...
Overall LGTM. |
bc51c40
to
545e9d2
Compare
Fixed the graphviz thing. |
#[rustc_mir] | ||
fn test_fn_object(f: &Fn(i32, i32) -> i32, x: i32, y: i32) -> i32 { | ||
f(x, y) | ||
} |
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.
shouldn't we write a test that is not for a closure object?
r=me with a non-object test as well |
545e9d2
to
1f69493
Compare
@bors r+ |
📌 Commit 1f69493 has been approved by |
…when translating function references.
@bors r- |
I want to get rid of an unnecessary |
1f69493
to
e281509
Compare
@bors r=nikomatsakis |
📌 Commit e281509 has been approved by |
⌛ Testing commit e281509 with merge 8f7e5bb... |
💔 Test failed - auto-linux-64-opt |
@bors retry |
…komatsakis So far, calls going through `Fn::call`, `FnMut::call_mut`, or `FnOnce::call_once` have not been translated properly into MIR: The call `f(a, b, c)` where `f: Fn(T1, T2, T3)` would end up in MIR as: ``` call `f` with arguments `a`, `b`, `c` ``` What we really want is: ``` call `Fn::call` with arguments `f`, `a`, `b`, `c` ``` This PR transforms these kinds of overloaded calls during `HIR -> HAIR` translation. What's still a bit funky is that the `Fn` traits expect arguments to be tupled but due to special handling type-checking and trans, we do not actually tuple arguments and everything still checks out fine. So, after this PR we end up with MIR containing calls where function signature and arguments seemingly don't match: ``` call Fn::call(&self, args: (T1, T2, T3)) with arguments `f`, `a`, `b`, `c` ``` instead of ``` call Fn::call(&self, args: (T1, T2, T3)) with arguments `f`, (`a`, `b`, `c`) // <- args tupled! ``` It would be nice if the call traits could go without special handling in MIR and later on.
So far, calls going through
Fn::call
,FnMut::call_mut
, orFnOnce::call_once
have not been translated properly into MIR:The call
f(a, b, c)
wheref: Fn(T1, T2, T3)
would end up in MIR as:What we really want is:
This PR transforms these kinds of overloaded calls during
HIR -> HAIR
translation.What's still a bit funky is that the
Fn
traits expect arguments to be tupled but due to special handling type-checking and trans, we do not actually tuple arguments and everything still checks out fine. So, after this PR we end up with MIR containing calls where function signature and arguments seemingly don't match:instead of
It would be nice if the call traits could go without special handling in MIR and later on.