Turns out it's possible to violate safety in Rust with Rc and integer overflow:
miniblog.
Related Posts
It's really satisfying fixing crashes in rust-analyzer. You can start from a panic message and dig until you've got a tiny Rust program that triggers the problem.
(It's usually an issue with incomplete source files breaking invariants.)
Today I learnt about clippy::clone_on_ref_ptr, which complains about t.clone() on a Rc<Thing>. You write Rc::clone(t) instead, so it's obvious it's a cheap clone.
It's a nice approach, because it makes the expensive clones more obvious.
It's funny how languages can offer multiple forms of syntax, but formatters standardise to a single form.
E.g. single vs double quotes in JS, optional semicolons in JS, different ways of grouping imports in Rust.
Should new languages be more syntactically opinionated?
![Rc is unsafe [mostly on 32-bit targets] due to overflow](https://us1.discourse-cdn.com/flex002/uploads/rustlang/original/2X/b/b71959a2097ce0b5c3a193ce0a6466a42d4c4952.png)