-
-
Notifications
You must be signed in to change notification settings - Fork 320
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
Align PNC Apply Pattern with Expr #7490
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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>( |
There was a problem hiding this comment.
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); | |||
|
There was a problem hiding this comment.
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() { |
There was a problem hiding this comment.
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>), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
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.