Rename has_type_parameters
to requires_monomorphization
This commit is contained in:
parent
a9622dc5c6
commit
15d2759d90
@ -819,13 +819,15 @@ impl<'a, 'gcx, 'tcx> Generics {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn has_type_parameters(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
|
||||
if self.types().count() != 0 {
|
||||
pub fn requires_monomorphization(&self, tcx: TyCtxt<'a, 'gcx, 'tcx>) -> bool {
|
||||
if self.params.iter().any(|p| {
|
||||
if let GenericParam::Type(_) = p { true } else { false }
|
||||
}) {
|
||||
return true;
|
||||
}
|
||||
if let Some(parent_def_id) = self.parent {
|
||||
let parent = tcx.generics_of(parent_def_id);
|
||||
parent.has_type_parameters(tcx)
|
||||
parent.requires_monomorphization(tcx)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
@ -929,7 +929,7 @@ impl<'a, 'b: 'a, 'tcx: 'b> IsolatedEncoder<'a, 'b, 'tcx> {
|
||||
hir::ImplItemKind::Const(..) => true,
|
||||
hir::ImplItemKind::Method(ref sig, _) => {
|
||||
let generics = self.tcx.generics_of(def_id);
|
||||
let needs_inline = (generics.has_type_parameters(self.tcx) ||
|
||||
let needs_inline = (generics.requires_monomorphization(self.tcx) ||
|
||||
tcx.trans_fn_attrs(def_id).requests_inline()) &&
|
||||
!self.metadata_output_only();
|
||||
let is_const_fn = sig.constness == hir::Constness::Const;
|
||||
|
@ -1076,7 +1076,7 @@ impl<'b, 'a, 'v> RootCollector<'b, 'a, 'v> {
|
||||
|
||||
fn item_has_type_parameters<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> bool {
|
||||
let generics = tcx.generics_of(def_id);
|
||||
generics.has_type_parameters(tcx)
|
||||
generics.requires_monomorphization(tcx)
|
||||
}
|
||||
|
||||
fn create_mono_items_for_default_impls<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
|
@ -184,7 +184,7 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
|
||||
// evaluate the promoted and replace the constant with the evaluated result
|
||||
Literal::Promoted { index } => {
|
||||
let generics = self.tcx.generics_of(self.source.def_id);
|
||||
if generics.has_type_parameters(self.tcx) {
|
||||
if generics.requires_monomorphization(self.tcx) {
|
||||
// FIXME: can't handle code with generics
|
||||
return None;
|
||||
}
|
||||
@ -295,7 +295,7 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
|
||||
self.source.def_id
|
||||
};
|
||||
let generics = self.tcx.generics_of(def_id);
|
||||
if generics.has_type_parameters(self.tcx) {
|
||||
if generics.requires_monomorphization(self.tcx) {
|
||||
// FIXME: can't handle code with generics
|
||||
return None;
|
||||
}
|
||||
@ -317,7 +317,7 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
|
||||
self.source.def_id
|
||||
};
|
||||
let generics = self.tcx.generics_of(def_id);
|
||||
if generics.has_type_parameters(self.tcx) {
|
||||
if generics.requires_monomorphization(self.tcx) {
|
||||
// FIXME: can't handle code with generics
|
||||
return None;
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ fn reachable_non_generics_provider<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
}) => {
|
||||
let def_id = tcx.hir.local_def_id(node_id);
|
||||
let generics = tcx.generics_of(def_id);
|
||||
if !generics.has_type_parameters(tcx) &&
|
||||
if !generics.requires_monomorphization(tcx) &&
|
||||
// Functions marked with #[inline] are only ever translated
|
||||
// with "internal" linkage and are never exported.
|
||||
!Instance::mono(tcx, def_id).def.requires_local(tcx) {
|
||||
|
Loading…
Reference in New Issue
Block a user