@@ -219,21 +219,12 @@ rustc_index::newtype_index! {
219219/// index and a def index.
220220///
221221/// You can create a `DefId` from a `LocalDefId` using `local_def_id.to_def_id()`.
222- #[ derive( Clone , PartialEq , Eq , Copy ) ]
223- // On below-64 bit systems we can simply use the derived `Hash` impl
224- #[ cfg_attr( not( target_pointer_width = "64" ) , derive( Hash ) ) ]
222+ #[ derive( Clone , PartialEq , Eq , Copy , Hash ) ]
225223#[ repr( C ) ]
226224#[ rustc_pass_by_value]
227- // We guarantee field order. Note that the order is essential here, see below why.
228225pub struct DefId {
229- // 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
231- // into a direct call to `u64::hash(_)`.
232- #[ cfg( not( all( target_pointer_width = "64" , target_endian = "big" ) ) ) ]
233226 pub index : DefIndex ,
234227 pub krate : CrateNum ,
235- #[ cfg( all( target_pointer_width = "64" , target_endian = "big" ) ) ]
236- pub index : DefIndex ,
237228}
238229
239230// To ensure correctness of incremental compilation,
@@ -242,24 +233,6 @@ pub struct DefId {
242233impl !Ord for DefId { }
243234impl !PartialOrd for DefId { }
244235
245- // On 64-bit systems, we can hash the whole `DefId` as one `u64` instead of two `u32`s. This
246- // improves performance without impairing `FxHash` quality. So the below code gets compiled to a
247- // noop on little endian systems because the memory layout of `DefId` is as follows:
248- //
249- // ```
250- // +-1--------------31-+-32-------------63-+
251- // ! index ! krate !
252- // +-------------------+-------------------+
253- // ```
254- //
255- // On 64-bit big-endian systems, this compiles to a 64-bit rotation by 32 bits, or a 64-bit load.
256- #[ cfg( target_pointer_width = "64" ) ]
257- impl Hash for DefId {
258- fn hash < H : Hasher > ( & self , h : & mut H ) {
259- ( ( ( self . krate . as_u32 ( ) as u64 ) << 32 ) | ( self . index . as_u32 ( ) as u64 ) ) . hash ( h)
260- }
261- }
262-
263236impl DefId {
264237 /// Makes a local `DefId` from the given `DefIndex`.
265238 #[ inline]
0 commit comments