Skip to content

Commit 44d3c32

Browse files
committed
Add test for #9560
1 parent b7bd455 commit 44d3c32

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

crates/hir_ty/src/tests/coercion.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ fn main() {
500500
}
501501

502502
#[test]
503-
fn coerce_unsize_expected_type() {
503+
fn coerce_unsize_expected_type_1() {
504504
check_no_mismatches(
505505
r#"
506506
//- minicore: coerce_unsized
@@ -520,6 +520,32 @@ fn main() {
520520
);
521521
}
522522

523+
#[test]
524+
fn coerce_unsize_expected_type_2() {
525+
// FIXME: this is wrong, #9560
526+
check(
527+
r#"
528+
//- minicore: coerce_unsized
529+
struct InFile<T>;
530+
impl<T> InFile<T> {
531+
fn with_value<U>(self, value: U) -> InFile<U> { InFile }
532+
}
533+
struct RecordField;
534+
trait AstNode {}
535+
impl AstNode for RecordField {}
536+
537+
fn takes_dyn(it: InFile<&dyn AstNode>) {}
538+
539+
fn test() {
540+
let x: InFile<()> = InFile;
541+
let n = &RecordField;
542+
takes_dyn(x.with_value(n));
543+
// ^^^^^^^^^^^^^^^ expected InFile<&dyn AstNode>, got InFile<&RecordField>
544+
}
545+
"#,
546+
);
547+
}
548+
523549
#[test]
524550
fn coerce_array_elems_lub() {
525551
check_no_mismatches(

0 commit comments

Comments
 (0)