-
Notifications
You must be signed in to change notification settings - Fork 13.4k
typeck: refactor patterns => pat.rs
+ make the def_bm
algo more declarative
#63862
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…rithm more declaratively.
This clarifies the fact that type checking patterns unconditionally starts with `BindByValue` as the default binding mode making the notion of a default binding mode internal to type checking patterns.
It's just shorter and we usually don't use the `_walk` suffix.
oli-obk
reviewed
Aug 24, 2019
@oli-obk I've done a similar dedup in |
oli-obk
approved these changes
Aug 25, 2019
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.
@bors r+ p=1
Let's try this again... ;) @bors r=oli-obk p=1 |
📌 Commit 5a7e1cb has been approved by |
bors
added a commit
that referenced
this pull request
Aug 25, 2019
typeck: refactor patterns => `pat.rs` + make the `def_bm` algo more declarative Spurred by the relative difficulty I had in working up an explanation of how default match bindings work in #63118 (comment), this PR refactors the type checking of patterns into `pat.rs`. The PR is probably best read commit-by-commit and includes various changes beyond the following, which are the most important highlights: - The algorithm for determining `def_bm` is encoded in a more declarative fashion now with important sub-steps divided into functions that make sense as logical units (and as described in the reference). This is done starting with *"extract `is_no_ref_pat`."* to *"extract `calc_default_binding_mode`"*. - Dedicated functions like `check_pat_{lit,range,ident,tuple,box,ref,slice}` are then introduced for the various kinds of patterns to make things overall more readable. - `fn check_pat_top(...)` becomes the sole entry point to type checking patterns. This will take care of initializing the default binding mode (hence: `def_bm`) to `BindByValue` and is called by all contexts that have a pattern that needs to be type checked (functions, `match`, `if let`, `let`, ...). The overall result is that the notion of `def_bm` is internal to checking patterns. - Various diagnostics are extracted to dedicated functions to disturb the flow of type checking logic less. r? @oli-obk
☀️ Test successful - checks-azure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
merged-by-bors
This PR was explicitly merged by bors.
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
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.
Spurred by the relative difficulty I had in working up an explanation of how default match bindings work in #63118 (comment), this PR refactors the type checking of patterns into
pat.rs
.The PR is probably best read commit-by-commit and includes various changes beyond the following, which are the most important highlights:
The algorithm for determining
def_bm
is encoded in a more declarative fashion now with important sub-steps divided into functions that make sense as logical units (and as described in the reference). This is done starting with "extractis_no_ref_pat
." to "extractcalc_default_binding_mode
".Dedicated functions like
check_pat_{lit,range,ident,tuple,box,ref,slice}
are then introduced for the various kinds of patterns to make things overall more readable.fn check_pat_top(...)
becomes the sole entry point to type checking patterns.This will take care of initializing the default binding mode (hence:
def_bm
) toBindByValue
and is called by all contexts that have a pattern that needs to be type checked (functions,match
,if let
,let
, ...). The overall result is that the notion ofdef_bm
is internal to checking patterns.Various diagnostics are extracted to dedicated functions to disturb the flow of type checking logic less.
r? @oli-obk