diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-07-30 13:40:43 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2019-07-31 08:55:37 -0400 |
| commit | c146344e32018a8b28c456352a873f9feafd6ff3 (patch) | |
| tree | 38014accec36d050b74c4ea56271e7e1e133db64 /src/libsyntax | |
| parent | d4227f6e0d4269fd69ade5702cdbb59a73d6319a (diff) | |
Decode AttrId via mk_attr_id
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ast.rs | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index b633705a65f..2938487393d 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -2104,9 +2104,7 @@ pub enum AttrStyle { Inner, } -#[derive( - Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, PartialOrd, Ord, Copy, -)] +#[derive(Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord, Copy)] pub struct AttrId(pub usize); impl Idx for AttrId { @@ -2118,6 +2116,18 @@ impl Idx for AttrId { } } +impl rustc_serialize::Encodable for AttrId { + fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> { + s.emit_unit() + } +} + +impl rustc_serialize::Decodable for AttrId { + fn decode<D: Decoder>(d: &mut D) -> Result<AttrId, D::Error> { + d.read_nil().map(|_| crate::attr::mk_attr_id()) + } +} + /// Metadata associated with an item. /// Doc-comments are promoted to attributes that have `is_sugared_doc = true`. #[derive(Clone, RustcEncodable, RustcDecodable, Debug)] |
