Use try_from instead of the cast crate.

Now that `try_from` is in stable Rust, we can use it here.
This commit is contained in:
Dan Gohman
2019-05-31 09:51:11 -07:00
committed by Benjamin Bouvier
parent fbaffa2c04
commit da1baf7481
3 changed files with 4 additions and 4 deletions

View File

@@ -11,7 +11,7 @@ use crate::translation_utils::{
DefinedFuncIndex, FuncIndex, Global, GlobalIndex, Memory, MemoryIndex, SignatureIndex, Table,
TableIndex,
};
use cast;
use core::convert::TryFrom;
use cranelift_codegen::cursor::FuncCursor;
use cranelift_codegen::ir::immediates::{Offset32, Uimm64};
use cranelift_codegen::ir::types::*;
@@ -196,7 +196,7 @@ impl<'dummy_environment> FuncEnvironment for DummyFuncEnvironment<'dummy_environ
index: GlobalIndex,
) -> WasmResult<GlobalVariable> {
// Just create a dummy `vmctx` global.
let offset = cast::i32((index.index() * 8) + 8).unwrap().into();
let offset = i32::try_from((index.index() * 8) + 8).unwrap().into();
let vmctx = func.create_global_value(ir::GlobalValueData::VMContext {});
Ok(GlobalVariable::Memory {
gv: vmctx,