CFI: Abstract Closures and Coroutines by maurer · Pull Request #123106 · rust-lang/rust (original) (raw)
I think I answered this on the previous change, but I also left a comment above it in the first half of this if
statement when I set Virtual
the first time explaining. The short version of that comment is that this is an adjusted type for the case where the callsite will have a Virtual
. I wanted to make the callsite and the declaration match as closely as possible to make it harder to make a mistake.
This also means that fn_abi
will use its special logic for unwrapping receivers in the case that the receiver is not already directly a pointer to a dyn Trait
- it'll unwrap the ZST repeatedly until it gets to one. This is load-bearing in the top half of the if
condition, because alternate receivers happen.
Finally, in the future we could choose to support the fact that Virtual
&dyn Trait
in receiver position is different from any other instance's &dyn Trait
in receiver position, in that it's a single pointer instead of double-wide, and encode that differently (we don't do this today).
All that said, since none of the Fn
-trait receivers use receivers that need unwrapping, I can replace this with Item
if you really want me to.