Rename HAS_PROJECTIONS to HAS_ALIASES etc.
This commit is contained in:
parent
5dbaafdb93
commit
6f17b7f0ab
12 changed files with 21 additions and 17 deletions
|
@ -460,7 +460,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
|
||||||
where
|
where
|
||||||
T: TypeVisitable<TyCtxt<'tcx>>,
|
T: TypeVisitable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
t.has_free_regions() || t.has_projections() || t.has_infer_types()
|
t.has_free_regions() || t.has_aliases() || t.has_infer_types()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> {
|
pub fn node_ty(&self, id: hir::HirId) -> Ty<'tcx> {
|
||||||
|
|
|
@ -49,7 +49,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
let value = self.erase_regions(value);
|
let value = self.erase_regions(value);
|
||||||
debug!(?value);
|
debug!(?value);
|
||||||
|
|
||||||
if !value.has_projections() {
|
if !value.has_aliases() {
|
||||||
value
|
value
|
||||||
} else {
|
} else {
|
||||||
value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, param_env })
|
value.fold_with(&mut NormalizeAfterErasingRegionsFolder { tcx: self, param_env })
|
||||||
|
@ -81,7 +81,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||||
let value = self.erase_regions(value);
|
let value = self.erase_regions(value);
|
||||||
debug!(?value);
|
debug!(?value);
|
||||||
|
|
||||||
if !value.has_projections() {
|
if !value.has_aliases() {
|
||||||
Ok(value)
|
Ok(value)
|
||||||
} else {
|
} else {
|
||||||
let mut folder = TryNormalizeAfterErasingRegionsFolder::new(self, param_env);
|
let mut folder = TryNormalizeAfterErasingRegionsFolder::new(self, param_env);
|
||||||
|
|
|
@ -1077,7 +1077,7 @@ fn try_instance_mir<'tcx>(
|
||||||
let fields = def.all_fields();
|
let fields = def.all_fields();
|
||||||
for field in fields {
|
for field in fields {
|
||||||
let field_ty = field.ty(tcx, args);
|
let field_ty = field.ty(tcx, args);
|
||||||
if field_ty.has_param() && field_ty.has_projections() {
|
if field_ty.has_param() && field_ty.has_aliases() {
|
||||||
return Err("cannot build drop shim for polymorphic type");
|
return Err("cannot build drop shim for polymorphic type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
|
||||||
fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
|
fn try_fold_ty(&mut self, ty: Ty<'tcx>) -> Result<Ty<'tcx>, Self::Error> {
|
||||||
let infcx = self.at.infcx;
|
let infcx = self.at.infcx;
|
||||||
debug_assert_eq!(ty, infcx.shallow_resolve(ty));
|
debug_assert_eq!(ty, infcx.shallow_resolve(ty));
|
||||||
if !ty.has_projections() {
|
if !ty.has_aliases() {
|
||||||
return Ok(ty);
|
return Ok(ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ impl<'tcx> FallibleTypeFolder<TyCtxt<'tcx>> for NormalizationFolder<'_, 'tcx> {
|
||||||
fn try_fold_const(&mut self, ct: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
|
fn try_fold_const(&mut self, ct: ty::Const<'tcx>) -> Result<ty::Const<'tcx>, Self::Error> {
|
||||||
let infcx = self.at.infcx;
|
let infcx = self.at.infcx;
|
||||||
debug_assert_eq!(ct, infcx.shallow_resolve(ct));
|
debug_assert_eq!(ct, infcx.shallow_resolve(ct));
|
||||||
if !ct.has_projections() {
|
if !ct.has_aliases() {
|
||||||
return Ok(ct);
|
return Ok(ct);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -311,7 +311,7 @@ impl<'a, 'tcx> ObligationProcessor for FulfillProcessor<'a, 'tcx> {
|
||||||
|
|
||||||
let infcx = self.selcx.infcx;
|
let infcx = self.selcx.infcx;
|
||||||
|
|
||||||
if obligation.predicate.has_projections() {
|
if obligation.predicate.has_aliases() {
|
||||||
let mut obligations = Vec::new();
|
let mut obligations = Vec::new();
|
||||||
let predicate = normalize_with_depth_to(
|
let predicate = normalize_with_depth_to(
|
||||||
&mut self.selcx,
|
&mut self.selcx,
|
||||||
|
|
|
@ -101,6 +101,8 @@ pub(super) fn needs_normalization<'tcx, T: TypeVisitable<TyCtxt<'tcx>>>(
|
||||||
value: &T,
|
value: &T,
|
||||||
reveal: Reveal,
|
reveal: Reveal,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
// This mirrors `ty::TypeFlags::HAS_ALIASES` except that we take `Reveal` into account.
|
||||||
|
|
||||||
let mut flags = ty::TypeFlags::HAS_TY_PROJECTION
|
let mut flags = ty::TypeFlags::HAS_TY_PROJECTION
|
||||||
| ty::TypeFlags::HAS_TY_WEAK
|
| ty::TypeFlags::HAS_TY_WEAK
|
||||||
| ty::TypeFlags::HAS_TY_INHERENT
|
| ty::TypeFlags::HAS_TY_INHERENT
|
||||||
|
|
|
@ -432,7 +432,7 @@ pub(super) fn opt_normalize_projection_type<'a, 'b, 'tcx>(
|
||||||
|
|
||||||
let projected_term = selcx.infcx.resolve_vars_if_possible(projected_term);
|
let projected_term = selcx.infcx.resolve_vars_if_possible(projected_term);
|
||||||
|
|
||||||
let mut result = if projected_term.has_projections() {
|
let mut result = if projected_term.has_aliases() {
|
||||||
let normalized_ty = normalize_with_depth_to(
|
let normalized_ty = normalize_with_depth_to(
|
||||||
selcx,
|
selcx,
|
||||||
param_env,
|
param_env,
|
||||||
|
@ -596,7 +596,7 @@ pub fn normalize_inherent_projection<'a, 'b, 'tcx>(
|
||||||
let ty = tcx.type_of(alias_ty.def_id).instantiate(tcx, args);
|
let ty = tcx.type_of(alias_ty.def_id).instantiate(tcx, args);
|
||||||
|
|
||||||
let mut ty = selcx.infcx.resolve_vars_if_possible(ty);
|
let mut ty = selcx.infcx.resolve_vars_if_possible(ty);
|
||||||
if ty.has_projections() {
|
if ty.has_aliases() {
|
||||||
ty = normalize_with_depth_to(selcx, param_env, cause.clone(), depth + 1, ty, obligations);
|
ty = normalize_with_depth_to(selcx, param_env, cause.clone(), depth + 1, ty, obligations);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ where
|
||||||
type QueryResponse = T;
|
type QueryResponse = T;
|
||||||
|
|
||||||
fn try_fast_path(_tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<T> {
|
fn try_fast_path(_tcx: TyCtxt<'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<T> {
|
||||||
if !key.value.value.has_projections() { Some(key.value.value) } else { None }
|
if !key.value.value.has_aliases() { Some(key.value.value) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn perform_query(
|
fn perform_query(
|
||||||
|
|
|
@ -1066,7 +1066,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||||
// so we will try to normalize the obligation and evaluate again.
|
// so we will try to normalize the obligation and evaluate again.
|
||||||
// we will replace it with new solver in the future.
|
// we will replace it with new solver in the future.
|
||||||
if EvaluationResult::EvaluatedToErr == result
|
if EvaluationResult::EvaluatedToErr == result
|
||||||
&& fresh_trait_pred.has_projections()
|
&& fresh_trait_pred.has_aliases()
|
||||||
&& fresh_trait_pred.is_global()
|
&& fresh_trait_pred.is_global()
|
||||||
{
|
{
|
||||||
let mut nested_obligations = Vec::new();
|
let mut nested_obligations = Vec::new();
|
||||||
|
|
|
@ -239,9 +239,9 @@ fn layout_of_uncached<'tcx>(
|
||||||
|
|
||||||
// Arrays and slices.
|
// Arrays and slices.
|
||||||
ty::Array(element, mut count) => {
|
ty::Array(element, mut count) => {
|
||||||
if count.has_projections() {
|
if count.has_aliases() {
|
||||||
count = tcx.normalize_erasing_regions(param_env, count);
|
count = tcx.normalize_erasing_regions(param_env, count);
|
||||||
if count.has_projections() {
|
if count.has_aliases() {
|
||||||
return Err(error(cx, LayoutError::Unknown(ty)));
|
return Err(error(cx, LayoutError::Unknown(ty)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,8 +78,10 @@ bitflags! {
|
||||||
/// Does this have `ConstKind::Unevaluated`?
|
/// Does this have `ConstKind::Unevaluated`?
|
||||||
const HAS_CT_PROJECTION = 1 << 14;
|
const HAS_CT_PROJECTION = 1 << 14;
|
||||||
|
|
||||||
/// Could this type be normalized further?
|
/// Does this have `Alias` or `ConstKind::Unevaluated`?
|
||||||
const HAS_PROJECTION = TypeFlags::HAS_TY_PROJECTION.bits()
|
///
|
||||||
|
/// Rephrased, could this term be normalized further?
|
||||||
|
const HAS_ALIASES = TypeFlags::HAS_TY_PROJECTION.bits()
|
||||||
| TypeFlags::HAS_TY_WEAK.bits()
|
| TypeFlags::HAS_TY_WEAK.bits()
|
||||||
| TypeFlags::HAS_TY_OPAQUE.bits()
|
| TypeFlags::HAS_TY_OPAQUE.bits()
|
||||||
| TypeFlags::HAS_TY_INHERENT.bits()
|
| TypeFlags::HAS_TY_INHERENT.bits()
|
||||||
|
|
|
@ -223,8 +223,8 @@ pub trait TypeVisitableExt<I: Interner>: TypeVisitable<I> {
|
||||||
self.has_vars_bound_at_or_above(ty::INNERMOST)
|
self.has_vars_bound_at_or_above(ty::INNERMOST)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_projections(&self) -> bool {
|
fn has_aliases(&self) -> bool {
|
||||||
self.has_type_flags(TypeFlags::HAS_PROJECTION)
|
self.has_type_flags(TypeFlags::HAS_ALIASES)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn has_inherent_projections(&self) -> bool {
|
fn has_inherent_projections(&self) -> bool {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue