Skip to content

Commit 7c5b2e6

Browse files
committed
test associated consts
1 parent 0ada942 commit 7c5b2e6

File tree

3 files changed

+81
-33
lines changed

3 files changed

+81
-33
lines changed

tests/expectations/tests/bitfield-enum-basic.rs

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,18 @@
22

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

5-
pub const Foo_Bar: Foo = Foo(2);
6-
pub const Foo_Baz: Foo = Foo(4);
7-
pub const Foo_Duplicated: Foo = Foo(4);
8-
pub const Foo_Negative: Foo = Foo(-3);
5+
impl Foo {
6+
pub const Bar: Foo = Foo(2);
7+
}
8+
impl Foo {
9+
pub const Baz: Foo = Foo(4);
10+
}
11+
impl Foo {
12+
pub const Duplicated: Foo = Foo(4);
13+
}
14+
impl Foo {
15+
pub const Negative: Foo = Foo(-3);
16+
}
917
impl ::std::ops::BitOr<Foo> for Foo {
1018
type Output = Self;
1119
#[inline]
@@ -35,10 +43,18 @@ impl ::std::ops::BitAndAssign for Foo {
3543
#[repr(C)]
3644
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
3745
pub struct Foo(pub i32);
38-
pub const Buz_Bar: Buz = Buz(2);
39-
pub const Buz_Baz: Buz = Buz(4);
40-
pub const Buz_Duplicated: Buz = Buz(4);
41-
pub const Buz_Negative: Buz = Buz(-3);
46+
impl Buz {
47+
pub const Bar: Buz = Buz(2);
48+
}
49+
impl Buz {
50+
pub const Baz: Buz = Buz(4);
51+
}
52+
impl Buz {
53+
pub const Duplicated: Buz = Buz(4);
54+
}
55+
impl Buz {
56+
pub const Negative: Buz = Buz(-3);
57+
}
4258
impl ::std::ops::BitOr<Buz> for Buz {
4359
type Output = Self;
4460
#[inline]
@@ -68,8 +84,12 @@ impl ::std::ops::BitAndAssign for Buz {
6884
#[repr(C)]
6985
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
7086
pub struct Buz(pub i8);
71-
pub const NS_FOO: _bindgen_ty_1 = _bindgen_ty_1(1);
72-
pub const NS_BAR: _bindgen_ty_1 = _bindgen_ty_1(2);
87+
impl _bindgen_ty_1 {
88+
pub const NS_FOO: _bindgen_ty_1 = _bindgen_ty_1(1);
89+
}
90+
impl _bindgen_ty_1 {
91+
pub const NS_BAR: _bindgen_ty_1 = _bindgen_ty_1(2);
92+
}
7393
impl ::std::ops::BitOr<_bindgen_ty_1> for _bindgen_ty_1 {
7494
type Output = Self;
7595
#[inline]
@@ -104,8 +124,12 @@ pub struct _bindgen_ty_1(pub u32);
104124
pub struct Dummy {
105125
pub _address: u8,
106126
}
107-
pub const Dummy_DUMMY_FOO: Dummy__bindgen_ty_1 = Dummy__bindgen_ty_1(1);
108-
pub const Dummy_DUMMY_BAR: Dummy__bindgen_ty_1 = Dummy__bindgen_ty_1(2);
127+
impl Dummy__bindgen_ty_1 {
128+
pub const DUMMY_FOO: Dummy__bindgen_ty_1 = Dummy__bindgen_ty_1(1);
129+
}
130+
impl Dummy__bindgen_ty_1 {
131+
pub const DUMMY_BAR: Dummy__bindgen_ty_1 = Dummy__bindgen_ty_1(2);
132+
}
109133
impl ::std::ops::BitOr<Dummy__bindgen_ty_1> for Dummy__bindgen_ty_1 {
110134
type Output = Self;
111135
#[inline]

tests/expectations/tests/enum-doc-bitfield.rs

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,33 @@
22

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

5-
/// Document field with three slashes
6-
pub const B_VAR_A: B = B(0);
7-
/// Document field with preceeding star
8-
pub const B_VAR_B: B = B(1);
9-
/// Document field with preceeding exclamation
10-
pub const B_VAR_C: B = B(2);
11-
/// < Document field with following star
12-
pub const B_VAR_D: B = B(3);
13-
/// < Document field with following exclamation
14-
pub const B_VAR_E: B = B(4);
15-
/// Document field with preceeding star, with a loong long multiline
16-
/// comment.
17-
///
18-
/// Very interesting documentation, definitely.
19-
pub const B_VAR_F: B = B(5);
5+
impl B {
6+
/// Document field with three slashes
7+
pub const VAR_A: B = B(0);
8+
}
9+
impl B {
10+
/// Document field with preceeding star
11+
pub const VAR_B: B = B(1);
12+
}
13+
impl B {
14+
/// Document field with preceeding exclamation
15+
pub const VAR_C: B = B(2);
16+
}
17+
impl B {
18+
/// < Document field with following star
19+
pub const VAR_D: B = B(3);
20+
}
21+
impl B {
22+
/// < Document field with following exclamation
23+
pub const VAR_E: B = B(4);
24+
}
25+
impl B {
26+
/// Document field with preceeding star, with a loong long multiline
27+
/// comment.
28+
///
29+
/// Very interesting documentation, definitely.
30+
pub const VAR_F: B = B(5);
31+
}
2032
impl ::std::ops::BitOr<B> for B {
2133
type Output = Self;
2234
#[inline]

tests/expectations/tests/issue-1198-alias-rust-bitfield-enum.rs

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,15 @@
22

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

5-
pub const MyDupeEnum_A: MyDupeEnum = MyDupeEnum(0);
6-
pub const MyDupeEnum_A_alias: MyDupeEnum = MyDupeEnum(0);
7-
pub const MyDupeEnum_B: MyDupeEnum = MyDupeEnum(1);
5+
impl MyDupeEnum {
6+
pub const A: MyDupeEnum = MyDupeEnum(0);
7+
}
8+
impl MyDupeEnum {
9+
pub const A_alias: MyDupeEnum = MyDupeEnum(0);
10+
}
11+
impl MyDupeEnum {
12+
pub const B: MyDupeEnum = MyDupeEnum(1);
13+
}
814
impl ::std::ops::BitOr<MyDupeEnum> for MyDupeEnum {
915
type Output = Self;
1016
#[inline]
@@ -34,9 +40,15 @@ impl ::std::ops::BitAndAssign for MyDupeEnum {
3440
#[repr(C)]
3541
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
3642
pub struct MyDupeEnum(pub u32);
37-
pub const MyOtherDupeEnum_C: MyOtherDupeEnum = MyOtherDupeEnum(0);
38-
pub const MyOtherDupeEnum_C_alias: MyOtherDupeEnum = MyOtherDupeEnum(0);
39-
pub const MyOtherDupeEnum_D: MyOtherDupeEnum = MyOtherDupeEnum(1);
43+
impl MyOtherDupeEnum {
44+
pub const C: MyOtherDupeEnum = MyOtherDupeEnum(0);
45+
}
46+
impl MyOtherDupeEnum {
47+
pub const C_alias: MyOtherDupeEnum = MyOtherDupeEnum(0);
48+
}
49+
impl MyOtherDupeEnum {
50+
pub const D: MyOtherDupeEnum = MyOtherDupeEnum(1);
51+
}
4052
impl ::std::ops::BitOr<MyOtherDupeEnum> for MyOtherDupeEnum {
4153
type Output = Self;
4254
#[inline]

0 commit comments

Comments
 (0)