Open
Description
fn test() -> impl Iterator<Item = i32> {
panic!()
}
doesn't compile, as ()
(nor !
) implement Iterator<Item = i32>
.
#![feature(never_type_fallback)] // required for `panic!() as _`
fn test() -> impl Iterator<Item = i32> {
panic!() as std::iter::Empty<_>
}
compiles, but gives this warning:
warning: unreachable expression
--> src/lib.rs:3:5
|
3 | panic!() as std::iter::Empty<_>
| --------^^^^^^^^^^^^^^^^^^^^^^^
| |
| unreachable expression
| any code following this expression is unreachable
|
= note: `#[warn(unreachable_code)]` on by default
= note: this warning originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
#![feature(type_ascription)]
fn test() -> impl Iterator<Item = i32> {
panic!(): std::iter::Empty<_>
}
also compiles, but gives the same warning.