Rename ConstValue::Infer(InferConst::Canonical(..))
to ConstValue::Bound(..)
This commit is contained in:
parent
10f12fe3e7
commit
e9c2685167
17 changed files with 47 additions and 64 deletions
|
@ -468,7 +468,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
|
||||||
ConstValue::Infer(InferConst::Fresh(_)) => {
|
ConstValue::Infer(InferConst::Fresh(_)) => {
|
||||||
bug!("encountered a fresh const during canonicalization")
|
bug!("encountered a fresh const during canonicalization")
|
||||||
}
|
}
|
||||||
ConstValue::Infer(InferConst::Canonical(debruijn, _)) => {
|
ConstValue::Bound(debruijn, _) => {
|
||||||
if debruijn >= self.binder_index {
|
if debruijn >= self.binder_index {
|
||||||
bug!("escaping bound type during canonicalization")
|
bug!("escaping bound type during canonicalization")
|
||||||
} else {
|
} else {
|
||||||
|
@ -700,7 +700,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
|
||||||
let var = self.canonical_var(info, const_var.into());
|
let var = self.canonical_var(info, const_var.into());
|
||||||
self.tcx().mk_const(
|
self.tcx().mk_const(
|
||||||
ty::Const {
|
ty::Const {
|
||||||
val: ConstValue::Infer(InferConst::Canonical(self.binder_index, var.into())),
|
val: ConstValue::Bound(self.binder_index, var.into()),
|
||||||
ty: self.fold_ty(const_var.ty),
|
ty: self.fold_ty(const_var.ty),
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -33,7 +33,7 @@ use std::ops::Index;
|
||||||
use syntax::source_map::Span;
|
use syntax::source_map::Span;
|
||||||
use crate::ty::fold::TypeFoldable;
|
use crate::ty::fold::TypeFoldable;
|
||||||
use crate::ty::subst::GenericArg;
|
use crate::ty::subst::GenericArg;
|
||||||
use crate::ty::{self, BoundVar, InferConst, Lift, List, Region, TyCtxt};
|
use crate::ty::{self, BoundVar, Lift, List, Region, TyCtxt};
|
||||||
|
|
||||||
mod canonicalizer;
|
mod canonicalizer;
|
||||||
|
|
||||||
|
@ -510,9 +510,7 @@ impl<'tcx> CanonicalVarValues<'tcx> {
|
||||||
GenericArgKind::Const(ct) => {
|
GenericArgKind::Const(ct) => {
|
||||||
tcx.mk_const(ty::Const {
|
tcx.mk_const(ty::Const {
|
||||||
ty: ct.ty,
|
ty: ct.ty,
|
||||||
val: ConstValue::Infer(
|
val: ConstValue::Bound(ty::INNERMOST, ty::BoundVar::from_u32(i)),
|
||||||
InferConst::Canonical(ty::INNERMOST, ty::BoundVar::from_u32(i))
|
|
||||||
),
|
|
||||||
}).into()
|
}).into()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::traits::TraitEngine;
|
||||||
use crate::traits::{Obligation, ObligationCause, PredicateObligation};
|
use crate::traits::{Obligation, ObligationCause, PredicateObligation};
|
||||||
use crate::ty::fold::TypeFoldable;
|
use crate::ty::fold::TypeFoldable;
|
||||||
use crate::ty::subst::{GenericArg, GenericArgKind};
|
use crate::ty::subst::{GenericArg, GenericArgKind};
|
||||||
use crate::ty::{self, BoundVar, InferConst, Ty, TyCtxt};
|
use crate::ty::{self, BoundVar, Ty, TyCtxt};
|
||||||
use crate::util::captures::Captures;
|
use crate::util::captures::Captures;
|
||||||
|
|
||||||
impl<'tcx> InferCtxtBuilder<'tcx> {
|
impl<'tcx> InferCtxtBuilder<'tcx> {
|
||||||
|
@ -493,10 +493,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GenericArgKind::Const(result_value) => {
|
GenericArgKind::Const(result_value) => {
|
||||||
if let ty::Const {
|
if let ty::Const { val: ConstValue::Bound(debrujin, b), .. } = result_value {
|
||||||
val: ConstValue::Infer(InferConst::Canonical(debrujin, b)),
|
|
||||||
..
|
|
||||||
} = result_value {
|
|
||||||
// ...in which case we would set `canonical_vars[0]` to `Some(const X)`.
|
// ...in which case we would set `canonical_vars[0]` to `Some(const X)`.
|
||||||
|
|
||||||
// We only allow a `ty::INNERMOST` index in substitutions.
|
// We only allow a `ty::INNERMOST` index in substitutions.
|
||||||
|
|
|
@ -252,7 +252,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
|
||||||
return ct;
|
return ct;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstValue::Infer(ty::InferConst::Canonical(..)) |
|
ConstValue::Bound(..) |
|
||||||
ConstValue::Placeholder(_) => {
|
ConstValue::Placeholder(_) => {
|
||||||
bug!("unexpected const {:?}", ct)
|
bug!("unexpected const {:?}", ct)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ use crate::ty::error::TypeError;
|
||||||
use crate::ty::fold::{TypeFoldable, TypeVisitor};
|
use crate::ty::fold::{TypeFoldable, TypeVisitor};
|
||||||
use crate::ty::relate::{self, Relate, RelateResult, TypeRelation};
|
use crate::ty::relate::{self, Relate, RelateResult, TypeRelation};
|
||||||
use crate::ty::subst::GenericArg;
|
use crate::ty::subst::GenericArg;
|
||||||
use crate::ty::{self, Ty, TyCtxt, InferConst};
|
use crate::ty::{self, Ty, TyCtxt};
|
||||||
use crate::mir::interpret::ConstValue;
|
use crate::mir::interpret::ConstValue;
|
||||||
use rustc_data_structures::fx::FxHashMap;
|
use rustc_data_structures::fx::FxHashMap;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
|
@ -618,7 +618,7 @@ where
|
||||||
a: &'tcx ty::Const<'tcx>,
|
a: &'tcx ty::Const<'tcx>,
|
||||||
b: &'tcx ty::Const<'tcx>,
|
b: &'tcx ty::Const<'tcx>,
|
||||||
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
|
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
|
||||||
if let ty::Const { val: ConstValue::Infer(InferConst::Canonical(_, _)), .. } = a {
|
if let ty::Const { val: ConstValue::Bound(..), .. } = a {
|
||||||
// FIXME(const_generics): I'm unsure how this branch should actually be handled,
|
// FIXME(const_generics): I'm unsure how this branch should actually be handled,
|
||||||
// so this is probably not correct.
|
// so this is probably not correct.
|
||||||
self.infcx.super_combine_consts(self, a, b)
|
self.infcx.super_combine_consts(self, a, b)
|
||||||
|
@ -993,7 +993,7 @@ where
|
||||||
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
|
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
|
||||||
debug!("TypeGeneralizer::consts(a={:?})", a);
|
debug!("TypeGeneralizer::consts(a={:?})", a);
|
||||||
|
|
||||||
if let ty::Const { val: ConstValue::Infer(InferConst::Canonical(_, _)), .. } = a {
|
if let ty::Const { val: ConstValue::Bound(..), .. } = a {
|
||||||
bug!(
|
bug!(
|
||||||
"unexpected inference variable encountered in NLL generalization: {:?}",
|
"unexpected inference variable encountered in NLL generalization: {:?}",
|
||||||
a
|
a
|
||||||
|
|
|
@ -5,6 +5,7 @@ use rustc_apfloat::{Float, ieee::{Double, Single}};
|
||||||
use crate::ty::{Ty, InferConst, ParamConst, layout::{HasDataLayout, Size}, subst::SubstsRef};
|
use crate::ty::{Ty, InferConst, ParamConst, layout::{HasDataLayout, Size}, subst::SubstsRef};
|
||||||
use crate::ty::PlaceholderConst;
|
use crate::ty::PlaceholderConst;
|
||||||
use crate::hir::def_id::DefId;
|
use crate::hir::def_id::DefId;
|
||||||
|
use crate::ty::{BoundVar, DebruijnIndex};
|
||||||
|
|
||||||
use super::{InterpResult, Pointer, PointerArithmetic, Allocation, AllocId, sign_extend, truncate};
|
use super::{InterpResult, Pointer, PointerArithmetic, Allocation, AllocId, sign_extend, truncate};
|
||||||
|
|
||||||
|
@ -28,6 +29,9 @@ pub enum ConstValue<'tcx> {
|
||||||
/// Infer the value of the const.
|
/// Infer the value of the const.
|
||||||
Infer(InferConst<'tcx>),
|
Infer(InferConst<'tcx>),
|
||||||
|
|
||||||
|
/// Bound const variable, used only when preparing a trait query.
|
||||||
|
Bound(DebruijnIndex, BoundVar),
|
||||||
|
|
||||||
/// A placeholder const - universally quantified higher-ranked const.
|
/// A placeholder const - universally quantified higher-ranked const.
|
||||||
Placeholder(PlaceholderConst),
|
Placeholder(PlaceholderConst),
|
||||||
|
|
||||||
|
@ -66,8 +70,9 @@ impl<'tcx> ConstValue<'tcx> {
|
||||||
match *self {
|
match *self {
|
||||||
ConstValue::Param(_) |
|
ConstValue::Param(_) |
|
||||||
ConstValue::Infer(_) |
|
ConstValue::Infer(_) |
|
||||||
|
ConstValue::Bound(..) |
|
||||||
ConstValue::Placeholder(_) |
|
ConstValue::Placeholder(_) |
|
||||||
ConstValue::ByRef{ .. } |
|
ConstValue::ByRef { .. } |
|
||||||
ConstValue::Unevaluated(..) |
|
ConstValue::Unevaluated(..) |
|
||||||
ConstValue::Slice { .. } => None,
|
ConstValue::Slice { .. } => None,
|
||||||
ConstValue::Scalar(val) => Some(val),
|
ConstValue::Scalar(val) => Some(val),
|
||||||
|
|
|
@ -882,7 +882,7 @@ impl CanonicalUserType<'tcx> {
|
||||||
},
|
},
|
||||||
|
|
||||||
GenericArgKind::Const(ct) => match ct.val {
|
GenericArgKind::Const(ct) => match ct.val {
|
||||||
ConstValue::Infer(InferConst::Canonical(debruijn, b)) => {
|
ConstValue::Bound(debruijn, b) => {
|
||||||
// We only allow a `ty::INNERMOST` index in substitutions.
|
// We only allow a `ty::INNERMOST` index in substitutions.
|
||||||
assert_eq!(debruijn, ty::INNERMOST);
|
assert_eq!(debruijn, ty::INNERMOST);
|
||||||
cvar == b
|
cvar == b
|
||||||
|
|
|
@ -240,10 +240,10 @@ impl FlagComputation {
|
||||||
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES | TypeFlags::HAS_CT_INFER);
|
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES | TypeFlags::HAS_CT_INFER);
|
||||||
match infer {
|
match infer {
|
||||||
InferConst::Fresh(_) => {}
|
InferConst::Fresh(_) => {}
|
||||||
InferConst::Canonical(debruijn, _) => self.add_binder(debruijn),
|
|
||||||
InferConst::Var(_) => self.add_flags(TypeFlags::KEEP_IN_LOCAL_TCX),
|
InferConst::Var(_) => self.add_flags(TypeFlags::KEEP_IN_LOCAL_TCX),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ConstValue::Bound(debruijn, _) => self.add_binder(debruijn),
|
||||||
ConstValue::Param(_) => {
|
ConstValue::Param(_) => {
|
||||||
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES | TypeFlags::HAS_PARAMS);
|
self.add_flags(TypeFlags::HAS_FREE_LOCAL_NAMES | TypeFlags::HAS_PARAMS);
|
||||||
}
|
}
|
||||||
|
|
|
@ -521,10 +521,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for BoundVarReplacer<'a, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
||||||
if let ty::Const {
|
if let ty::Const { val: ConstValue::Bound(debruijn, bound_const), ty } = *ct {
|
||||||
val: ConstValue::Infer(ty::InferConst::Canonical(debruijn, bound_const)),
|
|
||||||
ty,
|
|
||||||
} = *ct {
|
|
||||||
if debruijn == self.current_index {
|
if debruijn == self.current_index {
|
||||||
let fld_c = &mut self.fld_c;
|
let fld_c = &mut self.fld_c;
|
||||||
let ct = fld_c(bound_const, ty);
|
let ct = fld_c(bound_const, ty);
|
||||||
|
@ -570,7 +567,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
// identity for bound types and consts
|
// identity for bound types and consts
|
||||||
let fld_t = |bound_ty| self.mk_ty(ty::Bound(ty::INNERMOST, bound_ty));
|
let fld_t = |bound_ty| self.mk_ty(ty::Bound(ty::INNERMOST, bound_ty));
|
||||||
let fld_c = |bound_ct, ty| {
|
let fld_c = |bound_ct, ty| {
|
||||||
self.mk_const_infer(ty::InferConst::Canonical(ty::INNERMOST, bound_ct), ty)
|
self.mk_const(ty::Const {
|
||||||
|
val: ConstValue::Bound(ty::INNERMOST, bound_ct),
|
||||||
|
ty,
|
||||||
|
})
|
||||||
};
|
};
|
||||||
self.replace_escaping_bound_vars(value.skip_binder(), fld_r, fld_t, fld_c)
|
self.replace_escaping_bound_vars(value.skip_binder(), fld_r, fld_t, fld_c)
|
||||||
}
|
}
|
||||||
|
@ -802,10 +802,7 @@ impl TypeFolder<'tcx> for Shifter<'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
fn fold_const(&mut self, ct: &'tcx ty::Const<'tcx>) -> &'tcx ty::Const<'tcx> {
|
||||||
if let ty::Const {
|
if let ty::Const { val: ConstValue::Bound(debruijn, bound_ct), ty } = *ct {
|
||||||
val: ConstValue::Infer(ty::InferConst::Canonical(debruijn, bound_const)),
|
|
||||||
ty,
|
|
||||||
} = *ct {
|
|
||||||
if self.amount == 0 || debruijn < self.current_index {
|
if self.amount == 0 || debruijn < self.current_index {
|
||||||
ct
|
ct
|
||||||
} else {
|
} else {
|
||||||
|
@ -816,7 +813,10 @@ impl TypeFolder<'tcx> for Shifter<'tcx> {
|
||||||
debruijn.shifted_out(self.amount)
|
debruijn.shifted_out(self.amount)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
self.tcx.mk_const_infer(ty::InferConst::Canonical(debruijn, bound_const), ty)
|
self.tcx.mk_const(ty::Const {
|
||||||
|
val: ConstValue::Bound(debruijn, bound_ct),
|
||||||
|
ty,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ct.super_fold_with(self)
|
ct.super_fold_with(self)
|
||||||
|
@ -920,8 +920,7 @@ impl<'tcx> TypeVisitor<'tcx> for HasEscapingVarsVisitor {
|
||||||
// const, as it has types/regions embedded in a lot of other
|
// const, as it has types/regions embedded in a lot of other
|
||||||
// places.
|
// places.
|
||||||
match ct.val {
|
match ct.val {
|
||||||
ConstValue::Infer(ty::InferConst::Canonical(debruijn, _))
|
ConstValue::Bound(debruijn, _) if debruijn >= self.outer_index => true,
|
||||||
if debruijn >= self.outer_index => true,
|
|
||||||
_ => ct.super_visit_with(self),
|
_ => ct.super_visit_with(self),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1379,27 +1379,23 @@ impl<'tcx> TypeFoldable<'tcx> for &'tcx ty::Const<'tcx> {
|
||||||
impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> {
|
impl<'tcx> TypeFoldable<'tcx> for ConstValue<'tcx> {
|
||||||
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
fn super_fold_with<F: TypeFolder<'tcx>>(&self, folder: &mut F) -> Self {
|
||||||
match *self {
|
match *self {
|
||||||
ConstValue::ByRef { alloc, offset } =>
|
|
||||||
ConstValue::ByRef { alloc, offset },
|
|
||||||
ConstValue::Infer(ic) => ConstValue::Infer(ic.fold_with(folder)),
|
ConstValue::Infer(ic) => ConstValue::Infer(ic.fold_with(folder)),
|
||||||
ConstValue::Param(p) => ConstValue::Param(p.fold_with(folder)),
|
ConstValue::Param(p) => ConstValue::Param(p.fold_with(folder)),
|
||||||
ConstValue::Placeholder(p) => ConstValue::Placeholder(p),
|
|
||||||
ConstValue::Scalar(a) => ConstValue::Scalar(a),
|
|
||||||
ConstValue::Slice { data, start, end } => ConstValue::Slice { data, start, end },
|
|
||||||
ConstValue::Unevaluated(did, substs)
|
ConstValue::Unevaluated(did, substs)
|
||||||
=> ConstValue::Unevaluated(did, substs.fold_with(folder)),
|
=> ConstValue::Unevaluated(did, substs.fold_with(folder)),
|
||||||
|
ConstValue::ByRef { .. } | ConstValue::Bound(..) | ConstValue::Placeholder(..)
|
||||||
|
| ConstValue::Scalar(..) | ConstValue::Slice { .. } => *self,
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
fn super_visit_with<V: TypeVisitor<'tcx>>(&self, visitor: &mut V) -> bool {
|
||||||
match *self {
|
match *self {
|
||||||
ConstValue::ByRef { .. } => false,
|
|
||||||
ConstValue::Infer(ic) => ic.visit_with(visitor),
|
ConstValue::Infer(ic) => ic.visit_with(visitor),
|
||||||
ConstValue::Param(p) => p.visit_with(visitor),
|
ConstValue::Param(p) => p.visit_with(visitor),
|
||||||
ConstValue::Placeholder(_) => false,
|
|
||||||
ConstValue::Scalar(_) => false,
|
|
||||||
ConstValue::Slice { .. } => false,
|
|
||||||
ConstValue::Unevaluated(_, substs) => substs.visit_with(visitor),
|
ConstValue::Unevaluated(_, substs) => substs.visit_with(visitor),
|
||||||
|
ConstValue::ByRef { .. } | ConstValue::Bound(..) | ConstValue::Placeholder(_)
|
||||||
|
| ConstValue::Scalar(_) | ConstValue::Slice { .. } => false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2373,6 +2373,4 @@ pub enum InferConst<'tcx> {
|
||||||
Var(ConstVid<'tcx>),
|
Var(ConstVid<'tcx>),
|
||||||
/// A fresh const variable. See `infer::freshen` for more details.
|
/// A fresh const variable. See `infer::freshen` for more details.
|
||||||
Fresh(u32),
|
Fresh(u32),
|
||||||
/// Canonicalized const variable, used only when preparing a trait query.
|
|
||||||
Canonical(DebruijnIndex, BoundVar),
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
use crate::hir::def_id::DefId;
|
use crate::hir::def_id::DefId;
|
||||||
use crate::infer::canonical::Canonical;
|
use crate::infer::canonical::Canonical;
|
||||||
use crate::ty::{self, Lift, List, Ty, TyCtxt, InferConst, ParamConst};
|
use crate::ty::{self, Lift, List, Ty, TyCtxt, ParamConst};
|
||||||
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||||
use crate::mir::interpret::ConstValue;
|
use crate::mir::interpret::ConstValue;
|
||||||
use crate::ty::sty::{ClosureSubsts, GeneratorSubsts};
|
use crate::ty::sty::{ClosureSubsts, GeneratorSubsts};
|
||||||
|
@ -234,9 +234,7 @@ impl<'a, 'tcx> InternalSubsts<'tcx> {
|
||||||
|
|
||||||
ty::GenericParamDefKind::Const => {
|
ty::GenericParamDefKind::Const => {
|
||||||
tcx.mk_const(ty::Const {
|
tcx.mk_const(ty::Const {
|
||||||
val: ConstValue::Infer(
|
val: ConstValue::Bound(ty::INNERMOST, ty::BoundVar::from(param.index)),
|
||||||
InferConst::Canonical(ty::INNERMOST, ty::BoundVar::from(param.index))
|
|
||||||
),
|
|
||||||
ty: tcx.type_of(def_id),
|
ty: tcx.type_of(def_id),
|
||||||
}).into()
|
}).into()
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,6 +79,7 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> {
|
||||||
ConstValue::Unevaluated(..) => bug!("unevaluated constant in `OperandRef::from_const`"),
|
ConstValue::Unevaluated(..) => bug!("unevaluated constant in `OperandRef::from_const`"),
|
||||||
ConstValue::Param(_) => bug!("encountered a ConstValue::Param in codegen"),
|
ConstValue::Param(_) => bug!("encountered a ConstValue::Param in codegen"),
|
||||||
ConstValue::Infer(_) => bug!("encountered a ConstValue::Infer in codegen"),
|
ConstValue::Infer(_) => bug!("encountered a ConstValue::Infer in codegen"),
|
||||||
|
ConstValue::Bound(..) => bug!("encountered a ConstValue::Bound in codegen"),
|
||||||
ConstValue::Placeholder(_) => bug!("encountered a ConstValue::Placeholder in codegen"),
|
ConstValue::Placeholder(_) => bug!("encountered a ConstValue::Placeholder in codegen"),
|
||||||
ConstValue::Scalar(x) => {
|
ConstValue::Scalar(x) => {
|
||||||
let scalar = match layout.abi {
|
let scalar = match layout.abi {
|
||||||
|
|
|
@ -589,8 +589,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
let ptr = self.tag_static_base_pointer(Pointer::new(id, offset));
|
let ptr = self.tag_static_base_pointer(Pointer::new(id, offset));
|
||||||
Operand::Indirect(MemPlace::from_ptr(ptr, layout.align.abi))
|
Operand::Indirect(MemPlace::from_ptr(ptr, layout.align.abi))
|
||||||
},
|
},
|
||||||
ConstValue::Scalar(x) =>
|
ConstValue::Scalar(x) => Operand::Immediate(tag_scalar(x).into()),
|
||||||
Operand::Immediate(tag_scalar(x).into()),
|
|
||||||
ConstValue::Slice { data, start, end } => {
|
ConstValue::Slice { data, start, end } => {
|
||||||
// We rely on mutability being set correctly in `data` to prevent writes
|
// We rely on mutability being set correctly in `data` to prevent writes
|
||||||
// where none should happen.
|
// where none should happen.
|
||||||
|
@ -606,6 +605,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
}
|
}
|
||||||
ConstValue::Param(..) |
|
ConstValue::Param(..) |
|
||||||
ConstValue::Infer(..) |
|
ConstValue::Infer(..) |
|
||||||
|
ConstValue::Bound(..) |
|
||||||
ConstValue::Placeholder(..) |
|
ConstValue::Placeholder(..) |
|
||||||
ConstValue::Unevaluated(..) =>
|
ConstValue::Unevaluated(..) =>
|
||||||
bug!("eval_const_to_op: Unexpected ConstValue {:?}", val),
|
bug!("eval_const_to_op: Unexpected ConstValue {:?}", val),
|
||||||
|
|
|
@ -33,7 +33,7 @@ use rustc::traits::{
|
||||||
InEnvironment,
|
InEnvironment,
|
||||||
ChalkCanonicalGoal,
|
ChalkCanonicalGoal,
|
||||||
};
|
};
|
||||||
use rustc::ty::{self, TyCtxt, InferConst};
|
use rustc::ty::{self, TyCtxt};
|
||||||
use rustc::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
use rustc::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
|
||||||
use rustc::ty::query::Providers;
|
use rustc::ty::query::Providers;
|
||||||
use rustc::ty::subst::{GenericArg, GenericArgKind};
|
use rustc::ty::subst::{GenericArg, GenericArgKind};
|
||||||
|
@ -286,7 +286,7 @@ impl context::ContextOps<ChalkArenas<'tcx>> for ChalkContext<'tcx> {
|
||||||
_ => false,
|
_ => false,
|
||||||
},
|
},
|
||||||
GenericArgKind::Const(ct) => match ct.val {
|
GenericArgKind::Const(ct) => match ct.val {
|
||||||
ConstValue::Infer(InferConst::Canonical(debruijn, bound_ct)) => {
|
ConstValue::Bound(debruijn, bound_ct) => {
|
||||||
debug_assert_eq!(debruijn, ty::INNERMOST);
|
debug_assert_eq!(debruijn, ty::INNERMOST);
|
||||||
cvar == bound_ct
|
cvar == bound_ct
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@ use rustc::traits::{
|
||||||
Environment,
|
Environment,
|
||||||
InEnvironment,
|
InEnvironment,
|
||||||
};
|
};
|
||||||
use rustc::ty::{self, Ty, TyCtxt, InferConst};
|
use rustc::ty::{self, Ty, TyCtxt};
|
||||||
use rustc::ty::subst::GenericArg;
|
use rustc::ty::subst::GenericArg;
|
||||||
use rustc::ty::relate::{Relate, RelateResult, TypeRelation};
|
use rustc::ty::relate::{Relate, RelateResult, TypeRelation};
|
||||||
use rustc::mir::interpret::ConstValue;
|
use rustc::mir::interpret::ConstValue;
|
||||||
|
@ -287,10 +287,7 @@ impl TypeRelation<'tcx> for AnswerSubstitutor<'cx, 'tcx> {
|
||||||
a: &'tcx ty::Const<'tcx>,
|
a: &'tcx ty::Const<'tcx>,
|
||||||
b: &'tcx ty::Const<'tcx>,
|
b: &'tcx ty::Const<'tcx>,
|
||||||
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
|
) -> RelateResult<'tcx, &'tcx ty::Const<'tcx>> {
|
||||||
if let ty::Const {
|
if let ty::Const { val: ConstValue::Bound(debruijn, bound_ct), .. } = a {
|
||||||
val: ConstValue::Infer(InferConst::Canonical(debruijn, bound_ct)),
|
|
||||||
..
|
|
||||||
} = a {
|
|
||||||
if *debruijn == self.binder_index {
|
if *debruijn == self.binder_index {
|
||||||
self.unify_free_answer_var(*bound_ct, b.into())?;
|
self.unify_free_answer_var(*bound_ct, b.into())?;
|
||||||
return Ok(b);
|
return Ok(b);
|
||||||
|
@ -299,14 +296,8 @@ impl TypeRelation<'tcx> for AnswerSubstitutor<'cx, 'tcx> {
|
||||||
|
|
||||||
match (a, b) {
|
match (a, b) {
|
||||||
(
|
(
|
||||||
ty::Const {
|
ty::Const { val: ConstValue::Bound(a_debruijn, a_bound), .. },
|
||||||
val: ConstValue::Infer(InferConst::Canonical(a_debruijn, a_bound)),
|
ty::Const { val: ConstValue::Bound(b_debruijn, b_bound), .. },
|
||||||
..
|
|
||||||
},
|
|
||||||
ty::Const {
|
|
||||||
val: ConstValue::Infer(InferConst::Canonical(b_debruijn, b_bound)),
|
|
||||||
..
|
|
||||||
},
|
|
||||||
) => {
|
) => {
|
||||||
assert_eq!(a_debruijn, b_debruijn);
|
assert_eq!(a_debruijn, b_debruijn);
|
||||||
assert_eq!(a_bound, b_bound);
|
assert_eq!(a_bound, b_bound);
|
||||||
|
|
|
@ -46,13 +46,13 @@ error: def-path(bar::<impl foo::Foo>::baz)
|
||||||
LL | #[rustc_def_path]
|
LL | #[rustc_def_path]
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$_$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method17h059bf53000885489E)
|
error: symbol-name(_ZN209_$LT$$u5b$$RF$dyn$u20$impl1..Foo$u2b$Assoc$u20$$u3d$$u20$extern$u20$$u22$C$u22$$u20$fn$LP$$RF$u8$C$$u20$...$RP$$u2b$impl1..AutoTrait$u3b$$u20$_$u5d$$u20$as$u20$impl1..main..$u7b$$u7b$closure$u7d$$u7d$..Bar$GT$6method17h636bc933fc62ee2fE)
|
||||||
--> $DIR/impl1.rs:61:13
|
--> $DIR/impl1.rs:61:13
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; _] as impl1::main::{{closure}}::Bar>::method::h059bf53000885489)
|
error: demangling(<[&dyn impl1::Foo+Assoc = extern "C" fn(&u8, ::.)+impl1::AutoTrait; _] as impl1::main::{{closure}}::Bar>::method::h636bc933fc62ee2f)
|
||||||
--> $DIR/impl1.rs:61:13
|
--> $DIR/impl1.rs:61:13
|
||||||
|
|
|
|
||||||
LL | #[rustc_symbol_name]
|
LL | #[rustc_symbol_name]
|
||||||
|
|
Loading…
Reference in a new issue