aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/diagnostics/match_check.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/diagnostics/match_check.rs')
-rw-r--r--crates/hir_ty/src/diagnostics/match_check.rs20
1 files changed, 18 insertions, 2 deletions
diff --git a/crates/hir_ty/src/diagnostics/match_check.rs b/crates/hir_ty/src/diagnostics/match_check.rs
index 5fb98ff35..992bb8682 100644
--- a/crates/hir_ty/src/diagnostics/match_check.rs
+++ b/crates/hir_ty/src/diagnostics/match_check.rs
@@ -39,8 +39,8 @@ pub(crate) struct Pat {
39} 39}
40 40
41impl Pat { 41impl Pat {
42 pub(crate) fn wildcard_from_ty(ty: &Ty) -> Self { 42 pub(crate) fn wildcard_from_ty(ty: Ty) -> Self {
43 Pat { ty: ty.clone(), kind: Box::new(PatKind::Wild) } 43 Pat { ty, kind: Box::new(PatKind::Wild) }
44 } 44 }
45} 45}
46 46
@@ -1145,6 +1145,22 @@ fn main() {
1145 ); 1145 );
1146 } 1146 }
1147 1147
1148 #[test]
1149 fn pattern_type_is_of_substitution() {
1150 cov_mark::check!(match_check_wildcard_expanded_to_substitutions);
1151 check_diagnostics(
1152 r#"
1153struct Foo<T>(T);
1154struct Bar;
1155fn main() {
1156 match Foo(Bar) {
1157 _ | Foo(Bar) => {}
1158 }
1159}
1160"#,
1161 );
1162 }
1163
1148 mod false_negatives { 1164 mod false_negatives {
1149 //! The implementation of match checking here is a work in progress. As we roll this out, we 1165 //! The implementation of match checking here is a work in progress. As we roll this out, we
1150 //! prefer false negatives to false positives (ideally there would be no false positives). This 1166 //! prefer false negatives to false positives (ideally there would be no false positives). This