From 44d3c329221efd0f3fbc9e987d426b158aa55fa6 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 11 Jul 2021 16:14:22 +0200 Subject: [PATCH] Add test for #9560 --- crates/hir_ty/src/tests/coercion.rs | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/crates/hir_ty/src/tests/coercion.rs b/crates/hir_ty/src/tests/coercion.rs index aecc482cfdc..8db1592c916 100644 --- a/crates/hir_ty/src/tests/coercion.rs +++ b/crates/hir_ty/src/tests/coercion.rs @@ -500,7 +500,7 @@ fn main() { } #[test] -fn coerce_unsize_expected_type() { +fn coerce_unsize_expected_type_1() { check_no_mismatches( r#" //- minicore: coerce_unsized @@ -520,6 +520,32 @@ fn main() { ); } +#[test] +fn coerce_unsize_expected_type_2() { + // FIXME: this is wrong, #9560 + check( + r#" +//- minicore: coerce_unsized +struct InFile; +impl InFile { + fn with_value(self, value: U) -> InFile { InFile } +} +struct RecordField; +trait AstNode {} +impl AstNode for RecordField {} + +fn takes_dyn(it: InFile<&dyn AstNode>) {} + +fn test() { + let x: InFile<()> = InFile; + let n = &RecordField; + takes_dyn(x.with_value(n)); + // ^^^^^^^^^^^^^^^ expected InFile<&dyn AstNode>, got InFile<&RecordField> +} + "#, + ); +} + #[test] fn coerce_array_elems_lub() { check_no_mismatches(