Combine projection and opaque into alias
This commit is contained in:
parent
c13bd83528
commit
61adaf8187
104 changed files with 387 additions and 381 deletions
|
@ -1241,7 +1241,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
|
|||
//
|
||||
// Calling `skip_binder` is okay, because `add_bounds` expects the `param_ty`
|
||||
// parameter to have a skipped binder.
|
||||
let param_ty = tcx.mk_ty(ty::Projection(projection_ty.skip_binder()));
|
||||
let param_ty = tcx.mk_ty(ty::Alias(ty::Projection, projection_ty.skip_binder()));
|
||||
self.add_bounds(param_ty, ast_bounds.iter(), bounds, candidate.bound_vars());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1440,7 +1440,7 @@ fn opaque_type_cycle_error(tcx: TyCtxt<'_>, def_id: LocalDefId, span: Span) -> E
|
|||
impl<'tcx> ty::visit::TypeVisitor<'tcx> for OpaqueTypeCollector {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match *t.kind() {
|
||||
ty::Opaque(ty::AliasTy { def_id: def, substs: _ }) => {
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id: def, substs: _ }) => {
|
||||
self.0.push(def);
|
||||
ControlFlow::CONTINUE
|
||||
}
|
||||
|
|
|
@ -571,7 +571,7 @@ impl<'tcx> TypeFolder<'tcx> for ImplTraitInTraitCollector<'_, 'tcx> {
|
|||
}
|
||||
|
||||
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
|
||||
if let ty::Projection(proj) = ty.kind()
|
||||
if let ty::Alias(ty::Projection, proj) = ty.kind()
|
||||
&& self.tcx().def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder
|
||||
{
|
||||
if let Some((ty, _)) = self.types.get(&proj.def_id) {
|
||||
|
@ -1734,7 +1734,7 @@ pub fn check_type_bounds<'tcx>(
|
|||
let normalize_param_env = {
|
||||
let mut predicates = param_env.caller_bounds().iter().collect::<Vec<_>>();
|
||||
match impl_ty_value.kind() {
|
||||
ty::Projection(proj)
|
||||
ty::Alias(ty::Projection, proj)
|
||||
if proj.def_id == trait_ty.def_id && proj.substs == rebased_substs =>
|
||||
{
|
||||
// Don't include this predicate if the projected type is
|
||||
|
|
|
@ -759,7 +759,7 @@ impl<'tcx> TypeVisitor<'tcx> for GATSubstCollector<'tcx> {
|
|||
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match t.kind() {
|
||||
ty::Projection(p) if p.def_id == self.gat => {
|
||||
ty::Alias(ty::Projection, p) if p.def_id == self.gat => {
|
||||
for (idx, subst) in p.substs.iter().enumerate() {
|
||||
match subst.unpack() {
|
||||
GenericArgKind::Lifetime(lt) if !lt.is_late_bound() => {
|
||||
|
@ -1592,7 +1592,7 @@ fn check_return_position_impl_trait_in_trait_bounds<'tcx>(
|
|||
{
|
||||
for arg in fn_output.walk() {
|
||||
if let ty::GenericArgKind::Type(ty) = arg.unpack()
|
||||
&& let ty::Projection(proj) = ty.kind()
|
||||
&& let ty::Alias(ty::Projection, proj) = ty.kind()
|
||||
&& tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder
|
||||
&& tcx.impl_trait_in_trait_parent(proj.def_id) == fn_def_id.to_def_id()
|
||||
{
|
||||
|
|
|
@ -223,7 +223,7 @@ impl<'tcx> InherentCollect<'tcx> {
|
|||
| ty::Tuple(..) => {
|
||||
self.check_primitive_impl(item.owner_id.def_id, self_ty, items, ty.span)
|
||||
}
|
||||
ty::Projection(..) | ty::Opaque(..) | ty::Param(_) => {
|
||||
ty::Alias(ty::Projection, ..) | ty::Alias(ty::Opaque, ..) | ty::Param(_) => {
|
||||
let mut err = struct_span_err!(
|
||||
self.tcx.sess,
|
||||
ty.span,
|
||||
|
|
|
@ -1749,7 +1749,7 @@ fn is_late_bound_map(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<&FxIndexSet<
|
|||
ty::Param(param_ty) => {
|
||||
self.arg_is_constrained[param_ty.index as usize] = true;
|
||||
}
|
||||
ty::Projection(_) => return ControlFlow::Continue(()),
|
||||
ty::Alias(ty::Projection, _) => return ControlFlow::Continue(()),
|
||||
_ => (),
|
||||
}
|
||||
t.super_visit_with(self)
|
||||
|
|
|
@ -411,7 +411,7 @@ pub(super) fn explicit_predicates_of<'tcx>(
|
|||
// substs are the same as the trait's.
|
||||
// * It must be an associated type for this trait (*not* a
|
||||
// supertrait).
|
||||
if let ty::Projection(projection) = ty.kind() {
|
||||
if let ty::Alias(ty::Projection, projection) = ty.kind() {
|
||||
projection.substs == trait_identity_substs
|
||||
&& tcx.associated_item(projection.def_id).container_id(tcx) == def_id
|
||||
} else {
|
||||
|
|
|
@ -52,7 +52,7 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
|
|||
// Using the ItemCtxt convert the HIR for the unresolved assoc type into a
|
||||
// ty which is a fully resolved projection.
|
||||
// For the code example above, this would mean converting Self::Assoc<3>
|
||||
// into a ty::Projection(<Self as Foo>::Assoc<3>)
|
||||
// into a ty::Alias(ty::Projection, <Self as Foo>::Assoc<3>)
|
||||
let item_hir_id = tcx
|
||||
.hir()
|
||||
.parent_iter(hir_id)
|
||||
|
@ -68,7 +68,7 @@ pub(super) fn opt_const_param_of(tcx: TyCtxt<'_>, def_id: LocalDefId) -> Option<
|
|||
// the def_id that this query was called with. We filter to only type and const args here
|
||||
// as a precaution for if it's ever allowed to elide lifetimes in GAT's. It currently isn't
|
||||
// but it can't hurt to be safe ^^
|
||||
if let ty::Projection(projection) = ty.kind() {
|
||||
if let ty::Alias(ty::Projection, projection) = ty.kind() {
|
||||
let generics = tcx.generics_of(projection.def_id);
|
||||
|
||||
let arg_index = segment
|
||||
|
|
|
@ -59,7 +59,7 @@ struct ParameterCollector {
|
|||
impl<'tcx> TypeVisitor<'tcx> for ParameterCollector {
|
||||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
match *t.kind() {
|
||||
ty::Projection(..) if !self.include_nonconstraining => {
|
||||
ty::Alias(ty::Projection, ..) if !self.include_nonconstraining => {
|
||||
// projections are not injective
|
||||
return ControlFlow::CONTINUE;
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ fn insert_required_predicates_to_be_wf<'tcx>(
|
|||
}
|
||||
}
|
||||
|
||||
ty::Projection(obj) => {
|
||||
ty::Alias(ty::Projection, obj) => {
|
||||
// This corresponds to `<T as Foo<'a>>::Bar`. In this case, we should use the
|
||||
// explicit predicates as well.
|
||||
debug!("Projection");
|
||||
|
|
|
@ -249,11 +249,11 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
|
|||
self.add_constraints_from_substs(current, def.did(), substs, variance);
|
||||
}
|
||||
|
||||
ty::Projection(ref data) => {
|
||||
ty::Alias(ty::Projection, ref data) => {
|
||||
self.add_constraints_from_invariant_substs(current, data.substs, variance);
|
||||
}
|
||||
|
||||
ty::Opaque(ty::AliasTy { def_id: _, substs }) => {
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id: _, substs }) => {
|
||||
self.add_constraints_from_invariant_substs(current, substs, variance);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,8 +112,8 @@ fn variance_of_opaque(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[ty::Varianc
|
|||
fn visit_ty(&mut self, t: Ty<'tcx>) -> ControlFlow<Self::BreakTy> {
|
||||
// FIXME(alias): merge these
|
||||
match t.kind() {
|
||||
ty::Opaque(ty::AliasTy { def_id, substs }) => self.visit_opaque(*def_id, substs),
|
||||
ty::Projection(proj)
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs }) => self.visit_opaque(*def_id, substs),
|
||||
ty::Alias(ty::Projection, proj)
|
||||
if self.tcx.def_kind(proj.def_id) == DefKind::ImplTraitPlaceholder =>
|
||||
{
|
||||
self.visit_opaque(proj.def_id, proj.substs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue