News for hackers. Stuff that matters.
Re:Prusti: Static Analyzer for Rust by nine_k on Thursday October 13, 2022 @06:11PM (#33197119)
But how passing around a (constant) raw pointer is not sidestepping borrow checker? Since the pointer (AFAICT) does need to be borrowed, because it's manifestly immutable, it could be passed into several functions that alter the pointed-at memory in arbitrary order.
Re:Prusti: Static Analyzer for Rust by epilys on Friday October 14, 2022 @08:13AM (#33202485)
Yeah it is sidestepping as you say! The distinction is that if you don't sidestep by dereferencing raw pointers, the borrow check still works. Observe that you can cast as raw pointers in safe rust. What unsafe {} changes is that you can dereference them. The borrow checker still works for regularly borrowed values (&var and &mut var etc). This is probably obvious for Rust users, but I find some people take the "turn the borrow checker off" literally by assuming they won't get lifetime errors if the put an unsafe { } around their code.