we can get the Session from the TyCtxt
This commit is contained in:
parent
5b89f3fb94
commit
f1f6205145
@ -58,7 +58,7 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls<'a> {
|
||||
|
||||
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 @@ impl<'a> CompilerCalls<'a> for MiriCompilerCalls {
|
||||
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::traits::Reveal;
|
||||
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 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
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 @@ impl<'a, 'b, 'tcx> Visitor<'tcx> for ConstantExtractor<'a, 'b, 'tcx> {
|
||||
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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user