1 // Copyright 2018 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.
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.
12 #[derive(Copy, Clone)]
21 // A pointer is guaranteed non-null
22 const BAD_ENUM: Enum = unsafe { TransmuteEnum { a: &1 }.b };
23 //~^ ERROR this constant likely exhibits undefined behavior
25 // Invalid enum discriminant
27 #[derive(Copy, Clone)]
31 union TransmuteEnum2 {
35 const BAD_ENUM2 : Enum2 = unsafe { TransmuteEnum2 { a: 0 }.b };
36 //~^ ERROR this constant likely exhibits undefined behavior
38 // Invalid enum field content (mostly to test printing of apths for enum tuple
39 // variants and tuples).
44 // Need to create something which does not clash with enum layout optimizations.
45 const BAD_ENUM_CHAR : Option<(char, char)> = Some(('x', unsafe { TransmuteChar { a: !0 }.b }));
46 //~^ ERROR this constant likely exhibits undefined behavior