about summary refs log tree commit diff
path: root/src/libstd/sys/unix/stack_overflow.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-08-25 04:26:26 +0000
committerbors <bors@rust-lang.org>2019-08-25 04:26:26 +0000
commit783469ca09005d135c3204a55069707d1cd705a9 (patch)
tree05bccc7ce12e8043c03bb0970bde11f11e3b943d /src/libstd/sys/unix/stack_overflow.rs
parent9267119019b48b0c3c6fb44cd3cbab64b2a1a6b5 (diff)
parent5a7e1cb46a05fd176e5488beb58f72a05f4b1a0d (diff)
downloadrust-783469ca09005d135c3204a55069707d1cd705a9.tar.gz
rust-783469ca09005d135c3204a55069707d1cd705a9.zip
Auto merge of #63862 - Centril:match-cleanup, r=oli-obk
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 https://github.com/rust-lang/rust/pull/63118#issuecomment-524161584, 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
Diffstat (limited to 'src/libstd/sys/unix/stack_overflow.rs')
0 files changed, 0 insertions, 0 deletions