diff options
| author | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-01-18 11:40:53 +0100 |
|---|---|---|
| committer | Oliver Scherer <github35764891676564198441@oli-obk.de> | 2019-01-18 11:40:53 +0100 |
| commit | 1dc4e417fa2a73d5ffa24428df6b7d4dbbf41f4a (patch) | |
| tree | a78cb0aea86cb087d3e1d7c17dc057f05c0f17e7 | |
| parent | daa53a52a2667533d5fe59bfcc5b8614b79c3d31 (diff) | |
| download | rust-1dc4e417fa2a73d5ffa24428df6b7d4dbbf41f4a.tar.gz rust-1dc4e417fa2a73d5ffa24428df6b7d4dbbf41f4a.zip | |
Manually inline a function that was only used once
| -rw-r--r-- | src/librustc/ty/mod.rs | 10 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/eval_context.rs | 10 |
2 files changed, 5 insertions, 15 deletions
diff --git a/src/librustc/ty/mod.rs b/src/librustc/ty/mod.rs index 26b4735d926..2fdcb2681db 100644 --- a/src/librustc/ty/mod.rs +++ b/src/librustc/ty/mod.rs @@ -2946,16 +2946,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> { } } - /// Given the DefId of an item, returns its MIR, borrowed immutably. - /// Returns None if there is no MIR for the DefId - pub fn maybe_optimized_mir(self, did: DefId) -> Option<&'gcx Mir<'gcx>> { - if self.is_mir_available(did) { - Some(self.optimized_mir(did)) - } else { - None - } - } - /// Get the attributes of a definition. pub fn get_attrs(self, did: DefId) -> Attributes<'gcx> { if let Some(id) = self.hir().as_local_node_id(did) { diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 19362b6cfdb..90f7ba761ea 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -265,11 +265,11 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc } trace!("load mir {:?}", instance); match instance { - ty::InstanceDef::Item(def_id) => { - self.tcx.maybe_optimized_mir(def_id).ok_or_else(|| - EvalErrorKind::NoMirFor(self.tcx.item_path_str(def_id)).into() - ) - } + ty::InstanceDef::Item(def_id) => if self.tcx.is_mir_available(did) { + Ok(self.tcx.optimized_mir(did)) + } else { + err!(NoMirFor(self.tcx.item_path_str(def_id))) + }, _ => Ok(self.tcx.instance_mir(instance)), } } |
