mirror of
https://github.com/allankoechke/rust.git
synced 2026-12-02 17:44:28 +00:00
Use `LocalDefId` as an index in metadata encoding The goal of this PR to eliminate encoding of a raw `DefIndex`, instead we should encode something (`LocalDefId`) that certainly indicates that index belongs to the local crate. The implementation of `DefIndex` encoding should always panic to prevent accidental remappings of non-local `DefIndex`es in rust-lang/rust#162809. So the plan is as follows: - Use `LocalDefId` as a writing index in tables for metadata encoding, use `LocalDefId` instead of `DefIndex` everywhere, specialize encode/decode methods to correctly process it, - Replace implementation of `encode_def_index` in `EncodeContext` with panic, so we never remap and encode def index, - Make tables' keys two-sided: we can read and write using different index types, in this case we will write using `LocalDefId` and read using `DefIndex` (done in rust-lang/rust#163447). Blocked by rust-lang/rust#162900. r? @petrochenkov