forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#55819 - pnkfelix:issue-55810-must-typeck-pa…
…ts-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 rust-lang#55810
- Loading branch information
Showing
2 changed files
with
27 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
23 changes: 23 additions & 0 deletions
23
src/test/ui/typeck/issue-55810-must-typeck-match-pats-before-guards.rs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 => {} | ||
} | ||
} |