Skip to content
This repository was archived by the owner on Nov 12, 2022. It is now read-only.

Commit c31e326

Browse files
committed
Work around inconsistent padding from different LLVM versions.
1 parent d15b976 commit c31e326

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/conversions.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ use rust::maybe_wrap_value;
4444
use libc;
4545
use num_traits::{Bounded, Zero};
4646
use std::borrow::Cow;
47+
use std::mem;
4748
use std::rc::Rc;
4849
use std::{ptr, slice};
4950

@@ -601,11 +602,18 @@ impl<C: Clone, T: FromJSValConvertible<Config=C>> FromJSValConvertible for Vec<T
601602
return Ok(ConversionResult::Failure("Value is not an object".into()));
602603
}
603604

605+
// Depending on the version of LLVM in use, bindgen can end up including
606+
// a padding field in the ForOfIterator. To support multiple versions of
607+
// LLVM that may not have the same fields as a result, we create an empty
608+
// iterator instance and initialize a non-empty instance using the empty
609+
// instance as a base value.
610+
let zero = mem::zeroed();
604611
let mut iterator = ForOfIterator {
605612
cx_: cx,
606613
iterator: RootedObject::new_unrooted(),
607614
nextMethod: RootedValue::new_unrooted(),
608615
index: ::std::u32::MAX, // NOT_ARRAY
616+
..zero
609617
};
610618
let iterator = ForOfIteratorGuard::new(cx, &mut iterator);
611619
let iterator = &mut *iterator.root;

0 commit comments

Comments
 (0)