Why Interned is used in rust/src/bootstrap?


#1

I’m wondering why the Interned type is used for string literals under rust/src/bootstrap. Wouldn’t the compiler (stage0?) intern the string literals?


#2

These two interners are completely independent (bootstrap is a small program isolated from the rest of compiler).

The bootstrap interner was added in https://github.com/rust-lang/rust/pull/43059 to avoid unergonomic Rc<String> (https://github.com/rust-lang/rust/pull/43059/files#r127785928).
Regarding why bootstrap uses Rc<String> instead of String in the first place, it’s certainly intended to be an optimization, but I’m not sure if it has any measurable impact or not, @Mark_Simulacrum may know better.


#3

It sounds like they just want the ergonomic benefit of avoiding clone(). I don’t think anyone is worried about bootstrap performance, because it’s not even compiled in release mode! :slight_smile: