Skip to content

Commit 8cbf4b0

Browse files
committed
swap defid fields
1 parent b1e5429 commit 8cbf4b0

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

compiler/rustc_span/src/def_id.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -227,13 +227,13 @@ rustc_index::newtype_index! {
227227
// We guarantee field order. Note that the order is essential here, see below why.
228228
pub struct DefId {
229229
// cfg-ing the order of fields so that the `DefIndex` which is high entropy always ends up in
230-
// the lower bits no matter the endianness. This allows the compiler to turn that `Hash` impl
230+
// the higher bits no matter the endianness. This allows the compiler to turn that `Hash` impl
231231
// into a direct call to `u64::hash(_)`.
232232
#[cfg(not(all(target_pointer_width = "64", target_endian = "big")))]
233-
pub index: DefIndex,
234-
pub krate: CrateNum,
233+
pub krate: DefIndex,
234+
pub index: CrateNum,
235235
#[cfg(all(target_pointer_width = "64", target_endian = "big"))]
236-
pub index: DefIndex,
236+
pub krate: DefIndex,
237237
}
238238

239239
// To ensure correctness of incremental compilation,
@@ -248,15 +248,15 @@ impl !PartialOrd for DefId {}
248248
//
249249
// ```
250250
// +-1--------------31-+-32-------------63-+
251-
// ! index ! krate !
251+
// ! krate ! index !
252252
// +-------------------+-------------------+
253253
// ```
254254
//
255255
// On 64-bit big-endian systems, this compiles to a 64-bit rotation by 32 bits, or a 64-bit load.
256256
#[cfg(target_pointer_width = "64")]
257257
impl Hash for DefId {
258258
fn hash<H: Hasher>(&self, h: &mut H) {
259-
(((self.krate.as_u32() as u64) << 32) | (self.index.as_u32() as u64)).hash(h)
259+
(((self.index.as_u32() as u64) << 32) | (self.krate.as_u32() as u64)).hash(h)
260260
}
261261
}
262262

0 commit comments

Comments
 (0)