]>
Commit | Line | Data |
---|---|---|
1c054081 JP |
1 | diff --git a/Cargo.lock b/Cargo.lock |
2 | --- a/Cargo.lock | |
3 | +++ b/Cargo.lock | |
4 | @@ -392,12 +392,10 @@ | |
5 | ] | |
6 | ||
7 | [[package]] | |
8 | name = "bindgen" | |
9 | version = "0.56.0" | |
10 | -source = "registry+https://github.com/rust-lang/crates.io-index" | |
11 | -checksum = "2da379dbebc0b76ef63ca68d8fc6e71c0f13e59432e0987e508c1820e6ab5239" | |
12 | dependencies = [ | |
13 | "bitflags", | |
14 | "cexpr", | |
15 | "clang-sys", | |
16 | "lazy_static", | |
17 | diff --git a/Cargo.toml b/Cargo.toml | |
18 | --- a/Cargo.toml | |
19 | +++ b/Cargo.toml | |
20 | @@ -104,10 +104,13 @@ | |
21 | web-sys = { path = "build/rust/dummy-web/web-sys" } | |
22 | ||
23 | # Overrides to allow easier use of common internal crates. | |
24 | moz_asserts = { path = "mozglue/static/rust/moz_asserts" } | |
25 | ||
26 | +# Patch bindgen to work around issues with some unsound transmutes when compiling with LLVM 16+. | |
27 | +bindgen = { path = "third_party/rust/bindgen" } | |
28 | + | |
29 | # Other overrides | |
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 | |
37 | @@ -109,11 +109,11 @@ | |
38 | const PARTIAL_EQ = 1 << 7; | |
39 | const EQ = 1 << 8; | |
40 | } | |
41 | } | |
42 | ||
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(); | |
46 | ||
47 | if item.can_derive_debug(ctx) && !item.annotations().disallow_debug() { | |
48 | derivable_traits |= DerivableTraits::DEBUG; | |
49 | } | |
50 | @@ -122,11 +122,11 @@ | |
51 | derivable_traits |= DerivableTraits::DEFAULT; | |
52 | } | |
53 | ||
54 | let all_template_params = item.all_template_params(ctx); | |
55 | ||
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; | |
59 | ||
60 | if ctx.options().rust_features().builtin_clone_impls || | |
61 | !all_template_params.is_empty() | |
62 | { | |
63 | @@ -889,11 +889,11 @@ | |
64 | alias_style | |
65 | ); | |
66 | ||
67 | let mut attributes = | |
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)) | |
74 | } | |
75 | ||
76 | @@ -1811,12 +1811,13 @@ | |
77 | // Just get the layout, and assume C++ if not. | |
78 | // | |
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(); | |
83 | fields.push(quote! { | |
84 | - _unused: [u8; 0], | |
85 | + _unused: ::#prefix::cell::UnsafeCell<[u8; 0]>, | |
86 | }); | |
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))] | |
93 | }); | |
94 | } | |
95 | } | |
96 | ||
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)); | |
107 | } | |
108 | ||
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. | |
114 | derives.insert( | |
115 | DerivableTraits::CLONE | | |
116 | DerivableTraits::COPY | | |
117 |