impl Trait
in return type does not compile if function returns panic!()
/ todo!()
/ unimplemented!()
#102410
Labels
C-bug
Category: This is a bug.
The following code fails to compile:
However, replacing the
impl Trait
with the regular generics syntax compiles fine:This happens only if there is a single path in the function terminating in a
panic!()
. The following compiles fine too:This also happens with
todo!()
andunimplemented!()
since those macros are also basically justpanic!()
s.If my understanding is correct,
impl Trait
and<T: Trait>
should behave identically, but clearly they don't and the typecheck fails in theimpl Trait
version. This means that, for example, usingtodo!()
in place of unfinished code is not possible in a function returningimpl Trait
.This occurs on 1.64.0 stable as well as nightly
The text was updated successfully, but these errors were encountered: