| 1 |
// Copyright 2019 The Fuchsia Authors |
| 2 |
// |
| 3 |
// Licensed under a BSD-style license <LICENSE-BSD>, Apache License, Version 2.0 |
| 4 |
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0>, or the MIT |
| 5 |
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your option. |
| 6 |
// This file may not be copied, modified, or distributed except according to |
| 7 |
// those terms. |
| 8 |
|
| 9 |
// See comment in `include.rs` for why we disable the prelude. |
| 10 |
#![no_implicit_prelude] |
| 11 |
#![allow(warnings)] |
| 12 |
|
| 13 |
include!("include.rs"); |
| 14 |
|
| 15 |
// An enum is `Unaligned` if: |
| 16 |
// - No `repr(align(N > 1))` |
| 17 |
// - `repr(u8)` or `repr(i8)` |
| 18 |
|
| 19 |
#[derive(imp::Unaligned)] |
| 20 |
#[repr(u8)] |
| 21 |
enum Foo { |
| 22 |
A, |
| 23 |
} |
| 24 |
|
| 25 |
util_assert_impl_all!(Foo: imp::Unaligned); |
| 26 |
|
| 27 |
#[derive(imp::Unaligned)] |
| 28 |
#[repr(i8)] |
| 29 |
enum Bar { |
| 30 |
A, |
| 31 |
} |
| 32 |
|
| 33 |
util_assert_impl_all!(Bar: imp::Unaligned); |
| 34 |
|
| 35 |
#[derive(imp::Unaligned)] |
| 36 |
#[repr(u8, align(1))] |
| 37 |
enum Baz { |
| 38 |
A, |
| 39 |
} |
| 40 |
|
| 41 |
util_assert_impl_all!(Baz: imp::Unaligned); |
| 42 |
|
| 43 |
#[derive(imp::Unaligned)] |
| 44 |
#[repr(i8, align(1))] |
| 45 |
enum Blah { |
| 46 |
B, |
| 47 |
} |
| 48 |
|
| 49 |
util_assert_impl_all!(Blah: imp::Unaligned); |