See #155746
#![feature(allocator_api)]
#[test]
fn make_mut_leaks() {
use std::alloc::Global;
use std::rc::Rc;
use std::sync::Arc;
let alloc = Rc::new(Global);
{
let mut arc = Arc::new_in(123, alloc.clone());
let weak = Arc::downgrade(&arc); // create a weak so make_mut steals the data
_ = Arc::make_mut(&mut arc);
assert_eq!(weak.upgrade(), None);
}
assert_eq!(Rc::strong_count(&alloc), 1); // if this is >1, we have a memory leak!
}
See #155746