Files
rust/compiler/rustc_span
bors 65efa19420 Auto merge of #163321 - aerooneqq:local-def-index, r=oli-obk,petrochenkov
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
2026-10-08 10:25:14 +00:00
..