Only generate JS null checks in debug mode

In non-debug mode Rust is already checking these pointers, so let's only
generate the relevant code in debug mode.
This commit is contained in:
Alex Crichton
2018-09-21 15:17:19 -07:00
parent 727cfc3bb5
commit ab3688d01a
4 changed files with 14 additions and 9 deletions

View File

@ -5,14 +5,16 @@ const useMoved = () => {
const apple = new wasm.Fruit('apple');
apple.name();
wasm.eat(apple);
assert.throws(() => apple.name(), /Attempt to use a moved value/);
assert.throws(() => apple.name(),
/Attempt to use a moved value|null pointer passed to rust/);
};
const moveMoved = () => {
const pear = new wasm.Fruit('pear');
pear.name();
wasm.eat(pear);
assert.throws(() => wasm.eat(pear), /Attempt to use a moved value/);
assert.throws(() => wasm.eat(pear),
/Attempt to use a moved value|null pointer passed to rust/);
};
exports.js_works = () => {