{
"$type": "site.standard.document",
"bskyPostRef": {
"cid": "bafyreie7mcs3nq6nf6bwvjsiw74afgbp65gn7ulomjwrit4x5nsstux3na",
"uri": "at://did:plc:ivbknywyskln22er3nkssdhl/app.bsky.feed.post/3mhde3irhgee2"
},
"path": "/t/stable-type-identifiers-a-missing-piece-for-crabi-and-export/24093#post_7",
"publishedAt": "2026-03-18T10:13:22.000Z",
"site": "https://internals.rust-lang.org",
"tags": [
"crates.io"
],
"textContent": "Rustc does not know about crate versions. The unique identity of a crate (internally called `StableCrateId`) is crate name + all `-Cmetadata` arguments + `crate_type==bin` + rustc version. Cargo hashes a whole bunch of things into `-Cmetadata` to ensure crates that cargo believes to be unique don't overlap in ABI. This includes not just the crate version, but also all dependencies as well as the origin of the crate (you can have two crates with the same version from different locations. eg one from crates.io and one from a local path). And the rustc version has to be hashed in to ensure you can link two cdylibs or two staticlibs containing the same dependency, yet compiled with different rustc versions together without causing symbol conflicts.\n\nAnd then the path from crate root to type is not unique within a crate. The `DefPath` also contains disambiguators for each path component. This is necessary to handle things like anonymous types or\n\n\n fn foo() {\n {\n struct Bar;\n }\n {\n struct Bar;\n }\n }\n\n\nwhere you did have `my_crate[1234]::foo[0]::Bar[0]` and `my_crate[1234]::foo[0]::Bar[1]` as different types.",
"title": "Stable type identifiers: a missing piece for crABI and export"
}