diff options
Diffstat (limited to 'tests/ui/unsafe/unsafe-subtyping.rs')
| -rw-r--r-- | tests/ui/unsafe/unsafe-subtyping.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/ui/unsafe/unsafe-subtyping.rs b/tests/ui/unsafe/unsafe-subtyping.rs new file mode 100644 index 00000000000..a4b748a50f2 --- /dev/null +++ b/tests/ui/unsafe/unsafe-subtyping.rs @@ -0,0 +1,11 @@ +// Check that safe fns are not a subtype of unsafe fns. + +fn foo(x: Option<fn(i32)>) -> Option<unsafe fn(i32)> { + x //~ ERROR mismatched types +} + +fn bar(x: fn(i32)) -> unsafe fn(i32) { + x // OK, coercion! +} + +fn main() { } |
