Skip to content

Commit fc9dfca

Browse files
trans/metadata: Remove obsolete CrateStore::can_have_local_instance()
1 parent 622730c commit fc9dfca

File tree

4 files changed

+7
-50
lines changed

4 files changed

+7
-50
lines changed

src/librustc/middle/cstore.rs

-8
Original file line numberDiff line numberDiff line change
@@ -259,11 +259,6 @@ pub trait CrateStore<'tcx> {
259259
fn get_item_mir<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> Mir<'tcx>;
260260
fn is_item_mir_available(&self, def: DefId) -> bool;
261261

262-
/// Take a look if we need to inline or monomorphize this. If so, we
263-
/// will emit code for this item in the local crate, and thus
264-
/// create a translation item for it.
265-
fn can_have_local_instance<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> bool;
266-
267262
// This is basically a 1-based range of ints, which is a little
268263
// silly - I may fix that.
269264
fn crates(&self) -> Vec<CrateNum>;
@@ -438,9 +433,6 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
438433
fn is_item_mir_available(&self, def: DefId) -> bool {
439434
bug!("is_item_mir_available")
440435
}
441-
fn can_have_local_instance<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> bool {
442-
bug!("can_have_local_instance")
443-
}
444436

445437
// This is basically a 1-based range of ints, which is a little
446438
// silly - I may fix that.

src/librustc_metadata/cstore_impl.rs

-9
Original file line numberDiff line numberDiff line change
@@ -470,15 +470,6 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
470470
self.get_crate_data(def.krate).is_item_mir_available(def.index)
471471
}
472472

473-
fn can_have_local_instance<'a>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId) -> bool {
474-
if def.is_local() {
475-
true
476-
} else {
477-
self.dep_graph.read(DepNode::MetaData(def));
478-
self.get_crate_data(def.krate).can_have_local_instance(tcx, def.index)
479-
}
480-
}
481-
482473
fn crates(&self) -> Vec<CrateNum>
483474
{
484475
let mut result = vec![];

src/librustc_metadata/decoder.rs

+6-32
Original file line numberDiff line numberDiff line change
@@ -445,14 +445,6 @@ impl<'tcx> EntryKind<'tcx> {
445445
EntryKind::Closure(_) => return None,
446446
})
447447
}
448-
fn is_const_fn(&self, meta: &CrateMetadata) -> bool {
449-
let constness = match *self {
450-
EntryKind::Method(data) => data.decode(meta).fn_data.constness,
451-
EntryKind::Fn(data) => data.decode(meta).constness,
452-
_ => hir::Constness::NotConst,
453-
};
454-
constness == hir::Constness::Const
455-
}
456448
}
457449

458450
impl<'a, 'tcx> CrateMetadata {
@@ -804,29 +796,6 @@ impl<'a, 'tcx> CrateMetadata {
804796
self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some()
805797
}
806798

807-
pub fn can_have_local_instance(&self,
808-
tcx: TyCtxt<'a, 'tcx, 'tcx>,
809-
id: DefIndex) -> bool {
810-
self.maybe_entry(id).map_or(false, |item| {
811-
let item = item.decode(self);
812-
// if we don't have a MIR, then this item was never meant to be locally instantiated
813-
// or we have a bug in the metadata serialization
814-
item.mir.is_some() && (
815-
// items with generics always can have local instances if monomorphized
816-
item.generics.map_or(false, |generics| {
817-
let generics = generics.decode((self, tcx));
818-
generics.parent_types != 0 || !generics.types.is_empty()
819-
}) ||
820-
match item.kind {
821-
EntryKind::Closure(_) => true,
822-
_ => false,
823-
} ||
824-
item.kind.is_const_fn(self) ||
825-
attr::requests_inline(&self.get_attributes(&item))
826-
)
827-
})
828-
}
829-
830799
pub fn maybe_get_item_mir(&self,
831800
tcx: TyCtxt<'a, 'tcx, 'tcx>,
832801
id: DefIndex)
@@ -1043,7 +1012,12 @@ impl<'a, 'tcx> CrateMetadata {
10431012
}
10441013

10451014
pub fn is_const_fn(&self, id: DefIndex) -> bool {
1046-
self.entry(id).kind.is_const_fn(self)
1015+
let constness = match self.entry(id).kind {
1016+
EntryKind::Method(data) => data.decode(self).fn_data.constness,
1017+
EntryKind::Fn(data) => data.decode(self).constness,
1018+
_ => hir::Constness::NotConst,
1019+
};
1020+
constness == hir::Constness::Const
10471021
}
10481022

10491023
pub fn is_foreign_item(&self, id: DefIndex) -> bool {

src/librustc_trans/collector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
698698
// crate
699699
false
700700
} else {
701-
if !tcx.sess.cstore.can_have_local_instance(tcx, def_id) {
701+
if !tcx.sess.cstore.is_item_mir_available(def_id) {
702702
bug!("Cannot create local trans-item for {:?}", def_id)
703703
}
704704
true

0 commit comments

Comments
 (0)