@@ -390,7 +390,7 @@ fn test() {
390
390
let _: &Foo<[usize]> = &Foo { t: [1, 2, 3] };
391
391
//^^^^^^^^^ expected [usize], got [usize; 3]
392
392
let _: &Bar<[usize]> = &Bar(Foo { t: [1, 2, 3] });
393
- //^^^^^^^^^^^^^^^^^^^^^^^^^^ expected &Bar< [usize]> , got &Bar<[i32 ; 3]>
393
+ //^^^^^^^^^ expected [usize], got [usize ; 3]
394
394
}
395
395
"# ,
396
396
) ;
@@ -522,8 +522,7 @@ fn main() {
522
522
523
523
#[ test]
524
524
fn coerce_unsize_expected_type_2 ( ) {
525
- // FIXME: this is wrong, #9560
526
- check (
525
+ check_no_mismatches (
527
526
r#"
528
527
//- minicore: coerce_unsized
529
528
struct InFile<T>;
@@ -540,7 +539,48 @@ fn test() {
540
539
let x: InFile<()> = InFile;
541
540
let n = &RecordField;
542
541
takes_dyn(x.with_value(n));
543
- // ^^^^^^^^^^^^^^^ expected InFile<&dyn AstNode>, got InFile<&RecordField>
542
+ }
543
+ "# ,
544
+ ) ;
545
+ }
546
+
547
+ #[ test]
548
+ fn coerce_unsize_expected_type_3 ( ) {
549
+ check_no_mismatches (
550
+ r#"
551
+ //- minicore: coerce_unsized
552
+ enum Option<T> { Some(T), None }
553
+ struct RecordField;
554
+ trait AstNode {}
555
+ impl AstNode for RecordField {}
556
+
557
+ fn takes_dyn(it: Option<&dyn AstNode>) {}
558
+
559
+ fn test() {
560
+ let x: InFile<()> = InFile;
561
+ let n = &RecordField;
562
+ takes_dyn(Option::Some(n));
563
+ }
564
+ "# ,
565
+ ) ;
566
+ }
567
+
568
+ #[ test]
569
+ fn coerce_unsize_expected_type_4 ( ) {
570
+ check_no_mismatches (
571
+ r#"
572
+ //- minicore: coerce_unsized
573
+ use core::{marker::Unsize, ops::CoerceUnsized};
574
+
575
+ struct B<T: ?Sized>(*const T);
576
+ impl<T: ?Sized> B<T> {
577
+ fn new(t: T) -> Self { B(&t) }
578
+ }
579
+
580
+ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<B<U>> for B<T> {}
581
+
582
+ fn test() {
583
+ let _: B<[isize]> = B::new({ [1, 2, 3] });
544
584
}
545
585
"# ,
546
586
) ;
0 commit comments