about summary refs log tree commit diff
path: root/src/libsyntax_pos/symbol.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/libsyntax_pos/symbol.rs')
-rw-r--r--src/libsyntax_pos/symbol.rs34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/libsyntax_pos/symbol.rs b/src/libsyntax_pos/symbol.rs
index 0b8f16bbc3b..f44716e013e 100644
--- a/src/libsyntax_pos/symbol.rs
+++ b/src/libsyntax_pos/symbol.rs
@@ -225,9 +225,10 @@ symbols! {
         custom_inner_attributes,
         custom_test_frameworks,
         c_variadic,
-        Debug,
+        debug_trait,
         declare_lint_pass,
         decl_macro,
+        Debug,
         Decodable,
         Default,
         default_lib_allocator,
@@ -238,6 +239,7 @@ symbols! {
         deref,
         deref_mut,
         derive,
+        diagnostic,
         direct,
         doc,
         doc_alias,
@@ -569,6 +571,7 @@ symbols! {
         rustc_conversion_suggestion,
         rustc_def_path,
         rustc_deprecated,
+        rustc_diagnostic_item,
         rustc_diagnostic_macros,
         rustc_dirty,
         rustc_dummy,
@@ -849,9 +852,29 @@ impl fmt::Display for Ident {
     }
 }
 
-impl UseSpecializedEncodable for Ident {}
+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 {}
+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)?,
+            })
+        })
+    }
+}
 
 /// A symbol is an interned or gensymed string. A gensym is a symbol that is
 /// never equal to any other symbol.
@@ -1063,6 +1086,11 @@ impl Symbol {
         self == kw::DollarCrate
     }
 
+    /// Returns `true` if the symbol is `true` or `false`.
+    pub fn is_bool_lit(self) -> bool {
+        self == kw::True || self == kw::False
+    }
+
     /// This symbol can be a raw identifier.
     pub fn can_be_raw(self) -> bool {
         self != kw::Invalid && self != kw::Underscore && !self.is_path_segment_keyword()