rust/src/test/ui/empty/empty-never-array.rs
Tyler Mandry 9058bf2100 Make use of possibly uninitialized data a hard error
This is one of the behaviors we no longer allow in NLL. Since it can
lead to undefined behavior, I think it's definitely worth making it a
hard error without waiting to turn off migration mode ().

Closes .

My ulterior motive here is making it impossible to leave variables
partially initialized across a yield (see discussion at ), so
tests are included for that.
2019-08-05 14:57:12 -07:00

19 lines
402 B
Rust

#![feature(never_type)]
enum Helper<T, U> {
T(T, [!; 0]),
#[allow(dead_code)]
U(U),
}
fn transmute<T, U>(t: T) -> U {
let Helper::U(u) = Helper::T(t, []);
//~^ ERROR refutable pattern in local binding: `T(_, _)` not covered
u
//~^ ERROR use of possibly uninitialized variable: `u`
}
fn main() {
println!("{:?}", transmute::<&str, (*const u8, u64)>("type safety"));
}