we can get the Session from the TyCtxt

上级 5b89f3fb
......@@ -58,7 +58,7 @@ fn build_controller(
let mut mir_map = MirMap { map: mir_map.map.clone() };
run_mir_passes(tcx, &mut mir_map);
bencher.borrow_mut().iter(|| { eval_main(tcx, &mir_map, node_id, state.session); });
bencher.borrow_mut().iter(|| { eval_main(tcx, &mir_map, node_id); });
state.session.abort_if_errors();
});
......
......@@ -75,7 +75,7 @@ fn build_controller(
mir_map_copy.map.insert(def_id, mir_map.map.get(&def_id).unwrap().clone());
}
run_mir_passes(tcx, &mut mir_map_copy);
eval_main(tcx, &mir_map_copy, entry_def_id, memory_size, step_limit, stack_limit, state.session);
eval_main(tcx, &mir_map_copy, entry_def_id, memory_size, step_limit, stack_limit);
state.session.abort_if_errors();
});
......
......@@ -6,7 +6,6 @@
use rustc::ty::layout::{self, Layout, Size};
use rustc::ty::subst::{self, Subst, Substs};
use rustc::ty::{self, Ty, TyCtxt, TypeFoldable};
use rustc::session::Session;
use rustc::util::nodemap::DefIdMap;
use rustc_data_structures::indexed_vec::Idx;
use std::cell::RefCell;
......@@ -32,10 +31,6 @@ pub struct EvalContext<'a, 'tcx: 'a> {
/// The results of the type checker, from rustc.
tcx: TyCtxt<'a, 'tcx, 'tcx>,
/// The Session, from rustc.
/// Used to extract info from other crates
session: &'a Session,
/// A mapping from NodeIds to Mir, from rustc. Only contains MIR for crate-local items.
mir_map: &'a MirMap<'tcx>,
......@@ -159,7 +154,7 @@ pub enum StackPopCleanup {
}
impl<'a, 'tcx> EvalContext<'a, 'tcx> {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir_map: &'a MirMap<'tcx>, memory_size: usize, stack_limit: usize, session: &'a Session) -> Self {
pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir_map: &'a MirMap<'tcx>, memory_size: usize, stack_limit: usize) -> Self {
EvalContext {
tcx: tcx,
mir_map: mir_map,
......@@ -168,7 +163,6 @@ pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, mir_map: &'a MirMap<'tcx>, memory_size:
statics: HashMap::new(),
stack: Vec::new(),
stack_limit: stack_limit,
session: session,
}
}
......@@ -1197,10 +1191,9 @@ pub fn eval_main<'a, 'tcx: 'a>(
memory_size: usize,
step_limit: u64,
stack_limit: usize,
session: &'a Session,
) {
let mir = mir_map.map.get(&def_id).expect("no mir for main function");
let mut ecx = EvalContext::new(tcx, mir_map, memory_size, stack_limit, session);
let mut ecx = EvalContext::new(tcx, mir_map, memory_size, stack_limit);
let substs = subst::Substs::empty(tcx);
let return_ptr = ecx.alloc_ret_ptr(mir.return_ty, substs)
.expect("should at least be able to allocate space for the main function's return value");
......
......@@ -212,7 +212,7 @@ fn visit_lvalue(
bug!("static def id doesn't point to item");
}
} else {
let def = self.ecx.session.cstore.describe_def(def_id).expect("static not found");
let def = self.ecx.tcx.sess.cstore.describe_def(def_id).expect("static not found");
if let hir::def::Def::Static(_, mutable) = def {
self.global_item(def_id, substs, span, !mutable);
} else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册