mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Revert "Add an index to write_impl_tags"
This reverts commit 31f1aef8e0
.
This commit is contained in:
parent
7726c1745b
commit
7a5db3d457
1 changed files with 10 additions and 14 deletions
|
@ -890,11 +890,7 @@ pub struct {name} {{
|
|||
tags.iter(),
|
||||
&discriminant_name,
|
||||
&mut drop_payload,
|
||||
|_index, tag_name, opt_payload_id| {
|
||||
// Note: we don't need to check Some(tag_index) != null_tag_index
|
||||
// because the null tag is guaranteed to have no payload,
|
||||
// and so it will already be handled correctly by the logic of
|
||||
// "don't drop it if it has no payload."
|
||||
|tag_name, opt_payload_id| {
|
||||
match opt_payload_id {
|
||||
Some(payload_id) if cannot_derive_copy(types.get_type(payload_id), types) => {
|
||||
format!("unsafe {{ core::mem::ManuallyDrop::drop(&mut {actual_self_mut}.{tag_name}) }},",)
|
||||
|
@ -971,7 +967,7 @@ pub struct {name} {{
|
|||
tags.iter(),
|
||||
&discriminant_name,
|
||||
&mut buf,
|
||||
|_index, tag_name, opt_payload_id| {
|
||||
|tag_name, opt_payload_id| {
|
||||
if opt_payload_id.is_some() {
|
||||
format!("{actual_self}.{tag_name} == {actual_other}.{tag_name},")
|
||||
} else {
|
||||
|
@ -1010,7 +1006,7 @@ pub struct {name} {{
|
|||
tags.iter(),
|
||||
&discriminant_name,
|
||||
&mut buf,
|
||||
|_index, tag_name, opt_payload_id| {
|
||||
|tag_name, opt_payload_id| {
|
||||
if opt_payload_id.is_some() {
|
||||
format!("{actual_self}.{tag_name}.partial_cmp(&{actual_other}.{tag_name}),",)
|
||||
} else {
|
||||
|
@ -1049,7 +1045,7 @@ pub struct {name} {{
|
|||
tags.iter(),
|
||||
&discriminant_name,
|
||||
&mut buf,
|
||||
|_index, tag_name, opt_payload_id| {
|
||||
|tag_name, opt_payload_id| {
|
||||
if opt_payload_id.is_some() {
|
||||
format!("{actual_self}.{tag_name}.cmp(&{actual_other}.{tag_name}),",)
|
||||
} else {
|
||||
|
@ -1092,7 +1088,7 @@ pub struct {name} {{
|
|||
tags.iter(),
|
||||
&discriminant_name,
|
||||
&mut buf,
|
||||
|_index, tag_name, opt_payload_id| {
|
||||
|tag_name, opt_payload_id| {
|
||||
if opt_payload_id.is_some() {
|
||||
match recursiveness {
|
||||
Recursiveness::Recursive => {
|
||||
|
@ -1151,7 +1147,7 @@ pub struct {name} {{
|
|||
tags.iter(),
|
||||
&discriminant_name,
|
||||
&mut buf,
|
||||
|_index, tag_name, opt_payload_id| {
|
||||
|tag_name, opt_payload_id| {
|
||||
let hash_tag = format!("{discriminant_name}::{tag_name}.hash(state)");
|
||||
|
||||
if opt_payload_id.is_some() {
|
||||
|
@ -1189,7 +1185,7 @@ pub struct {name} {{
|
|||
tags.iter(),
|
||||
&discriminant_name,
|
||||
&mut buf,
|
||||
|_index, tag_name, opt_payload_id| match opt_payload_id {
|
||||
|tag_name, opt_payload_id| match opt_payload_id {
|
||||
Some(payload_id) => {
|
||||
// If it's a ManuallyDrop, we need a `*` prefix to dereference it
|
||||
// (because otherwise we're using ManuallyDrop's Debug instance
|
||||
|
@ -1255,7 +1251,7 @@ pub struct {name} {{
|
|||
fn write_impl_tags<
|
||||
'a,
|
||||
I: IntoIterator<Item = &'a (String, Option<TypeId>)>,
|
||||
F: Fn(usize, &str, Option<TypeId>) -> String,
|
||||
F: Fn(&str, Option<TypeId>) -> String,
|
||||
>(
|
||||
indentations: usize,
|
||||
tags: I,
|
||||
|
@ -1267,8 +1263,8 @@ fn write_impl_tags<
|
|||
|
||||
buf.push_str("match self.discriminant() {\n");
|
||||
|
||||
for (index, (tag_name, opt_payload_id)) in tags.into_iter().enumerate() {
|
||||
let branch_str = to_branch_str(index, tag_name, *opt_payload_id);
|
||||
for (tag_name, opt_payload_id) in tags {
|
||||
let branch_str = to_branch_str(tag_name, *opt_payload_id);
|
||||
|
||||
write_indents(indentations + 1, buf);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue