polymorphize: don't normalize self-ty need substs
`characteristic_def_id_of_type` was being invoked during partitioning for self types of impl blocks which had projections that depended on the value of unused generic parameters of a function, resulting in an ICE in the 'generic-names' debuginfo test. If partitioning is enabled and the instance needs substitution then this is now skipped. Signed-off-by: David Wood <david.wood@huawei.com>
This commit is contained in:
parent
76b05531ca
commit
b39e915981
1 changed files with 16 additions and 9 deletions
|
@ -9,7 +9,7 @@ use rustc_middle::middle::exported_symbols::SymbolExportLevel;
|
||||||
use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, Linkage, Visibility};
|
use rustc_middle::mir::mono::{CodegenUnit, CodegenUnitNameBuilder, Linkage, Visibility};
|
||||||
use rustc_middle::mir::mono::{InstantiationMode, MonoItem};
|
use rustc_middle::mir::mono::{InstantiationMode, MonoItem};
|
||||||
use rustc_middle::ty::print::characteristic_def_id_of_type;
|
use rustc_middle::ty::print::characteristic_def_id_of_type;
|
||||||
use rustc_middle::ty::{self, DefIdTree, InstanceDef, TyCtxt};
|
use rustc_middle::ty::{self, fold::TypeFoldable, DefIdTree, InstanceDef, TyCtxt};
|
||||||
use rustc_span::symbol::Symbol;
|
use rustc_span::symbol::Symbol;
|
||||||
|
|
||||||
use super::PartitioningCx;
|
use super::PartitioningCx;
|
||||||
|
@ -300,6 +300,12 @@ fn characteristic_def_id_of_mono_item<'tcx>(
|
||||||
// call it.
|
// call it.
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When polymorphization is enabled, methods which do not depend on their generic
|
||||||
|
// parameters, but the self-type of their impl block do will fail to normalize.
|
||||||
|
if !tcx.sess.opts.debugging_opts.polymorphize
|
||||||
|
|| !instance.definitely_needs_subst(tcx)
|
||||||
|
{
|
||||||
// This is a method within an impl, find out what the self-type is:
|
// This is a method within an impl, find out what the self-type is:
|
||||||
let impl_self_ty = tcx.subst_and_normalize_erasing_regions(
|
let impl_self_ty = tcx.subst_and_normalize_erasing_regions(
|
||||||
instance.substs,
|
instance.substs,
|
||||||
|
@ -310,6 +316,7 @@ fn characteristic_def_id_of_mono_item<'tcx>(
|
||||||
return Some(def_id);
|
return Some(def_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Some(def_id)
|
Some(def_id)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue