Closed
Description
I tried this code:
trait Foo {
fn foo(&self);
}
impl Foo for i32 {
fn foo(&self) {
println!("<Foo as i32>::foo")
}
}
fn bar() -> impl Foo {
42
}
fn baz() -> impl Foo {
unimplemented!()
}
I expected to see this happen: successful compilation. Instead, this happened: compilation error:
error[E0277]: the trait bound `(): Foo` is not satisfied
--> src/lib.rs:15:13
|
15 | fn baz() -> impl Foo {
| ^^^^^^^^ the trait `Foo` is not implemented for `()`
16 | unimplemented!()
| ---------------- this returned value is of type `!`
|
= note: the return type of a function must have a statically known size
Meta
rustc --version --verbose
:
rustc 1.43.0 (4fb7144ed 2020-04-20)
binary: rustc
commit-hash: 4fb7144ed159f94491249e86d5bbd033b5d60550
commit-date: 2020-04-20
host: x86_64-unknown-linux-gnu
release: 1.43.0
LLVM version: 9.0