diff options
Diffstat (limited to '')
-rw-r--r-- | src/test/ui/coercion/coercion-missing-tail-expected-type.stderr | 4 | ||||
-rw-r--r-- | src/test/ui/coercion/issue-36007.rs | 20 |
2 files changed, 22 insertions, 2 deletions
diff --git a/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr b/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr index a4843bca5..4c04bb113 100644 --- a/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr +++ b/src/test/ui/coercion/coercion-missing-tail-expected-type.stderr @@ -6,7 +6,7 @@ LL | fn plus_one(x: i32) -> i32 { | | | implicitly returns `()` as its body has no tail or `return` expression LL | x + 1; - | - help: remove this semicolon + | - help: remove this semicolon to return this value error[E0308]: mismatched types --> $DIR/coercion-missing-tail-expected-type.rs:8:13 @@ -16,7 +16,7 @@ LL | fn foo() -> Result<u8, u64> { | | | implicitly returns `()` as its body has no tail or `return` expression LL | Ok(1); - | - help: remove this semicolon + | - help: remove this semicolon to return this value | = note: expected enum `Result<u8, u64>` found unit type `()` diff --git a/src/test/ui/coercion/issue-36007.rs b/src/test/ui/coercion/issue-36007.rs new file mode 100644 index 000000000..78812df87 --- /dev/null +++ b/src/test/ui/coercion/issue-36007.rs @@ -0,0 +1,20 @@ +// check-pass +#![feature(coerce_unsized, unsize)] + +use std::marker::Unsize; +use std::ops::CoerceUnsized; + +struct Foo<T: ?Sized>(Box<T>); + +impl<T> CoerceUnsized<Foo<dyn Baz>> for Foo<T> where T: Unsize<dyn Baz> {} + +struct Bar; + +trait Baz {} + +impl Baz for Bar {} + +fn main() { + let foo = Foo(Box::new(Bar)); + let foobar: Foo<Bar> = foo; +} |