diff options
| author | Michael Goulet <michael@errs.io> | 2022-11-26 21:51:55 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-12-13 17:48:55 +0000 |
| commit | 61adaf81873101587ffff4e1b8671acbc33d3df1 (patch) | |
| tree | 7687aacda07f91463a43012ee10e0a5894557ac4 /compiler/rustc_hir_analysis/src | |
| parent | c13bd83528da223fa073e9c7e5fdc435254baab6 (diff) | |
| download | rust-61adaf81873101587ffff4e1b8671acbc33d3df1.tar.gz rust-61adaf81873101587ffff4e1b8671acbc33d3df1.zip | |
Combine projection and opaque into alias
Diffstat (limited to 'compiler/rustc_hir_analysis/src')
12 files changed, 17 insertions, 17 deletions
diff --git a/compiler/rustc_hir_analysis/src/astconv/mod.rs b/compiler/rustc_hir_analysis/src/astconv/mod.rs index f91c17d5c03..c8c10385f0c 100644 --- a/compiler/rustc_hir_analysis/src/astconv/mod.rs +++ b/compiler/rustc_hir_analysis/src/astconv/mod.rs @@ -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()); } } diff --git a/compiler/rustc_hir_analysis/src/check/check.rs b/compiler/rustc_hir_analysis/src/check/check.rs index 9b42c16b882..dd841707b29 100644 --- a/compiler/rustc_hir_analysis/src/check/check.rs +++ b/compiler/rustc_hir_analysis/src/check/check.rs @@ -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 } diff --git a/compiler/rustc_hir_analysis/src/check/compare_method.rs b/compiler/rustc_hir_analysis/src/check/compare_method.rs index d09c17e9f9b..ba7d31cea2e 100644 --- a/compiler/rustc_hir_analysis/src/check/compare_method.rs +++ b/compiler/rustc_hir_analysis/src/check/compare_method.rs @@ -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 diff --git a/compiler/rustc_hir_analysis/src/check/wfcheck.rs b/compiler/rustc_hir_analysis/src/check/wfcheck.rs index c0dbae81371..94d333c336e 100644 --- a/compiler/rustc_hir_analysis/src/check/wfcheck.rs +++ b/compiler/rustc_hir_analysis/src/check/wfcheck.rs @@ -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() { diff --git a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs index 2890c149b3a..32c3e95688b 100644 --- a/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs +++ b/compiler/rustc_hir_analysis/src/coherence/inherent_impls.rs @@ -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, diff --git a/compiler/rustc_hir_analysis/src/collect/lifetimes.rs b/compiler/rustc_hir_analysis/src/collect/lifetimes.rs index 9a7b261fffd..b4ad3467e7d 100644 --- a/compiler/rustc_hir_analysis/src/collect/lifetimes.rs +++ b/compiler/rustc_hir_analysis/src/collect/lifetimes.rs @@ -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) diff --git a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs index 617de63b1bd..776bfe9c53a 100644 --- a/compiler/rustc_hir_analysis/src/collect/predicates_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/predicates_of.rs @@ -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 { diff --git a/compiler/rustc_hir_analysis/src/collect/type_of.rs b/compiler/rustc_hir_analysis/src/collect/type_of.rs index 43bc71ea1e4..b678990f94e 100644 --- a/compiler/rustc_hir_analysis/src/collect/type_of.rs +++ b/compiler/rustc_hir_analysis/src/collect/type_of.rs @@ -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 diff --git a/compiler/rustc_hir_analysis/src/constrained_generic_params.rs b/compiler/rustc_hir_analysis/src/constrained_generic_params.rs index b4057df7896..95c971c0d78 100644 --- a/compiler/rustc_hir_analysis/src/constrained_generic_params.rs +++ b/compiler/rustc_hir_analysis/src/constrained_generic_params.rs @@ -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; } diff --git a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs index 3d29470ee66..af8d7e85158 100644 --- a/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs +++ b/compiler/rustc_hir_analysis/src/outlives/implicit_infer.rs @@ -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"); diff --git a/compiler/rustc_hir_analysis/src/variance/constraints.rs b/compiler/rustc_hir_analysis/src/variance/constraints.rs index 2d1b4fc4dc6..75bb7abf0ed 100644 --- a/compiler/rustc_hir_analysis/src/variance/constraints.rs +++ b/compiler/rustc_hir_analysis/src/variance/constraints.rs @@ -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); } diff --git a/compiler/rustc_hir_analysis/src/variance/mod.rs b/compiler/rustc_hir_analysis/src/variance/mod.rs index 3eb33319f7f..feb49ed1e30 100644 --- a/compiler/rustc_hir_analysis/src/variance/mod.rs +++ b/compiler/rustc_hir_analysis/src/variance/mod.rs @@ -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) |
