From 9a30aaff789615b126799666bb3ec41f76df7eca Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 19 May 2022 22:04:16 -0400 Subject: [PATCH] Fix debug_assert bindgen for tag unions --- bindgen/src/bindgen_rs.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bindgen/src/bindgen_rs.rs b/bindgen/src/bindgen_rs.rs index 661c9e0c87..03c2f87b5a 100644 --- a/bindgen/src/bindgen_rs.rs +++ b/bindgen/src/bindgen_rs.rs @@ -280,7 +280,7 @@ impl {name} {{ /// (Always examine .tag() first to make sure this is the correct variant!) /// Panics in debug builds if the .tag() doesn't return {tag_name}. pub unsafe fn into_{tag_name}({self_for_into}) -> {payload_type_name} {{ - debug_assert_eq!(self.tag(), Self::{tag_name}); + debug_assert_eq!(self.tag(), {discriminant_name}::{tag_name}); {get_payload} }}"#, )?; @@ -293,7 +293,7 @@ impl {name} {{ /// (Always examine .tag() first to make sure this is the correct variant!) /// Panics in debug builds if the .tag() doesn't return {tag_name}. pub unsafe fn as_{tag_name}(&self) -> {ref_if_needed}{payload_type_name} {{ - debug_assert_eq!(self.tag(), Self::{tag_name}); + debug_assert_eq!(self.tag(), {discriminant_name}::{tag_name}); {ref_if_needed}self.variant.{tag_name} }}"#, )?; @@ -874,7 +874,7 @@ impl {name} {{ /// (Always examine .tag() first to make sure this is the correct variant!) /// Panics in debug builds if the .tag() doesn't return {non_null_tag}. pub unsafe fn into_{non_null_tag}(self) -> {payload_type_name} {{ - debug_assert_eq!(self.tag(), Self::{non_null_tag}); + debug_assert_eq!(self.tag(), {discriminant_name}::{non_null_tag}); let payload = {assign_payload}; let align = core::mem::align_of::<{payload_type_name}>() as u32; @@ -893,7 +893,7 @@ impl {name} {{ /// (Always examine .tag() first to make sure this is the correct variant!) /// Panics in debug builds if the .tag() doesn't return {non_null_tag}. pub unsafe fn as_{non_null_tag}(&self) -> {ref_if_needed}{payload_type_name} {{ - debug_assert_eq!(self.tag(), Self::{non_null_tag}); + debug_assert_eq!(self.tag(), {discriminant_name}::{non_null_tag}); {ref_if_needed}*self.pointer }}"#, )?;