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:
commit
c4ca49aebd
2 changed files with 27 additions and 4 deletions
|
|
@ -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 => {}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue