From 64c3d8a7c25222c0fa3603d8cb030b020e2901d8 Mon Sep 17 00:00:00 2001 From: Jan-Erik Rediger Date: Wed, 8 Jun 2016 10:55:00 +0200 Subject: [PATCH] Update code to work with nightly 2016-06-04 --- README.md | 2 ++ src/bin/mir2wasm.rs | 2 +- src/monomorphize.rs | 10 +++++----- src/trans.rs | 10 +++++----- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index c6b81a1780..81da2de02f 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ An experimental compiler from [Rust] to [WebAssembly], based on rustc + Rust [MI I recommend that you install [rustup] and then use it to install the current rustc nightly version: +**Tested with nightly 2016-06-04** + ```sh git clone https://github.com/brson/mir2wasm.git cd mir2wasm diff --git a/src/bin/mir2wasm.rs b/src/bin/mir2wasm.rs index c76e81ad0a..701ea0edcd 100644 --- a/src/bin/mir2wasm.rs +++ b/src/bin/mir2wasm.rs @@ -28,7 +28,7 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls { control.after_analysis.stop = rustc_driver::Compilation::Stop; control.after_analysis.callback = Box::new(|state| { state.session.abort_if_errors(); - trans::trans_crate(state.tcx.unwrap(), state.mir_map.unwrap()) + trans::trans_crate(&state.tcx.unwrap(), state.mir_map.unwrap()) .unwrap(); // FIXME }); diff --git a/src/monomorphize.rs b/src/monomorphize.rs index 53846b2afe..33ff5c94fd 100644 --- a/src/monomorphize.rs +++ b/src/monomorphize.rs @@ -1,13 +1,13 @@ use rustc::ty::subst::{Subst, Substs}; use rustc::ty::{TyCtxt, TypeFoldable}; -use rustc::infer::normalize_associated_type; +use rustc::infer::TransNormalize; -pub fn apply_param_substs<'tcx,T>(tcx: &TyCtxt<'tcx>, +pub fn apply_param_substs<'a, 'tcx,T>(tcx: &TyCtxt<'a, 'tcx, 'tcx>, param_substs: &Substs<'tcx>, value: &T) -> T - where T : TypeFoldable<'tcx> + where T : TypeFoldable<'tcx> + TransNormalize<'tcx> { - let substituted = value.subst(tcx, param_substs); - normalize_associated_type(tcx, &substituted) + let substituted = value.subst(*tcx, param_substs); + tcx.normalize_associated_type(&substituted) } diff --git a/src/trans.rs b/src/trans.rs index bcf55e7d52..fc407ed4f1 100644 --- a/src/trans.rs +++ b/src/trans.rs @@ -16,7 +16,7 @@ use std::collections::HashMap; use binaryen::*; use monomorphize; -pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>, +pub fn trans_crate<'a, 'tcx>(tcx: &TyCtxt<'a, 'tcx, 'tcx>, mir_map: &MirMap<'tcx>) -> Result<()> { let _ignore = tcx.dep_graph.in_ignore(); @@ -40,7 +40,7 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>, } struct BinaryenModuleCtxt<'v, 'tcx: 'v> { - tcx: &'v TyCtxt<'tcx>, + tcx: &'v TyCtxt<'v, 'tcx, 'tcx>, mir_map: &'v MirMap<'tcx>, module: BinaryenModuleRef, fun_types: HashMap, BinaryenFunctionTypeRef>, @@ -84,7 +84,7 @@ impl<'v, 'tcx> Visitor<'v> for BinaryenModuleCtxt<'v, 'tcx> { } struct BinaryenFnCtxt<'v, 'tcx: 'v> { - tcx: &'v TyCtxt<'tcx>, + tcx: &'v TyCtxt<'v, 'tcx, 'tcx>, mir_map: &'v MirMap<'tcx>, mir: &'v Mir<'tcx>, did: DefId, @@ -316,8 +316,8 @@ impl<'v, 'tcx: 'v> BinaryenFnCtxt<'v, 'tcx> { match *operand { Operand::Consume(ref lvalue) => { let (i, _) = self.trans_lval(lvalue); - let lval_ty = self.mir.lvalue_ty(self.tcx, lvalue); - let t = lval_ty.to_ty(self.tcx); + let lval_ty = self.mir.lvalue_ty(*self.tcx, lvalue); + let t = lval_ty.to_ty(*self.tcx); let t = rust_ty_to_binaryen(t); unsafe { BinaryenGetLocal(self.module, i, t) } }