Skip to content

Commit 1dc4e41

Browse files
committed
Manually inline a function that was only used once
1 parent daa53a5 commit 1dc4e41

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

src/librustc/ty/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -2946,16 +2946,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
29462946
}
29472947
}
29482948

2949-
/// Given the DefId of an item, returns its MIR, borrowed immutably.
2950-
/// Returns None if there is no MIR for the DefId
2951-
pub fn maybe_optimized_mir(self, did: DefId) -> Option<&'gcx Mir<'gcx>> {
2952-
if self.is_mir_available(did) {
2953-
Some(self.optimized_mir(did))
2954-
} else {
2955-
None
2956-
}
2957-
}
2958-
29592949
/// Get the attributes of a definition.
29602950
pub fn get_attrs(self, did: DefId) -> Attributes<'gcx> {
29612951
if let Some(id) = self.hir().as_local_node_id(did) {

src/librustc_mir/interpret/eval_context.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
265265
}
266266
trace!("load mir {:?}", instance);
267267
match instance {
268-
ty::InstanceDef::Item(def_id) => {
269-
self.tcx.maybe_optimized_mir(def_id).ok_or_else(||
270-
EvalErrorKind::NoMirFor(self.tcx.item_path_str(def_id)).into()
271-
)
272-
}
268+
ty::InstanceDef::Item(def_id) => if self.tcx.is_mir_available(did) {
269+
Ok(self.tcx.optimized_mir(did))
270+
} else {
271+
err!(NoMirFor(self.tcx.item_path_str(def_id)))
272+
},
273273
_ => Ok(self.tcx.instance_mir(instance)),
274274
}
275275
}

0 commit comments

Comments
 (0)