// error-pattern: deallocating while item is protected use std::cell::Cell; // Check that even `&Cell` are dereferenceable. // Also see . fn inner(x: &Cell, f: fn(&Cell)) { // `f` may mutate, but it may not deallocate! f(x) } fn main() { inner(Box::leak(Box::new(Cell::new(0))), |x| { let raw = x as *const _ as *mut Cell; drop(unsafe { Box::from_raw(raw) }); }); }