Rollup merge of #55819 - pnkfelix:issue-55810-must-typeck-pats-eagerly, r=oli-obk

Typecheck patterns of all match arms first, so we get types for bindings

Fix eventually (after backport to beta) the issue #55810
This commit is contained in:
Pietro Albini 2018-11-11 00:21:21 +01:00 committed by GitHub
commit c4ca49aebd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 4 deletions

View file

@ -0,0 +1,23 @@
// compile-pass
// rust-lang/rust#55810: types for a binding in a match arm can be
// inferred from arms that come later in the match.
struct S;
impl S {
fn method(&self) -> bool {
unimplemented!()
}
}
fn get<T>() -> T {
unimplemented!()
}
fn main() {
match get() {
x if x.method() => {}
&S => {}
}
}