Thread with 10 posts
jump to expanded postexciting programming problem in touchHLE: supporting inheritance for instance variables. look at how gnarly this is:
https://github.com/hikari-no-yume/touchHLE/commit/ae5b7a8d6513e3204d3c2eab1f250cdcf8930ee5
i have an idea for a neater solution, but it will involve descending further into the land of Any
s and 'static
s and 'a
s and dyn
s :3
THE BAD NEWS: i have ran head-first into the borrow checker struggling with mutable borrows in loops again ;_;
THE GOOD NEWS: unsafe { &mut *(a as *mut _) }
is my friend and would never hurt me :3
@hikari are you running Miri on this to find out if it would hurt you
@porglezomp (gaben voice) uhh⦠no
@porglezomp but it's simple enough that i know it must be safe. there is never an actually overlapping mutable borrow, and the lifetimes are all identical
@hikari
β’ use miri itβs also your friend
β’ if itβs so obvious surely you can make it obvious to the compiler also
@porglezomp AIUI it's a known limitation of the borrow checker, it simply cannot handle a loop that updates mutable borrows with early returns, or something like that :(
@porglezomp I've run into it multiple times before and this time I just don't have any patience for it. I do not want to play the game of making my code comically inefficient just to work around this limitation of rustc.
@hikari @porglezomp for some reason I'm suspicious this is related to split borrows or something. and might work with deleting the wrapper functions. don't know it for certain though.
@hikari @porglezomp a little rustc fairy suggests the original code will probably compile with -Z polonius, and it is indeed a current-rustc limitation. but it won't be a future one, at some point! https://crates.io/crates/polonius-the-crab/0.3.1