]> git.lizzy.rs Git - rust.git/commitdiff
Merge #982
authorbors[bot] <bors[bot]@users.noreply.github.com>
Sun, 17 Mar 2019 21:41:37 +0000 (21:41 +0000)
committerbors[bot] <bors[bot]@users.noreply.github.com>
Sun, 17 Mar 2019 21:41:37 +0000 (21:41 +0000)
982: Implement BindingMode for pattern matching. r=flodiebold a=mjkillough

Implement `BindingMode` for pattern matching, so that types can be
correctly inferred using match ergonomics. The binding mode defaults to
`Move` (referred to as 'BindingMode::BindByValue` in rustc), and is
updated by automatic dereferencing of the value being matched.

Fixes #888.

 - [Binding modes in The Reference](https://doc.rust-lang.org/reference/patterns.html#binding-modes)
 - [`rustc` implementation](https://github.com/rust-lang/rust/blob/e17c48e2f21eefd59748e364234efc7037a3ec96/src/librustc_typeck/check/_match.rs#L77) (and [definition of `BindingMode`](https://github.com/rust-lang/rust/blob/e957ed9d10ec589bdd523b88b4b44c41b1ecf763/src/librustc/ty/binding.rs))
 - [Match Ergonomics RFC](https://github.com/rust-lang/rfcs/blob/master/text/2005-match-ergonomics.md#binding-mode-rules)

Co-authored-by: Michael Killough <michaeljkillough@gmail.com>
1  2 
crates/ra_hir/src/marks.rs
crates/ra_hir/src/ty/infer.rs
crates/ra_hir/src/ty/tests.rs

Simple merge
Simple merge
Simple merge