Open
Description
I tried this code:
trait MyTrait {
fn f() -> [u8]; // Ok, but it shouldn't be
}
impl MyTrait for () {
fn f() -> [u8] { // Compilation error, as expected
todo!()
}
}
I expect the line marked with "Ok" to cause compilation error, because the return type is unsized.
It's better to produce diagnostics early, without waiting until somebody tries to implement this trait (which would be impossible anyway).
Instead, this happens: the compiler allows to declare the associated function f()
, and only complains when I try to implement it for a concrete type.
I did a quick search in the issue tracker and it looks like it's maybe similar to #82633.
Meta
rustc --version --verbose
:
rustc 1.70.0-nightly (7b4f48927 2023-03-12)
binary: rustc
commit-hash: 7b4f48927dce585f747a58083b45ab62b9d73a53
commit-date: 2023-03-12
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7