(_, ty::ConstKind::Infer(InferConst::Var(vid))) => {
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
// escaping bound variables here.
if !a.has_escaping_bound_vars() && !b.has_escaping_bound_vars() {
}
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
// escaping bound variables here.
if !a.has_escaping_bound_vars() && !b.has_escaping_bound_vars() {
}
}
}
- 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),
}
}
}
}
}
- 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),
}
}
/// What mode(s) of borrowck should we run? AST? MIR? both?
/// (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:
//
// 1. An opts.borrowck_mode of `BorrowckMode::Migrate` is
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]
pub fn local_crate_exports_generics(self) -> bool {
debug_assert!(self.sess.opts.share_generics());
Ok(sz) => Ok(tcx.mk_ty(ty::Array(t, sz))),
// FIXME(#72219) Implement improved diagnostics for mismatched array
// length?
- Err(err) if relation.tcx().features().const_generics => Err(err),
+ Err(err) if relation.tcx().lazy_normalization() => Err(err),
Err(err) => {
// Check whether the lengths are both concrete/known values,
// but are unequal, for better diagnostics.
}
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
} else {
let constant = constant.super_fold_with(self);
// HACK(eddyb) this provides the correct generics when
// `feature(const_generics)` is enabled, so that const expressions
// 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())
} else {
let parent_node = tcx.hir().get(tcx.hir().get_parent_node(hir_id));