mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Decode AttrId via mk_attr_id
This commit is contained in:
parent
d4227f6e0d
commit
c146344e32
@ -980,14 +980,7 @@ impl<'a, 'tcx> CrateMetadata {
|
||||
}
|
||||
|
||||
fn get_attributes(&self, item: &Entry<'tcx>, sess: &Session) -> Vec<ast::Attribute> {
|
||||
item.attributes
|
||||
.decode((self, sess))
|
||||
.map(|mut attr| {
|
||||
// Need new unique IDs: old thread-local IDs won't map to new threads.
|
||||
attr.id = attr::mk_attr_id();
|
||||
attr
|
||||
})
|
||||
.collect()
|
||||
item.attributes.decode((self, sess)).collect()
|
||||
}
|
||||
|
||||
// Translate a DefId from the current compilation environment to a DefId
|
||||
|
@ -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)]
|
||||
|
Loading…
Reference in New Issue
Block a user