Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Pattern Migration 2024: reword to make sense on all Editions #136475
Pattern Migration 2024: reword to make sense on all Editions #136475
Changes from 2 commits
724b885
bdc6c4d
bbe40ac
9202001
4331f55
203d310
a064e78
767f820
a5cc4cb
060cc37
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
The default binding mode is really a property of the whole subpattern. Could you change this label to something like "this reference/binding mode" and add another label that points to the whole subpattern with "default binding mode is X"?
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.
Done! I'm a little wary about labeling the whole subpattern for reference patterns, though. It looks good for bindings, but with reference patterns it kind of looks like it's highlighting the inside of the pattern, where the default binding mode will be different and can potentially overlap other labels. I've added a test to illustrate:
I wonder if it'd look good to instead put the "default binding mode is X" label where the default binding mode is introduced.. that'd give more information to users too, but I'm not sure how readable it'd be. I'll experiment and fix another small formatting issue before marking this as ready for review.
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.
Hm that's not very legible indeed. I think there might be an option so that labels are kept more separate than this for legibility? I'm not sure though.
Good point, that could be good yes! I'm thinking this might work well if we could separate it so we can explain a bit more, e.g.
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.
I think I know how to do that! I like the
help
too. Would each labeled reference pattern / binding modifier also get its own note? Would they be grouped if their default binding modes are introduced at the same span? I'll experiment and see how it looks. Maybe the underline could disappear where the default binding mode changes, too.. that might just be more confusing though.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.
We could show each transition of the default binding mode leading all the way down to the binding. I'm not really sure how serious I am about that suggestion. On the one hand, it seems maybe a bit much, but on the other, it probably would improve understanding.
We have other errors, like our cycle errors, that carefully show each step. It's maybe not inconceivable.
(Though to really make sense of it, we'd probably have to elaborate the type as well. Anyway, keeping it simple is fine too. Seeing the default binding mode annotated at all made me smile.)
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.
How does this look? I wanted to get something that worked for both mutable and shared references, in case we're labeling both
ref
andref mut
default binding modes, so we can have just one help after all the notes (any more feels excessive):Looking at it as a whole though, the note's message feels a bit redundant with the labels on the main diagnostic, so I tried moving the help into the note again:
But then
ref
is missing.. maybe it could go at the end of the note or the label? e.g. "matching on type&_
with a non-&
pattern changes the default binding mode toref
". It's a bit long, but all the information's there, at least.Likely, yeah. ^^;
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.
I like "matching on a reference type with a non-reference pattern changes the default binding mode", it's very clear. do we actually need to say which binding mode there is? saying "non-default binding mode" could be enough? except if the user doesn't know what a binding mode is I guess ><
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.
Ah, good point. I'm not too worried about terminology; the diagnostic links to the edition guide, which explains it. I think hoping people follow the link if they don't know the terms is the best we can do.
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.
as of a5cc4cb, it now looks like this:
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.
Looks great.