3 ms·
https://github.com/rust-lang/rust/blob/master/src/liballoc/rc.rs#L408 https://github.com/rust-lang/rust/blob/master/src/liballoc/r...
by steveklabnik 12y ago
https://github.com/rust-lang/rust/blob/master/src/liballoc/rc.rs#L408 https://github.com/rust-lang/rust/blob/master/src/liballoc/r...
- mcguire 12y agoMaking mem::forget safe makes that point moot. https://github.com/rust-lang/rfcs/pull/1066 https://github.com/rust-lang/rfcs/pull/1066
- steveklabnik 12y agoForget isn't the reason that that block is unsafe.
- mcguire 12y agoRight. That block is unsafe because it's doing unsafe things. (ptr::read and alloc::heap::deallocate) But the use of Rc is kind of a red herring; if mem::forget is marked safe, then you don't need safe_forget because you can forget things (fail to execute their destructors, specifically) safely anyway. The problem is that destructors aren't guaranteed; the bugs in the thready thing (and potentially unbounded other things) are symptoms. Drop needs big, red warning signs. The power of a notation, and a type system, is in what it lets you not think about. The fact that destructors may not be called is, unfortunately, something you have to think about.