Skip to content

Align PNC Apply Pattern with Expr #7490

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed

Conversation

gamebox
Copy link
Collaborator

@gamebox gamebox commented Jan 9, 2025

This doesn't actually solve #7486 but it aligns things so that it can be fixed. That issue is a little contentious and based on looking at the output and not liking what it looks like without considering the original source (that source is just completely artificial and not helpful).

I think that if #7470 gets merged with this, the fuzzer will be much more stable.

Copy link
Collaborator

@smores56 smores56 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you remove the println!, it looks good to me

@@ -108,6 +110,37 @@ where
}
}

pub trait FieldValue {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not immediately obvious to me what this does, maybe add a doc comment?

Mapper(&'a Loc<Field>),
}

pub(crate) fn fmt_record_like<'a, 'b: 'a, Field, ToSpacesAround>(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eventually, it might be nice to use this for other types of collections like lists. I don't think we need to make any changes right now, but food for thought for the future.

@@ -1702,7 +1678,13 @@ fn fmt_when<'a>(

buf.spaces(1);

fmt_pattern(buf, &pattern.value, indent + INDENT, Parens::NotNeeded);
let lifted = pattern_lift_spaces(buf.text.bump(), &pattern.value);

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this missing a call to format lifted.after?

@@ -1715,7 +1697,11 @@ fn fmt_when<'a>(

buf.indent(indent + INDENT);
let line_indent = buf.cur_line_indent();
buf.push_str(" ->");
if buf.ends_with_space() || buf.ends_with_newline() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pro tip: you should be able to just use buf.ensure_ends_with_whitespace(), followed by buf.push_str("->")

/// Can only occur inside of a RecordDestructure
OptionalField(&'a str, &'a Loc<Expr<'a>>),
RecordDestructure(Collection<'a, Loc<AssignedField<'a, Pattern<'a>>>>),
ExprWrapped(Expr<'a>),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for?

Copy link

Thank you for your contribution! Sometimes PRs end up staying open for a long time without activity, which can make the list of open PRs get long and time-consuming to review. To keep things manageable for reviewers, this bot automatically closes PRs that haven’t had activity in 60 days. This PR hasn’t had activity in 30 days, so it will be automatically closed if there is no more activity in the next 30 days. Keep in mind that PRs marked Closed are not deleted, so no matter what, the PR will still be right here in the repo. You can always access it and reopen it anytime you like!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants