mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 08:34:33 +00:00
Fix debug_assert bindgen for tag unions
This commit is contained in:
parent
09acc5458b
commit
9a30aaff78
1 changed files with 4 additions and 4 deletions
|
@ -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
|
||||
}}"#,
|
||||
)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue