squash OpaqueTy and ProjectionTy into AliasTy

This commit is contained in:
Michael Goulet
2022-11-26 21:32:01 +00:00
parent 5c6afb850c
commit c13bd83528
66 changed files with 182 additions and 197 deletions

View File

@@ -536,10 +536,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let ty = traits::normalize_projection_type(
self,
param_env,
ty::ProjectionTy {
def_id: tcx.lang_items().deref_target()?,
substs: trait_ref.substs,
},
ty::AliasTy { def_id: tcx.lang_items().deref_target()?, substs: trait_ref.substs },
cause.clone(),
0,
// We're *intentionally* throwing these away,
@@ -830,7 +827,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
| ty::GeneratorWitness(_)
| ty::Never
| ty::Projection(_)
| ty::Opaque(ty::OpaqueTy { def_id: _, substs: _ })
| ty::Opaque(ty::AliasTy { def_id: _, substs: _ })
| ty::Param(_)
| ty::Bound(_, _)
| ty::Error(_)

View File

@@ -156,7 +156,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let placeholder_trait_predicate = ty::Binder::dummy(placeholder_trait_predicate);
let (def_id, substs) = match *placeholder_self_ty.kind() {
ty::Projection(proj) => (proj.def_id, proj.substs),
ty::Opaque(ty::OpaqueTy { def_id, substs }) => (def_id, substs),
ty::Opaque(ty::AliasTy { def_id, substs }) => (def_id, substs),
_ => bug!("projection candidate for unexpected type: {:?}", placeholder_self_ty),
};

View File

@@ -1596,7 +1596,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let tcx = self.infcx.tcx;
let (def_id, substs) = match *placeholder_trait_predicate.trait_ref.self_ty().kind() {
ty::Projection(ref data) => (data.def_id, data.substs),
ty::Opaque(ty::OpaqueTy { def_id, substs }) => (def_id, substs),
ty::Opaque(ty::AliasTy { def_id, substs }) => (def_id, substs),
_ => {
span_bug!(
obligation.cause.span,
@@ -2260,7 +2260,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
t.rebind(def.all_fields().map(|f| f.ty(self.tcx(), substs)).collect())
}
ty::Opaque(ty::OpaqueTy { def_id, substs }) => {
ty::Opaque(ty::AliasTy { def_id, substs }) => {
// We can resolve the `impl Trait` to its concrete type,
// which enforces a DAG between the functions requiring
// the auto trait bounds in question.