Logically seperate lazy norm from const_generics
This commit is contained in:
parent
752d8a24d8
commit
6a72ba4c33
@ -164,7 +164,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
|
|||||||
(_, ty::ConstKind::Infer(InferConst::Var(vid))) => {
|
(_, ty::ConstKind::Infer(InferConst::Var(vid))) => {
|
||||||
return self.unify_const_variable(!a_is_expected, vid, a);
|
return self.unify_const_variable(!a_is_expected, vid, a);
|
||||||
}
|
}
|
||||||
(ty::ConstKind::Unevaluated(..), _) if self.tcx.features().const_generics => {
|
(ty::ConstKind::Unevaluated(..), _) if self.tcx.lazy_normalization() => {
|
||||||
// FIXME(#59490): Need to remove the leak check to accomodate
|
// FIXME(#59490): Need to remove the leak check to accomodate
|
||||||
// escaping bound variables here.
|
// escaping bound variables here.
|
||||||
if !a.has_escaping_bound_vars() && !b.has_escaping_bound_vars() {
|
if !a.has_escaping_bound_vars() && !b.has_escaping_bound_vars() {
|
||||||
@ -172,7 +172,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
|
|||||||
}
|
}
|
||||||
return Ok(b);
|
return Ok(b);
|
||||||
}
|
}
|
||||||
(_, ty::ConstKind::Unevaluated(..)) if self.tcx.features().const_generics => {
|
(_, ty::ConstKind::Unevaluated(..)) if self.tcx.lazy_normalization() => {
|
||||||
// FIXME(#59490): Need to remove the leak check to accomodate
|
// FIXME(#59490): Need to remove the leak check to accomodate
|
||||||
// escaping bound variables here.
|
// escaping bound variables here.
|
||||||
if !a.has_escaping_bound_vars() && !b.has_escaping_bound_vars() {
|
if !a.has_escaping_bound_vars() && !b.has_escaping_bound_vars() {
|
||||||
@ -666,7 +666,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::ConstKind::Unevaluated(..) if self.tcx().features().const_generics => Ok(c),
|
ty::ConstKind::Unevaluated(..) if self.tcx().lazy_normalization() => Ok(c),
|
||||||
_ => relate::super_relate_consts(self, c, c),
|
_ => relate::super_relate_consts(self, c, c),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -988,7 +988,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::ConstKind::Unevaluated(..) if self.tcx().features().const_generics => Ok(a),
|
ty::ConstKind::Unevaluated(..) if self.tcx().lazy_normalization() => Ok(a),
|
||||||
_ => relate::super_relate_consts(self, a, a),
|
_ => relate::super_relate_consts(self, a, a),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1339,7 +1339,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
|
|
||||||
/// What mode(s) of borrowck should we run? AST? MIR? both?
|
/// What mode(s) of borrowck should we run? AST? MIR? both?
|
||||||
/// (Also considers the `#![feature(nll)]` setting.)
|
/// (Also considers the `#![feature(nll)]` setting.)
|
||||||
pub fn borrowck_mode(&self) -> BorrowckMode {
|
pub fn borrowck_mode(self) -> BorrowckMode {
|
||||||
// Here are the main constraints we need to deal with:
|
// Here are the main constraints we need to deal with:
|
||||||
//
|
//
|
||||||
// 1. An opts.borrowck_mode of `BorrowckMode::Migrate` is
|
// 1. An opts.borrowck_mode of `BorrowckMode::Migrate` is
|
||||||
@ -1369,6 +1369,13 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
self.sess.opts.borrowck_mode
|
self.sess.opts.borrowck_mode
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// If `true`, we should use lazy normalization for constants, otherwise
|
||||||
|
/// we still evaluate them eagerly.
|
||||||
|
#[inline]
|
||||||
|
pub fn lazy_normalization(self) -> bool {
|
||||||
|
self.features().const_generics
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn local_crate_exports_generics(self) -> bool {
|
pub fn local_crate_exports_generics(self) -> bool {
|
||||||
debug_assert!(self.sess.opts.share_generics());
|
debug_assert!(self.sess.opts.share_generics());
|
||||||
|
@ -433,7 +433,7 @@ pub fn super_relate_tys<R: TypeRelation<'tcx>>(
|
|||||||
Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))),
|
Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))),
|
||||||
// FIXME(#72219) Implement improved diagnostics for mismatched array
|
// FIXME(#72219) Implement improved diagnostics for mismatched array
|
||||||
// length?
|
// length?
|
||||||
Err(err) if relation.tcx().features().const_generics => Err(err),
|
Err(err) if relation.tcx().lazy_normalization() => Err(err),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
// Check whether the lengths are both concrete/known values,
|
// Check whether the lengths are both concrete/known values,
|
||||||
// but are unequal, for better diagnostics.
|
// but are unequal, for better diagnostics.
|
||||||
|
@ -388,7 +388,7 @@ impl<'a, 'b, 'tcx> TypeFolder<'tcx> for AssocTypeNormalizer<'a, 'b, 'tcx> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn fold_const(&mut self, constant: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
fn fold_const(&mut self, constant: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
||||||
if self.selcx.tcx().features().const_generics {
|
if self.selcx.tcx().lazy_normalization() {
|
||||||
constant
|
constant
|
||||||
} else {
|
} else {
|
||||||
let constant = constant.super_fold_with(self);
|
let constant = constant.super_fold_with(self);
|
||||||
|
@ -1173,7 +1173,7 @@ fn generics_of(tcx: TyCtxt<'_>, def_id: DefId) -> ty::Generics {
|
|||||||
// HACK(eddyb) this provides the correct generics when
|
// HACK(eddyb) this provides the correct generics when
|
||||||
// `feature(const_generics)` is enabled, so that const expressions
|
// `feature(const_generics)` is enabled, so that const expressions
|
||||||
// used with const generics, e.g. `Foo<{N+1}>`, can work at all.
|
// used with const generics, e.g. `Foo<{N+1}>`, can work at all.
|
||||||
if tcx.features().const_generics {
|
if tcx.lazy_normalization() {
|
||||||
Some(parent_def_id.to_def_id())
|
Some(parent_def_id.to_def_id())
|
||||||
} else {
|
} else {
|
||||||
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id));
|
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id));
|
||||||
|
Loading…
Reference in New Issue
Block a user