]> git.proxmox.com Git - rustc.git/blobdiff - compiler/rustc_span/src/def_id.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / compiler / rustc_span / src / def_id.rs
index 147c1f9e043395d99a6d611f785f3ed76ea64f1b..6d1b36796d869fec88463521d022bc76dea66489 100644 (file)
@@ -27,8 +27,8 @@ impl CrateNum {
     }
 
     #[inline]
-    pub fn as_def_id(&self) -> DefId {
-        DefId { krate: *self, index: CRATE_DEF_INDEX }
+    pub fn as_def_id(self) -> DefId {
+        DefId { krate: self, index: CRATE_DEF_INDEX }
     }
 }
 
@@ -222,6 +222,7 @@ impl<D: Decoder> Decodable<D> for DefIndex {
 // On below-64 bit systems we can simply use the derived `Hash` impl
 #[cfg_attr(not(target_pointer_width = "64"), derive(Hash))]
 #[repr(C)]
+#[rustc_pass_by_value]
 // We guarantee field order. Note that the order is essential here, see below why.
 pub struct DefId {
     // cfg-ing the order of fields so that the `DefIndex` which is high entropy always ends up in
@@ -299,10 +300,7 @@ impl<E: Encoder> Encodable<E> for DefId {
 
 impl<D: Decoder> Decodable<D> for DefId {
     default fn decode(d: &mut D) -> DefId {
-        d.read_struct(|d| DefId {
-            krate: d.read_struct_field("krate", Decodable::decode),
-            index: d.read_struct_field("index", Decodable::decode),
-        })
+        DefId { krate: Decodable::decode(d), index: Decodable::decode(d) }
     }
 }