Skip to content

Commit c146344

Browse files
Decode AttrId via mk_attr_id
1 parent d4227f6 commit c146344

File tree

2 files changed

+14
-11
lines changed

2 files changed

+14
-11
lines changed

src/librustc_metadata/decoder.rs

+1-8
Original file line numberDiff line numberDiff line change
@@ -980,14 +980,7 @@ impl<'a, 'tcx> CrateMetadata {
980980
}
981981

982982
fn get_attributes(&self, item: &Entry<'tcx>, sess: &Session) -> Vec<ast::Attribute> {
983-
item.attributes
984-
.decode((self, sess))
985-
.map(|mut attr| {
986-
// Need new unique IDs: old thread-local IDs won't map to new threads.
987-
attr.id = attr::mk_attr_id();
988-
attr
989-
})
990-
.collect()
983+
item.attributes.decode((self, sess)).collect()
991984
}
992985

993986
// Translate a DefId from the current compilation environment to a DefId

src/libsyntax/ast.rs

+13-3
Original file line numberDiff line numberDiff line change
@@ -2104,9 +2104,7 @@ pub enum AttrStyle {
21042104
Inner,
21052105
}
21062106

2107-
#[derive(
2108-
Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, PartialOrd, Ord, Copy,
2109-
)]
2107+
#[derive(Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, Copy)]
21102108
pub struct AttrId(pub usize);
21112109

21122110
impl Idx for AttrId {
@@ -2118,6 +2116,18 @@ impl Idx for AttrId {
21182116
}
21192117
}
21202118

2119+
impl rustc_serialize::Encodable for AttrId {
2120+
fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
2121+
s.emit_unit()
2122+
}
2123+
}
2124+
2125+
impl rustc_serialize::Decodable for AttrId {
2126+
fn decode<D: Decoder>(d: &mut D) -> Result<AttrId, D::Error> {
2127+
d.read_nil().map(|_| crate::attr::mk_attr_id())
2128+
}
2129+
}
2130+
21212131
/// Metadata associated with an item.
21222132
/// Doc-comments are promoted to attributes that have `is_sugared_doc = true`.
21232133
#[derive(Clone, RustcEncodable, RustcDecodable, Debug)]

0 commit comments

Comments
 (0)