]> git.lizzy.rs Git - rust.git/commitdiff
Delete read_enum_variant names
authorMark Rousskov <mark.simulacrum@gmail.com>
Wed, 9 Feb 2022 22:12:20 +0000 (17:12 -0500)
committerMark Rousskov <mark.simulacrum@gmail.com>
Sun, 20 Feb 2022 23:58:22 +0000 (18:58 -0500)
compiler/rustc_macros/src/serialize.rs
compiler/rustc_serialize/src/serialize.rs

index 91a076fa6f624f9938e3b7ef299fe260a5a21987..8d898291e58874a4bfa9e01cda6025d0b0055e39 100644 (file)
@@ -60,13 +60,6 @@ fn decodable_body(
                     quote! { #idx => { #construct } }
                 })
                 .collect();
-            let names: TokenStream = variants
-                .iter()
-                .map(|vi| {
-                    let variant_name = vi.ast().ident.to_string();
-                    quote!(#variant_name,)
-                })
-                .collect();
             let message = format!(
                 "invalid enum variant tag while decoding `{}`, expected 0..{}",
                 ty_name,
@@ -75,7 +68,6 @@ fn decodable_body(
             quote! {
                 ::rustc_serialize::Decoder::read_enum_variant(
                     __decoder,
-                    &[#names],
                     |__decoder, __variant_idx| {
                         match __variant_idx {
                             #match_inner
index 6e0199260f830955a7bdfdbc9c5dadb3f5ce3c4c..b1a75309ccdd299a7acfaff4b4d9b6bc30788f6a 100644 (file)
@@ -202,7 +202,7 @@ pub trait Decoder {
     fn read_raw_bytes_into(&mut self, s: &mut [u8]);
 
     #[inline]
-    fn read_enum_variant<T, F>(&mut self, _names: &[&str], mut f: F) -> T
+    fn read_enum_variant<T, F>(&mut self, mut f: F) -> T
     where
         F: FnMut(&mut Self, usize) -> T,
     {
@@ -255,7 +255,7 @@ fn read_option<T, F>(&mut self, mut f: F) -> T
     where
         F: FnMut(&mut Self, bool) -> T,
     {
-        self.read_enum_variant(&["None", "Some"], move |this, idx| match idx {
+        self.read_enum_variant(move |this, idx| match idx {
             0 => f(this, false),
             1 => f(this, true),
             _ => panic!("read_option: expected 0 for None or 1 for Some"),
@@ -571,7 +571,7 @@ fn encode(&self, s: &mut S) -> Result<(), S::Error> {
 
 impl<D: Decoder, T1: Decodable<D>, T2: Decodable<D>> Decodable<D> for Result<T1, T2> {
     fn decode(d: &mut D) -> Result<T1, T2> {
-        d.read_enum_variant(&["Ok", "Err"], |d, disr| match disr {
+        d.read_enum_variant(|d, disr| match disr {
             0 => Ok(d.read_enum_variant_arg(|d| T1::decode(d))),
             1 => Err(d.read_enum_variant_arg(|d| T2::decode(d))),
             _ => panic!("Encountered invalid discriminant while decoding `Result`."),