}
pub trait MonoItemExt<'a, 'tcx>: fmt::Debug {
- fn as_trans_item(&self) -> &MonoItem<'tcx>;
+ fn as_mono_item(&self) -> &MonoItem<'tcx>;
fn instantiation_mode(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>)
tcx.sess.opts.optimize != OptLevel::No
});
- match *self.as_trans_item() {
+ match *self.as_mono_item() {
MonoItem::Fn(ref instance) => {
// If this function isn't inlined or otherwise has explicit
// linkage, then we'll be creating a globally shared version.
}
fn explicit_linkage(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Linkage> {
- let def_id = match *self.as_trans_item() {
+ let def_id = match *self.as_mono_item() {
MonoItem::Fn(ref instance) => instance.def_id(),
MonoItem::Static(node_id) => tcx.hir.local_def_id(node_id),
MonoItem::GlobalAsm(..) => return None,
/// which will never be accessed) in its place.
fn is_instantiable(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> bool {
debug!("is_instantiable({:?})", self);
- let (def_id, substs) = match *self.as_trans_item() {
+ let (def_id, substs) = match *self.as_mono_item() {
MonoItem::Fn(ref instance) => (instance.def_id(), instance.substs),
MonoItem::Static(node_id) => (tcx.hir.local_def_id(node_id), Substs::empty()),
// global asm never has predicates
fn to_string(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> String {
let hir_map = &tcx.hir;
- return match *self.as_trans_item() {
+ return match *self.as_mono_item() {
MonoItem::Fn(instance) => {
to_string_internal(tcx, "fn ", instance)
},
}
impl<'a, 'tcx> MonoItemExt<'a, 'tcx> for MonoItem<'tcx> {
- fn as_trans_item(&self) -> &MonoItem<'tcx> {
+ fn as_mono_item(&self) -> &MonoItem<'tcx> {
self
}
}
self.to_raw_string(),
ccx.codegen_unit().name());
- match *self.as_trans_item() {
+ match *self.as_mono_item() {
MonoItem::Static(node_id) => {
let tcx = ccx.tcx();
let item = tcx.hir.expect_item(node_id);
debug!("symbol {}", &symbol_name);
- match *self.as_trans_item() {
+ match *self.as_mono_item() {
MonoItem::Static(node_id) => {
predefine_static(ccx, node_id, linkage, visibility, &symbol_name);
}
}
fn symbol_name(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> ty::SymbolName {
- match *self.as_trans_item() {
+ match *self.as_mono_item() {
MonoItem::Fn(instance) => tcx.symbol_name(instance),
MonoItem::Static(node_id) => {
let def_id = tcx.hir.local_def_id(node_id);
}
fn local_span(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Option<Span> {
- match *self.as_trans_item() {
+ match *self.as_mono_item() {
MonoItem::Fn(Instance { def, .. }) => {
tcx.hir.as_local_node_id(def.def_id())
}
}
fn is_generic_fn(&self) -> bool {
- match *self.as_trans_item() {
+ match *self.as_mono_item() {
MonoItem::Fn(ref instance) => {
instance.substs.types().next().is_some()
}
}
fn to_raw_string(&self) -> String {
- match *self.as_trans_item() {
+ match *self.as_mono_item() {
MonoItem::Fn(instance) => {
format!("Fn({:?}, {})",
instance.def,