use rustc_arena::DroplessArena;
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, ToStableHashKey};
-use rustc_macros::{symbols, HashStable_Generic};
+use rustc_macros::HashStable_Generic;
use rustc_serialize::{Decodable, Decoder, Encodable, Encoder};
-use rustc_serialize::{UseSpecializedDecodable, UseSpecializedEncodable};
use std::cmp::{Ord, PartialEq, PartialOrd};
use std::fmt;
}
}
-#[derive(Copy, Clone, Eq, HashStable_Generic)]
+#[derive(Copy, Clone, Eq, HashStable_Generic, Encodable, Decodable)]
pub struct Ident {
pub name: Symbol,
pub span: Span,
}
}
-impl UseSpecializedEncodable for Ident {
- fn default_encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
- s.emit_struct("Ident", 2, |s| {
- s.emit_struct_field("name", 0, |s| self.name.encode(s))?;
- s.emit_struct_field("span", 1, |s| self.span.encode(s))
- })
- }
-}
-
-impl UseSpecializedDecodable for Ident {
- fn default_decode<D: Decoder>(d: &mut D) -> Result<Self, D::Error> {
- d.read_struct("Ident", 2, |d| {
- Ok(Ident {
- name: d.read_struct_field("name", 0, Decodable::decode)?,
- span: d.read_struct_field("span", 1, Decodable::decode)?,
- })
- })
- }
-}
-
/// This is the most general way to print identifiers.
/// AST pretty-printer is used as a fallback for turning AST structures into token streams for
/// proc macros. Additionally, proc macros may stringify their input and expect it survive the
}
}
-impl Encodable for Symbol {
- fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
+impl<S: Encoder> Encodable<S> for Symbol {
+ fn encode(&self, s: &mut S) -> Result<(), S::Error> {
self.with(|string| s.emit_str(string))
}
}
-impl Decodable for Symbol {
+impl<D: Decoder> Decodable<D> for Symbol {
#[inline]
- fn decode<D: Decoder>(d: &mut D) -> Result<Symbol, D::Error> {
+ fn decode(d: &mut D) -> Result<Symbol, D::Error> {
Ok(Symbol::intern(&d.read_str()?))
}
}
use super::Symbol;
use std::convert::TryInto;
- symbols!();
+ define_symbols!();
// Used from a macro in `librustc_feature/accepted.rs`
pub use super::kw::MacroRules as macro_rules;