]> git.proxmox.com Git - rustc.git/blame - src/test/debuginfo/nil-enum.rs
New upstream version 1.31.0~beta.4+dfsg1
[rustc.git] / src / test / debuginfo / nil-enum.rs
CommitLineData
1a4d82fc
JJ
1// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
0bf4aa26
XL
11// NOTE Instantiating an empty enum is UB. This test may break in the future.
12
1a4d82fc
JJ
13// LLDB can't handle zero-sized values
14// ignore-lldb
15
1a4d82fc
JJ
16
17// compile-flags:-g
18// gdb-command:run
19
20// gdb-command:print first
c30ab7b3
SL
21// gdbg-check:$1 = {<No data fields>}
22// gdbr-check:$1 = <error reading variable>
1a4d82fc
JJ
23
24// gdb-command:print second
c30ab7b3
SL
25// gdbg-check:$2 = {<No data fields>}
26// gdbr-check:$2 = <error reading variable>
1a4d82fc
JJ
27
28#![allow(unused_variables)]
b039eaaf 29#![feature(omit_gdb_pretty_printer_section)]
0bf4aa26 30#![feature(maybe_uninit)]
1a4d82fc
JJ
31#![omit_gdb_pretty_printer_section]
32
0bf4aa26
XL
33use std::mem::MaybeUninit;
34
1a4d82fc
JJ
35enum ANilEnum {}
36enum AnotherNilEnum {}
37
c30ab7b3 38// This test relies on gdbg printing the string "{<No data fields>}" for empty
1a4d82fc 39// structs (which may change some time)
c30ab7b3 40// The error from gdbr is expected since nil enums are not supposed to exist.
1a4d82fc
JJ
41fn main() {
42 unsafe {
0bf4aa26
XL
43 let first: ANilEnum = MaybeUninit::uninitialized().into_inner();
44 let second: AnotherNilEnum = MaybeUninit::uninitialized().into_inner();
1a4d82fc
JJ
45
46 zzz(); // #break
47 }
48}
49
50fn zzz() {()}