Auto merge of #104063 - compiler-errors:ct-norm-unless, r=jackh726
Don't normalize constants unless they need normalization Maybe makes normalization a bit faster when we have many constants in a type r? `@ghost`
This commit is contained in:
commit
ddfe1e87f7
2 changed files with 5 additions and 1 deletions
|
@ -647,7 +647,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
|
||||||
#[instrument(skip(self), level = "debug")]
|
#[instrument(skip(self), level = "debug")]
|
||||||
fn fold_const(&mut self, constant: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
fn fold_const(&mut self, constant: ty::Const<'tcx>) -> ty::Const<'tcx> {
|
||||||
let tcx = self.selcx.tcx();
|
let tcx = self.selcx.tcx();
|
||||||
if tcx.lazy_normalization() {
|
if tcx.lazy_normalization() || !needs_normalization(&constant, self.param_env.reveal()) {
|
||||||
constant
|
constant
|
||||||
} else {
|
} else {
|
||||||
let constant = constant.super_fold_with(self);
|
let constant = constant.super_fold_with(self);
|
||||||
|
|
|
@ -353,6 +353,10 @@ impl<'cx, 'tcx> FallibleTypeFolder<'tcx> for QueryNormalizer<'cx, 'tcx> {
|
||||||
&mut self,
|
&mut self,
|
||||||
constant: ty::Const<'tcx>,
|
constant: ty::Const<'tcx>,
|
||||||
) -> Result<ty::Const<'tcx>, Self::Error> {
|
) -> Result<ty::Const<'tcx>, Self::Error> {
|
||||||
|
if !needs_normalization(&constant, self.param_env.reveal()) {
|
||||||
|
return Ok(constant);
|
||||||
|
}
|
||||||
|
|
||||||
let constant = constant.try_super_fold_with(self)?;
|
let constant = constant.try_super_fold_with(self)?;
|
||||||
debug!(?constant, ?self.param_env);
|
debug!(?constant, ?self.param_env);
|
||||||
Ok(crate::traits::project::with_replaced_escaping_bound_vars(
|
Ok(crate::traits::project::with_replaced_escaping_bound_vars(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue