Skip to content

Instantly share code, notes, and snippets.

@compiler-errors
Created June 10, 2022 04:34
Show Gist options
  • Select an option

  • Save compiler-errors/339e8f94120a5c4dfd71e01641923ca1 to your computer and use it in GitHub Desktop.

Select an option

Save compiler-errors/339e8f94120a5c4dfd71e01641923ca1 to your computer and use it in GitHub Desktop.
diff --git a/compiler/rustc_middle/src/ty/fast_reject.rs b/compiler/rustc_middle/src/ty/fast_reject.rs
index 334789d460c..847a8588566 100644
--- a/compiler/rustc_middle/src/ty/fast_reject.rs
+++ b/compiler/rustc_middle/src/ty/fast_reject.rs
@@ -128,7 +128,9 @@ pub fn simplify_type<'tcx>(
TreatParams::AsPlaceholder => Some(PlaceholderSimplifiedType),
TreatParams::AsInfer => None,
},
- ty::Projection(_) => match treat_params {
+ // FIXME(compiler-errors): Is this correct? Either `TyAlias` acts just like a
+ // projection, or it always returns `None`, but I'm not sure which.
+ ty::Projection(_) | ty::TyAlias(..) => match treat_params {
// When treating `ty::Param` as a placeholder, projections also
// don't unify with anything else as long as they are fully normalized.
//
@@ -142,7 +144,6 @@ pub fn simplify_type<'tcx>(
ty::Opaque(def_id, _) => Some(OpaqueSimplifiedType(def_id)),
ty::Foreign(def_id) => Some(ForeignSimplifiedType(def_id)),
ty::Bound(..) | ty::Infer(_) | ty::Error(_) => None,
- ty::TyAlias(def_id, _) => Some(TyAliasSimplifiedType(def_id)),
}
}
@@ -233,7 +234,7 @@ pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) -
match impl_ty.kind() {
// Start by checking whether the type in the impl may unify with
// pretty much everything. Just return `true` in that case.
- ty::Param(_) | ty::Projection(_) | ty::Error(_) => return true,
+ ty::Param(_) | ty::Projection(_) | ty::TyAlias(..) | ty::Error(_) => return true,
// These types only unify with inference variables or their own
// variant.
ty::Bool
@@ -252,7 +253,6 @@ pub fn types_may_unify<'tcx>(self, obligation_ty: Ty<'tcx>, impl_ty: Ty<'tcx>) -
| ty::Tuple(..)
| ty::FnPtr(..)
| ty::Foreign(..)
- | ty::TyAlias(..)
| ty::Opaque(..) => {}
ty::FnDef(..)
| ty::Closure(..)
diff --git a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
index ba890b28049..f96b05502e0 100644
--- a/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/candidate_assembly.rs
@@ -342,7 +342,7 @@ fn assemble_candidates_from_projected_tys(
// Before we go into the whole placeholder thing, just
// quickly check if the self-type is a projection at all.
match obligation.predicate.skip_binder().trait_ref.self_ty().kind() {
- ty::Projection(_) | ty::Opaque(..) | ty::TyAlias(_, _) => {}
+ ty::Projection(_) | ty::Opaque(..) => {}
ty::Infer(ty::TyVar(_)) => {
span_bug!(
obligation.cause.span,
diff --git a/compiler/rustc_trait_selection/src/traits/select/mod.rs b/compiler/rustc_trait_selection/src/traits/select/mod.rs
index 459249ebf53..35a951b274b 100644
--- a/compiler/rustc_trait_selection/src/traits/select/mod.rs
+++ b/compiler/rustc_trait_selection/src/traits/select/mod.rs
@@ -1338,7 +1338,6 @@ fn match_projection_obligation_against_definition_bounds(
let (def_id, substs) = match *placeholder_trait_predicate.trait_ref.self_ty().kind() {
ty::Projection(ref data) => (data.item_def_id, data.substs),
ty::Opaque(def_id, substs) => (def_id, substs),
- ty::TyAlias(def_id, substs) => (def_id, substs),
_ => {
span_bug!(
obligation.cause.span,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment