Skip to content

Commit 31e4409

Browse files
committed
codegen: Make phantom fields public.
Otherwise you can't construct structs outside of the bindings file, which is breaking. Also, given the previous change was breaking and I didn't notice, I yanked 0.24.1.
1 parent 2d88dd1 commit 31e4409

40 files changed

+73
-72
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ name = "bindgen"
1313
readme = "README.md"
1414
repository = "https://github.com/servo/rust-bindgen"
1515
documentation = "https://docs.rs/bindgen"
16-
version = "0.24.1"
16+
version = "0.25.0"
1717
build = "build.rs"
1818

1919
exclude = [

src/codegen/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1477,6 +1477,7 @@ impl CodeGenerator for CompInfo {
14771477
ctx.ext_cx(),
14781478
::$prefix::marker::PhantomData<::$prefix::cell::UnsafeCell<$ident>>);
14791479
let phantom_field = StructFieldBuilder::named(format!("_phantom_{}", idx))
1480+
.pub_()
14801481
.build_ty(phantom_ty);
14811482
fields.push(phantom_field);
14821483
}

tests/expectations/tests/anonymous-template-types.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#[derive(Debug, Copy, Clone)]
99
pub struct Foo<T> {
1010
pub t_member: T,
11-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
11+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
1212
}
1313
impl <T> Default for Foo<T> {
1414
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
@@ -22,7 +22,7 @@ pub struct Bar {
2222
#[derive(Debug, Copy, Clone)]
2323
pub struct Quux<V> {
2424
pub v_member: V,
25-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<V>>,
25+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<V>>,
2626
}
2727
impl <V> Default for Quux<V> {
2828
fn default() -> Self { unsafe { ::std::mem::zeroed() } }

tests/expectations/tests/class_nested.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ impl Clone for A_C {
5353
#[derive(Debug, Copy, Clone)]
5454
pub struct A_D<T> {
5555
pub foo: T,
56-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
56+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
5757
}
5858
impl <T> Default for A_D<T> {
5959
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
@@ -116,13 +116,13 @@ impl Clone for D {
116116
#[derive(Debug, Copy, Clone)]
117117
pub struct Templated<T> {
118118
pub member: T,
119-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
119+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
120120
}
121121
#[repr(C)]
122122
#[derive(Debug, Copy, Clone)]
123123
pub struct Templated_Templated_inner<T> {
124124
pub member_ptr: *mut T,
125-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
125+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
126126
}
127127
impl <T> Default for Templated_Templated_inner<T> {
128128
fn default() -> Self { unsafe { ::std::mem::zeroed() } }

tests/expectations/tests/class_with_dtor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#[derive(Debug)]
99
pub struct HandleWithDtor<T> {
1010
pub ptr: *mut T,
11-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
11+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
1212
}
1313
impl <T> Default for HandleWithDtor<T> {
1414
fn default() -> Self { unsafe { ::std::mem::zeroed() } }

tests/expectations/tests/const_tparam.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
pub struct C<T> {
1010
pub foo: *const T,
1111
pub bar: *mut T,
12-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
12+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
1313
}
1414
impl <T> Default for C<T> {
1515
fn default() -> Self { unsafe { ::std::mem::zeroed() } }

tests/expectations/tests/default-template-parameter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
pub struct Foo<T, U> {
1010
pub t: T,
1111
pub u: U,
12-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
13-
_phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>,
12+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
13+
pub _phantom_1: ::std::marker::PhantomData<::std::cell::UnsafeCell<U>>,
1414
}
1515
impl <T, U> Default for Foo<T, U> {
1616
fn default() -> Self { unsafe { ::std::mem::zeroed() } }

tests/expectations/tests/forward-declaration-autoptr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub struct Foo {
1313
#[derive(Debug, Copy, Clone)]
1414
pub struct RefPtr<T> {
1515
pub m_inner: *mut T,
16-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
16+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
1717
}
1818
impl <T> Default for RefPtr<T> {
1919
fn default() -> Self { unsafe { ::std::mem::zeroed() } }

tests/expectations/tests/forward-inherit-struct-with-fields.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#[derive(Debug, Copy, Clone)]
99
pub struct Rooted<T> {
1010
pub _base: js_RootedBase<T>,
11-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
11+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
1212
}
1313
impl <T> Default for Rooted<T> {
1414
fn default() -> Self { unsafe { ::std::mem::zeroed() } }
@@ -18,7 +18,7 @@ impl <T> Default for Rooted<T> {
1818
pub struct js_RootedBase<T> {
1919
pub foo: *mut T,
2020
pub next: *mut Rooted<T>,
21-
_phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
21+
pub _phantom_0: ::std::marker::PhantomData<::std::cell::UnsafeCell<T>>,
2222
}
2323
impl <T> Default for js_RootedBase<T> {
2424
fn default() -> Self { unsafe { ::std::mem::zeroed() } }

0 commit comments

Comments
 (0)