-
Notifications
You must be signed in to change notification settings - Fork 385
Implement arbitrary-self dynamic method receivers #1038
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
This is one of the things we have to do (you'd get this for free if you're using |
You keep saying that.^^ Is that type in a place these days where Miri could reuse it? I recall it used to be in the wrong crate. Also I have no idea what it would take to port Miri to that API. |
I guess you might want to wait for rust-lang/rust#65947 to make it clearer how you're supposed to create it. |
IOW, this is blocked on rust-lang/rust#56166. |
My understanding was that FnAbi would take care of the details of this, but now I found this code: Looks like the codegen backends and Miri still need some ad-hoc code to descend to the right type of an arbitrary-self-receiver. Similar code exists at I am not sure if that is exactly the same or subtly different, but I feel like some kind of helper method could at least share the code between codegen and Miri -- but I don't understand enough to figure out the details. |
The basic idea is that if you have a fat pointer you need to strip the vtable pointer to make it a thin pointer before passing it as self value to the callee. Both snippets you linked unwrap a fat pointer embedded inside a struct so that for |
But the entire type is just a newtyped fat ptr, right? So really this is just type information getting in the way and what we would want is to just transmute the argument to a data ptr and a vtable ptr and handle those separately? |
Also I don't think I understand how using FnAbi (implemented in rust-lang/rust#91342) should help with this... now that I did the FnAbi change, it seems mostly orthogonal to me. |
The tests added in rust-lang/rust#54383 fail in Miri:
This is ICEing in this code:
https://github.com/rust-lang/rust/blob/7a76fe76f756895b8cda1e10398f2268656a2e0f/src/librustc_mir/interpret/terminator.rs#L430-L438
Clearly, that code assumes that only things that
builtin_deref
supports are receivers, and everything else is unsized -- hence theassert_mem_place
, which fails.So, how does one implement arbitrary-self dynamic receivers? What actually happens at run-time here? I don't know.^^
Cc @eddyb @mikeyhew
The text was updated successfully, but these errors were encountered: