Skip to content
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

Ensure for Coercion Sites we emit the code nessecary #710

Merged
merged 4 commits into from
Oct 13, 2021
Merged

Conversation

philberty
Copy link
Member

Coercion sites in Rust can require extra code generation for
CallExpressions arguments for example. This ensures we detect
those cases and emit the extra code necessary. Please read the individual
commit messages for more detail on how this works.

Fixes #700 #708 #709

This removes the bad code style lambda iterators for arguments. They are
a bad design choice for static analysis code since the user of the api
looses scope to break/return outside from the caller api. This will need
to be added to a style-guide in the future.

Fixes: #708
This removes the bad code style lambda iterators for arguments. They are
a bad design choice for static analysis code since the user of the api
looses scope to break/return outside from the caller api. This will need
to be added to a style-guide in the future.

Fixes: #709
…type

Coercion sites like CallExpr arguments must coerce the arguments for
type checking, but we must still insert the type of the actual argument
for that mapping not the coerced type. For example we might have:

```rust
fn dynamic_dispatch(t: &dyn Bar) {
    t.baz();
}

fn main() {
    let a = &Foo(123);
    dynamic_dispatch(a);
}
```

Here the argument 'a' has a type of (&ADT{Foo}) but this is coerceable to
(&dyn{Bar}) which is fine. The backend needs to be able to detect the
coercion from the two types in order to generate the vtable code. This
patch fixes the type checking such that we store the actual type of
(&ADT{Foo}) at that argument mapping instead of the coerced one.

Addresses: #700
…Expr

When we coerce the types of arguments to the parameters of functions for
example we must store the actual type of the argument at that HIR ID not
the coerced ones. This gives the backend a chance to then figure out
when to actually implement any coercion site code. such as computing the
dynamic objects.

Fixes: #700
@philberty
Copy link
Member Author

bors r+

@bors
Copy link
Contributor

bors bot commented Oct 13, 2021

Build succeeded:

@bors bors bot merged commit 7a34177 into master Oct 13, 2021
@philberty philberty deleted the phil/coercions branch October 14, 2021 15:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
1 participant