Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function pointers #21

Merged
merged 10 commits into from
Jun 13, 2016
3 changes: 2 additions & 1 deletion src/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
}

fn load_mir(&self, def_id: DefId) -> CachedMir<'a, 'tcx> {
use rustc_trans::back::symbol_names::def_id_to_string;
match self.tcx.map.as_local_node_id(def_id) {
Some(node_id) => CachedMir::Ref(self.mir_map.map.get(&node_id).unwrap()),
None => {
Expand All @@ -292,7 +293,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {

let cs = &self.tcx.sess.cstore;
let mir = cs.maybe_get_item_mir(self.tcx, def_id).unwrap_or_else(|| {
panic!("no mir for {:?}", def_id);
panic!("no mir for `{}`", def_id_to_string(self.tcx, def_id));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I just didn't know this was possible. 👍

});
let cached = Rc::new(mir);
mir_cache.insert(def_id, cached.clone());
Expand Down
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// From rustc.
#[macro_use] extern crate rustc;
extern crate rustc_mir;
extern crate rustc_trans;
extern crate syntax;
#[macro_use] extern crate log;
extern crate log_settings;
Expand Down
2 changes: 1 addition & 1 deletion tests/run-fail/inception.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// error-pattern:no mir for DefId
// error-pattern:no mir for `env_logger/

use std::env;
use std::process::{Command, Output};
Expand Down