"warning: trait `HasFloat` is never used" within bindgen
Categories
(Firefox Build System :: General, defect, P3)
Tracking
(Not tracked)
People
(Reporter: dshin, Assigned: rkraesig)
References
Details
Attachments
(2 obsolete files)
Build generates these warnings:
9:57.49 warning: trait `HasFloat` is never used
9:57.50 --> third_party/rust/bindgen/ir/item.rs:89:18
9:57.50 |
9:57.50 89 | pub(crate) trait HasFloat {
9:57.50 | ^^^^^^^^
9:57.50 |
9:57.50 = note: `#[warn(dead_code)]` on by default
This is fixed on bindgen side but no release has been cut yet containing this change - Latest release is 0.69.4, which we updated to in bug 1878536
Updated•2 years ago
|
| Reporter | ||
Comment 1•2 years ago
|
||
Looks like 0.70.0 is out now, so hopefully we won't be seeing this for long.
Comment 2•2 years ago
|
||
So, because I had a few minutes spare to do this, I tried upgrading (by adding build/rust/bindgen-0.69 which re-exports 0.70.1)
But this is now running into compile-time issues, due to size mismatches of generated structures, which are now const-time checks:
0:09.27 error[E0080]: evaluation of constant value failed
0:09.27 --> /Users/jer/mozilla/src/gecko/obj/aarch64-apple-darwin/release/build/gecko-profiler-4a6bc7d6e7dd41dd/out/gecko/bindings.rs:608:17
0:09.27 |
0:09.27 608 | / ["Size of UniqueJSONStrings"]
0:09.28 609 | | [::std::mem::size_of::<UniqueJSONStrings>() - 144usize];
0:09.28 | |___________________________________________________________________________^ index out of bounds: the length is 1 but the index is 8
0:09.28 error[E0080]: evaluation of constant value failed
0:09.28 --> /Users/jer/mozilla/src/gecko/obj/aarch64-apple-darwin/release/build/gecko-profiler-4a6bc7d6e7dd41dd/out/gecko/bindings.rs:1110:18
0:09.28 |
0:09.28 1110 | [::std::mem::size_of::<MarkerSchema_DynamicData>() - 72usize];
0:09.28 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `40_usize - 72_usize`, which would overflow
0:09.28 error[E0080]: evaluation of constant value failed
0:09.28 --> /Users/jer/mozilla/src/gecko/obj/aarch64-apple-darwin/release/build/gecko-profiler-4a6bc7d6e7dd41dd/out/gecko/bindings.rs:1152:18
0:09.28 |
0:09.28 1152 | [::std::mem::size_of::<MarkerSchema_GraphData>() - 40usize];
0:09.28 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `32_usize - 40_usize`, which would overflow
0:09.28 error[E0080]: evaluation of constant value failed
0:09.29 --> /Users/jer/mozilla/src/gecko/obj/aarch64-apple-darwin/release/build/gecko-profiler-4a6bc7d6e7dd41dd/out/gecko/bindings.rs:1636:125
0:09.29 |
0:09.29 1636 | ...iteFunc_close1_close0"] [:: std :: mem :: size_of :: < root :: mozilla :: UniquePtr > () - 8usize] ;
0:09.29 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize - 8_usize`, which would overflow
0:09.29 error[E0080]: evaluation of constant value failed
0:09.29 --> /Users/jer/mozilla/src/gecko/obj/aarch64-apple-darwin/release/build/gecko-profiler-4a6bc7d6e7dd41dd/out/gecko/bindings.rs:1648:9
0:09.29 |
0:09.29 1648 | ... ["Size of template specialization: HashMap_open0_HashNumber_uint32_t_DefaultHasher_open1_unsigned_int_void_close1_MallocAllocPolicy_close0"] [:: std :: mem :: size_of :: < root :: mozilla :: HashMap < root :: mozilla :: MallocAllocPolicy > > () - 24usize...
0:09.29 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 8
0:09.29 error[E0080]: evaluation of constant value failed
0:09.29 --> /Users/jer/mozilla/src/gecko/obj/aarch64-apple-darwin/release/build/gecko-profiler-4a6bc7d6e7dd41dd/out/gecko/bindings.rs:1668:14
0:09.29 |
0:09.29 1668 | [::std::mem::size_of::<root::mozilla::Maybe>() - 32usize];
0:09.29 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize - 32_usize`, which would overflow
0:09.29 error[E0080]: evaluation of constant value failed
0:09.29 --> /Users/jer/mozilla/src/gecko/obj/aarch64-apple-darwin/release/build/gecko-profiler-4a6bc7d6e7dd41dd/out/gecko/bindings.rs:1675:14
0:09.29 |
0:09.29 1675 | [::std::mem::size_of::<root::mozilla::Maybe>() - 8usize];
0:09.29 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize - 8_usize`, which would overflow
0:09.29 error[E0080]: evaluation of constant value failed
0:09.30 --> /Users/jer/mozilla/src/gecko/obj/aarch64-apple-darwin/release/build/gecko-profiler-4a6bc7d6e7dd41dd/out/gecko/bindings.rs:1681:117
0:09.30 |
0:09.30 1681 | ...ema_StaticData_close0"] [:: std :: mem :: size_of :: < root :: mozilla :: Variant > () - 80usize] ;
0:09.30 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `16_usize - 80_usize`, which would overflow
0:09.30 error[E0080]: evaluation of constant value failed
0:09.30 --> /Users/jer/mozilla/src/gecko/obj/aarch64-apple-darwin/release/build/gecko-profiler-4a6bc7d6e7dd41dd/out/gecko/bindings.rs:1691:117
0:09.30 |
0:09.30 1691 | ...ema_StaticData_close0"] [:: std :: mem :: size_of :: < root :: mozilla :: Variant > () - 80usize] ;
0:09.30 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `16_usize - 80_usize`, which would overflow
0:09.30 error[E0080]: evaluation of constant value failed
0:09.30 --> /Users/jer/mozilla/src/gecko/obj/aarch64-apple-darwin/release/build/gecko-profiler-4a6bc7d6e7dd41dd/out/gecko/bindings.rs:1697:14
0:09.30 |
0:09.30 1697 | [::std::mem::size_of::<root::mozilla::Maybe>() - 8usize];
0:09.30 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `1_usize - 8_usize`, which would overflow
I noticed that had both these lines:
[::std::mem::size_of::<root::mozilla::Maybe>() - 32usize];
[::std::mem::size_of::<root::mozilla::Maybe>() - 8usize];
so clearly something is going awry.
So I checked the code that is generated with 0.69.4:
#[test]
fn __bindgen_test_layout_Maybe_open0_string_close0_instantiation() {
assert_eq!(
::std::mem::size_of::<root::mozilla::Maybe>(),
32usize,
concat!(
"Size of template specialization: ",
stringify!(root::mozilla::Maybe)
)
);
// <snip>
#[test]
fn __bindgen_test_layout_Maybe_open0_MarkerSchema_GraphColor_close0_instantiation() {
assert_eq!(
::std::mem::size_of::<root::mozilla::Maybe>(),
8usize,
concat!(
"Size of template specialization: ",
stringify!(root::mozilla::Maybe)
)
);
So clearly these tests could never have been correct to begin with. Maybe can't be both of size 8 and 32 at the same time.
But these were tests and I guess we never actually ran them.
Judging from the test names I assume this should actually some kind of generic type?
That's as far as I'll go withthis for now. Maybe someone else can pick this up.
Comment 3•2 years ago
|
||
After talking with Emilio it might be good enough to mark some of those types as opaque. I'll put something up.
Comment 4•2 years ago
|
||
This updates to the latest 0.70.1, which now uses const checks instead
of tests and get rids of a long-standing warning about a unused trait.
Due to the const checks we now have to make some types opaque when
generating bindings in the gecko-profiler.
The ecosystem hasn't upgraded yet, so for now we need to use the usual
re-export shim trick. It compiles.
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Comment 5•2 years ago
|
||
I tried adding more types to make them opaque, but that's a bit of a chase and push to try (because some only seem to happen on x86 or Windows).
So for now I have to abandon that, but maybe someone else is willing to pick this up eventually.
| Assignee | ||
Comment 6•1 year ago
|
||
This will go away once we update to bindgen 0.70 or greater. For now,
though, slap an #[allow(dead_code)] on it to get rid of the warning.
Updated•1 year ago
|
Comment 7•1 year ago
|
||
Comment on attachment 9462920 [details]
Bug 1895950 - [1/1] silence unused HasFloat warning r?glandium!
Revision D236239 was moved to bug 1945218. Setting attachment 9462920 [details] to obsolete.
Description
•