diff options
Diffstat (limited to 'compiler/rustc_middle/src/ty/flags.rs')
| -rw-r--r-- | compiler/rustc_middle/src/ty/flags.rs | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/compiler/rustc_middle/src/ty/flags.rs b/compiler/rustc_middle/src/ty/flags.rs index a078b6fb742..f06a1b09cd8 100644 --- a/compiler/rustc_middle/src/ty/flags.rs +++ b/compiler/rustc_middle/src/ty/flags.rs @@ -1,5 +1,5 @@ use crate::ty::subst::{GenericArg, GenericArgKind}; -use crate::ty::{self, InferConst, Ty, TypeFlags}; +use crate::ty::{self, InferConst, Term, Ty, TypeFlags}; use std::slice; #[derive(Debug)] @@ -22,7 +22,7 @@ impl FlagComputation { result } - pub fn for_predicate(binder: ty::Binder<'tcx, ty::PredicateKind<'_>>) -> FlagComputation { + pub fn for_predicate<'tcx>(binder: ty::Binder<'tcx, ty::PredicateKind<'_>>) -> FlagComputation { let mut result = FlagComputation::new(); result.add_predicate(binder); result @@ -97,7 +97,7 @@ impl FlagComputation { &ty::Error(_) => self.add_flags(TypeFlags::HAS_ERROR), &ty::Param(_) => { - self.add_flags(TypeFlags::HAS_KNOWN_TY_PARAM); + self.add_flags(TypeFlags::HAS_TY_PARAM); self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE); } @@ -216,7 +216,7 @@ impl FlagComputation { } } - fn add_predicate(&mut self, binder: ty::Binder<'tcx, ty::PredicateKind<'_>>) { + fn add_predicate(&mut self, binder: ty::Binder<'_, ty::PredicateKind<'_>>) { self.bound_computation(binder, |computation, atom| computation.add_predicate_atom(atom)); } @@ -241,9 +241,12 @@ impl FlagComputation { self.add_ty(a); self.add_ty(b); } - ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, ty }) => { + ty::PredicateKind::Projection(ty::ProjectionPredicate { projection_ty, term }) => { self.add_projection_ty(projection_ty); - self.add_ty(ty); + match term { + Term::Ty(ty) => self.add_ty(ty), + Term::Const(c) => self.add_const(c), + } } ty::PredicateKind::WellFormed(arg) => { self.add_substs(slice::from_ref(&arg)); @@ -298,7 +301,7 @@ impl FlagComputation { self.add_bound_var(debruijn); } ty::ConstKind::Param(_) => { - self.add_flags(TypeFlags::HAS_KNOWN_CT_PARAM); + self.add_flags(TypeFlags::HAS_CT_PARAM); self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE); } ty::ConstKind::Placeholder(_) => { @@ -310,30 +313,17 @@ impl FlagComputation { } } - fn add_unevaluated_const<P>(&mut self, ct: ty::Unevaluated<'tcx, P>) { - // The generic arguments of unevaluated consts are a bit special, - // see the `rustc-dev-guide` for more information. - // - // FIXME(@lcnr): Actually add a link here. - if let Some(substs) = ct.substs_ { - // If they are available, we treat them as ordinary generic arguments. - self.add_substs(substs); - } else { - // Otherwise, we add `HAS_UNKNOWN_DEFAULT_CONST_SUBSTS` to signify - // that our const may potentially refer to generic parameters. - // - // Note that depending on which generic parameters are actually - // used in this constant, we may not actually refer to any generic - // parameters at all. - self.add_flags(TypeFlags::STILL_FURTHER_SPECIALIZABLE); - self.add_flags(TypeFlags::HAS_UNKNOWN_DEFAULT_CONST_SUBSTS); - } + fn add_unevaluated_const<P>(&mut self, ct: ty::Unevaluated<'_, P>) { + self.add_substs(ct.substs); self.add_flags(TypeFlags::HAS_CT_PROJECTION); } fn add_existential_projection(&mut self, projection: &ty::ExistentialProjection<'_>) { self.add_substs(projection.substs); - self.add_ty(projection.ty); + match projection.term { + ty::Term::Ty(ty) => self.add_ty(ty), + ty::Term::Const(ct) => self.add_const(ct), + } } fn add_projection_ty(&mut self, projection_ty: ty::ProjectionTy<'_>) { |
