3

Rust used to have a ton of pointer types:

Older Rusts had many more pointer types, they’re gone now.

https://doc.rust-lang.org/guide-pointers.html

I'm looking to understand the chronology of some of them to understand the language's evolution a little more deeply.

Q1: What were they? Are there previous versions of the Rust docs online that I can look at or do I have to recompile the old docs to do so?

Q2: What became of each pointer type as the language evolved (e.g. became redundant, functionality merged someplace else, dropped as a feature, etc.)?

1
  • I would recommend to look at release notes, specifically sections for versions 0.11 and 0.12. Several types of pointers became standard library structures instead of built-in language features, and @/Gc was removed altogether.
    – justinas
    Nov 10, 2020 at 13:38

1 Answer 1

9

From the archive of the guide: screenshot of cheat sheet

Interestingly, it appears that Rust used to call Box, Rc, and Arc pointer types. So, unfortunately, it seems like the pointer types that the guide was claiming Rust once had are actually still in the language. However, that doesn't mean there still isn't a story behind these types. Rust actually used to have two different box types, ~T and @T, but these were removed in version 0.11.0 in favor of Box and Gc, respectively (believe it or not Rust actually had a garbage collector back then). In the 1.0.0 alpha, the box keyword (which has been in the language from as early as 0.1.0) was feature-gated for a redesign, and the discussion is still happening to this day. After that change, no real major changes happened to Box except for a couple extra trait implementations and method additions.

Now, for Arc and Rc. Arc appears to have been added as early as version 0.3, and Rc was added in version 0.7. Also, unlike modern Rust, Rc did not have a way to get a mutable reference, and they instead opted for having both Rc and RcMut. Arc was even weirder, having an immutable ARC, a MutexARC (instead of the current Arc<Mutex<T>>), and a mutable RWARC. In version 0.8, despite not being in the changelogs for whatever reason, ARC finally got lowercased to Arc. In version 0.9, more undocumented changes happened where Rc was moved from the extra crate to std, and RcMut was mysteriously removed. An UnsafeArc was added into std::sync::arc, but extra::arc::Arc remained. In version 0.10, Weak was added for cycle breaking, and prior to that version, Rust surprisingly tried to statically prevent Rc cycles. In version 0.11.0, sweeping changes were made to Arc, separating Arc and Mutex, but Arc was still immutable and relied on Arc<RWLock<T>> to simulate Arc's current behavior. Strangely enough, Rc was still immutable. In version 1.0.0, Rc finally got the get_mut method we know and love. However, Arc still depended on RwLock. Arc was a bit slower, getting an unstable get_mut function in 1.3.0.

And now, the interesting one. What happened to Gc? It was removed in version 0.12 due to being poorly implemented, confusing, and the only reason why many obsolete language features existed at the time, with the promise that a garbage collector would be revisited in the future. As we know now, that never happened.

As for if you can see old docs, yes you can. They're all hosted at static.rust-lang.org. Just go to https://static.rust-lang.org/doc/VERSION_NUMBER/CRATE_NAME/index.html, such as https://static.rust-lang.org/doc/0.7/std/index.html.

2
  • 1
    FWIW Rust called them "pointer types" because as can be seen from the syntax they were special buit-ins of the language. Though Box remains special-cased, the old pointer types were embedded much deeper into the language, rather like references still are.
    – Masklinn
    Nov 10, 2020 at 14:14
  • "believe it or not Rust actually had a garbage collector back then" technically no more so than today, as the removal note indicates the "Gc" type (and the corresponding poiter) was just reference counted, implementing a proper Gc had been in the plans from the start, but got dropped alongside Gc itself.
    – Masklinn
    Nov 10, 2020 at 14:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.