Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/tests/coercion.rs')
-rw-r--r--crates/hir-ty/src/tests/coercion.rs28
1 files changed, 23 insertions, 5 deletions
diff --git a/crates/hir-ty/src/tests/coercion.rs b/crates/hir-ty/src/tests/coercion.rs
index 7992f1feee..ef94814d58 100644
--- a/crates/hir-ty/src/tests/coercion.rs
+++ b/crates/hir-ty/src/tests/coercion.rs
@@ -185,11 +185,10 @@ fn test() {
let t = &mut 1;
let x = match 1 {
1 => t as *mut i32,
+ //^^^^^^^^^^^^^ adjustments: Pointer(MutToConstPointer)
2 => t as &i32,
//^^^^^^^^^ expected *mut i32, got &'? i32
_ => t as *const i32,
- // ^^^^^^^^^^^^^^^ adjustments: Pointer(MutToConstPointer)
-
};
x;
//^ type: *const i32
@@ -536,7 +535,7 @@ fn test() {
#[test]
fn coerce_unsize_generic() {
- check(
+ check_no_mismatches(
r#"
//- minicore: coerce_unsized
struct Foo<T> { t: T };
@@ -544,9 +543,7 @@ struct Bar<T>(Foo<T>);
fn test() {
let _: &Foo<[usize]> = &Foo { t: [1, 2, 3] };
- //^^^^^^^^^^^^^^^^^^^^^ expected &'? Foo<[usize]>, got &'? Foo<[i32; 3]>
let _: &Bar<[usize]> = &Bar(Foo { t: [1, 2, 3] });
- //^^^^^^^^^^^^^^^^^^^^^^^^^^ expected &'? Bar<[usize]>, got &'? Bar<[i32; 3]>
}
"#,
);
@@ -958,3 +955,24 @@ fn f() {
"#,
);
}
+
+#[test]
+fn coerce_nested_unsized_struct() {
+ check_types(
+ r#"
+//- minicore: fn, coerce_unsized, dispatch_from_dyn, sized
+use core::marker::Unsize;
+
+struct Foo<T: ?Sized>(T);
+
+fn need(_: &Foo<dyn Fn(i32) -> i32>) {
+}
+
+fn test() {
+ let callback = |x| x;
+ //^ i32
+ need(&Foo(callback));
+}
+"#,
+ )
+}