1 diff --git a/Cargo.lock b/Cargo.lock
10 -source = "registry+https://github.com/rust-lang/crates.io-index"
11 -checksum = "2da379dbebc0b76ef63ca68d8fc6e71c0f13e59432e0987e508c1820e6ab5239"
17 diff --git a/Cargo.toml b/Cargo.toml
21 web-sys = { path = "build/rust/dummy-web/web-sys" }
23 # Overrides to allow easier use of common internal crates.
24 moz_asserts = { path = "mozglue/static/rust/moz_asserts" }
26 +# Patch bindgen to work around issues with some unsound transmutes when compiling with LLVM 16+.
27 +bindgen = { path = "third_party/rust/bindgen" }
30 async-task = { git = "https://github.com/smol-rs/async-task", rev="f6488e35beccb26eb6e85847b02aa78a42cd3d0e" }
31 chardetng = { git = "https://github.com/hsivonen/chardetng", rev="3484d3e3ebdc8931493aa5df4d7ee9360a90e76b" }
32 chardetng_c = { git = "https://github.com/hsivonen/chardetng_c", rev="ed8a4c6f900a90d4dbc1d64b856e61490a1c3570" }
33 coremidi = { git = "https://github.com/chris-zen/coremidi.git", rev="fc68464b5445caf111e41f643a2e69ccce0b4f83" }
34 diff --git a/third_party/rust/bindgen/src/codegen/mod.rs b/third_party/rust/bindgen/src/codegen/mod.rs
35 --- a/third_party/rust/bindgen/src/codegen/mod.rs
36 +++ b/third_party/rust/bindgen/src/codegen/mod.rs
38 const PARTIAL_EQ = 1 << 7;
43 -fn derives_of_item(item: &Item, ctx: &BindgenContext) -> DerivableTraits {
44 +fn derives_of_item(item: &Item, ctx: &BindgenContext, forward_decl: bool) -> DerivableTraits {
45 let mut derivable_traits = DerivableTraits::empty();
47 if item.can_derive_debug(ctx) && !item.annotations().disallow_debug() {
48 derivable_traits |= DerivableTraits::DEBUG;
51 derivable_traits |= DerivableTraits::DEFAULT;
54 let all_template_params = item.all_template_params(ctx);
56 - if item.can_derive_copy(ctx) && !item.annotations().disallow_copy() {
57 + if item.can_derive_copy(ctx) && !item.annotations().disallow_copy() && !forward_decl {
58 derivable_traits |= DerivableTraits::COPY;
60 if ctx.options().rust_features().builtin_clone_impls ||
61 !all_template_params.is_empty()
68 vec![attributes::repr("transparent")];
69 - let derivable_traits = derives_of_item(item, ctx);
70 + let derivable_traits = derives_of_item(item, ctx, false);
71 if !derivable_traits.is_empty() {
72 let derives: Vec<_> = derivable_traits.into();
73 attributes.push(attributes::derives(&derives))
76 @@ -1811,12 +1811,13 @@
77 // Just get the layout, and assume C++ if not.
79 // NOTE: This check is conveniently here to avoid the dummy fields we
80 // may add for unused template parameters.
81 if self.is_forward_declaration() {
82 + let prefix = ctx.trait_prefix();
85 + _unused: ::#prefix::cell::UnsafeCell<[u8; 0]>,
87 } else if item.is_zero_sized(ctx) {
88 let has_address = if is_opaque {
89 // Generate the address field if it's an opaque type and
90 // couldn't determine the layout of the blob.
91 @@ -1889,11 +1890,11 @@
92 #[repr(align(#explicit))]
97 - let derivable_traits = derives_of_item(item, ctx);
98 + let derivable_traits = derives_of_item(item, ctx, self.is_forward_declaration());
99 if !derivable_traits.contains(DerivableTraits::DEBUG) {
100 needs_debug_impl = ctx.options().derive_debug &&
101 ctx.options().impl_debug &&
102 !ctx.no_debug_by_name(item) &&
103 !item.annotations().disallow_debug();
104 @@ -2848,11 +2849,11 @@
105 if let Some(comment) = item.comment(ctx) {
106 attrs.push(attributes::doc(comment));
109 if !variation.is_const() {
110 - let mut derives = derives_of_item(item, ctx);
111 + let mut derives = derives_of_item(item, ctx, false);
112 // For backwards compat, enums always derive Clone/Eq/PartialEq/Hash, even
113 // if we don't generate those by default.
115 DerivableTraits::CLONE |
116 DerivableTraits::COPY |