fix: introduce new type var when expectation for ref pat is not ref

This commit is contained in:
Ryo Yoshida 2023-05-21 21:25:01 +09:00
parent a04d8456be
commit 01f42d2405
No known key found for this signature in database
GPG key ID: E25698A930586171
2 changed files with 26 additions and 4 deletions

View file

@ -1,6 +1,6 @@
use expect_test::expect;
use super::{check, check_infer, check_infer_with_mismatches, check_types};
use super::{check, check_infer, check_infer_with_mismatches, check_no_mismatches, check_types};
#[test]
fn infer_pattern() {
@ -240,6 +240,21 @@ fn infer_pattern_match_ergonomics_ref() {
);
}
#[test]
fn ref_pat_with_inference_variable() {
check_no_mismatches(
r#"
enum E { A }
fn test() {
let f = |e| match e {
&E::A => {}
};
f(&E::A);
}
"#,
);
}
#[test]
fn infer_pattern_match_slice() {
check_infer(