Skip to content

Commit

Permalink
Test const mod enum variants shadowing "Type"
Browse files Browse the repository at this point in the history
  • Loading branch information
tmfink committed Jun 19, 2017
1 parent 4b10529 commit 465e242
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/expectations/tests/constify-module-enums-shadow-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/* automatically generated by rust-bindgen */


#![allow(dead_code, non_snake_case, non_camel_case_types, non_upper_case_globals)]


pub mod foo {
pub type Type = ::std::os::raw::c_uint;
pub const Type: Type = 0;
pub const Type_: Type = 1;
pub const Type1: Type = 2;
pub const Type__: Type = 3;
}
#[repr(C)]
#[derive(Debug, Copy)]
pub struct bar {
pub member: foo::Type,
}
#[test]
fn bindgen_test_layout_bar() {
assert_eq!(::std::mem::size_of::<bar>() , 4usize , concat ! (
"Size of: " , stringify ! ( bar ) ));
assert_eq! (::std::mem::align_of::<bar>() , 4usize , concat ! (
"Alignment of " , stringify ! ( bar ) ));
assert_eq! (unsafe {
& ( * ( 0 as * const bar ) ) . member as * const _ as usize }
, 0usize , concat ! (
"Alignment of field: " , stringify ! ( bar ) , "::" ,
stringify ! ( member ) ));
}
impl Clone for bar {
fn clone(&self) -> Self { *self }
}
impl Default for bar {
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
}
12 changes: 12 additions & 0 deletions tests/headers/constify-module-enums-shadow-name.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// bindgen-flags: --constified-enum-module foo

enum foo {
Type,
Type_,
Type1,
Type__,
};

struct bar {
enum foo member;
};

0 comments on commit 465e242

Please sign in to comment.