about summary refs log tree commit diff
path: root/tests/ui/reachable/expr_cast.rs
blob: aa412c99b2e9b6e7536317f706773a2cd17dce68 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//@ check-pass
//@ edition: 2024
//
// Check that we don't warn on `as` casts of never to any as unreachable.
// While they *are* unreachable, sometimes they are required to appeal typeck.
#![deny(unreachable_code)]

fn a() {
    _ = {return} as u32;
}

fn b() {
    (return) as u32;
}

// example that needs an explicit never-to-any `as` cast
fn example() -> impl Iterator<Item = u8> {
    todo!() as std::iter::Empty<_>
}

fn main() {}