Combine projection and opaque into alias
This commit is contained in:
@@ -337,9 +337,9 @@ impl<'tcx> Ty<'tcx> {
|
||||
ty::Infer(ty::FreshTy(_)) => "fresh type".into(),
|
||||
ty::Infer(ty::FreshIntTy(_)) => "fresh integral type".into(),
|
||||
ty::Infer(ty::FreshFloatTy(_)) => "fresh floating-point type".into(),
|
||||
ty::Projection(_) => "associated type".into(),
|
||||
ty::Alias(ty::Projection, _) => "associated type".into(),
|
||||
ty::Param(p) => format!("type parameter `{}`", p).into(),
|
||||
ty::Opaque(..) => "opaque type".into(),
|
||||
ty::Alias(ty::Opaque, ..) => "opaque type".into(),
|
||||
ty::Error(_) => "type error".into(),
|
||||
}
|
||||
}
|
||||
@@ -375,9 +375,9 @@ impl<'tcx> Ty<'tcx> {
|
||||
ty::Tuple(..) => "tuple".into(),
|
||||
ty::Placeholder(..) => "higher-ranked type".into(),
|
||||
ty::Bound(..) => "bound type variable".into(),
|
||||
ty::Projection(_) => "associated type".into(),
|
||||
ty::Alias(ty::Projection, _) => "associated type".into(),
|
||||
ty::Param(_) => "type parameter".into(),
|
||||
ty::Opaque(..) => "opaque type".into(),
|
||||
ty::Alias(ty::Opaque, ..) => "opaque type".into(),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -400,7 +400,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
diag.note("no two closures, even if identical, have the same type");
|
||||
diag.help("consider boxing your closure and/or using it as a trait object");
|
||||
}
|
||||
(ty::Opaque(..), ty::Opaque(..)) => {
|
||||
(ty::Alias(ty::Opaque, ..), ty::Alias(ty::Opaque, ..)) => {
|
||||
// Issue #63167
|
||||
diag.note("distinct uses of `impl Trait` result in different opaque types");
|
||||
}
|
||||
@@ -439,10 +439,10 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
#traits-as-parameters",
|
||||
);
|
||||
}
|
||||
(ty::Projection(_), ty::Projection(_)) => {
|
||||
(ty::Alias(ty::Projection, _), ty::Alias(ty::Projection, _)) => {
|
||||
diag.note("an associated type was expected, but a different one was found");
|
||||
}
|
||||
(ty::Param(p), ty::Projection(proj)) | (ty::Projection(proj), ty::Param(p))
|
||||
(ty::Param(p), ty::Alias(ty::Projection, proj)) | (ty::Alias(ty::Projection, proj), ty::Param(p))
|
||||
if self.def_kind(proj.def_id) != DefKind::ImplTraitPlaceholder =>
|
||||
{
|
||||
let generics = self.generics_of(body_owner_def_id);
|
||||
@@ -493,8 +493,8 @@ impl<'tcx> TyCtxt<'tcx> {
|
||||
diag.note("you might be missing a type parameter or trait bound");
|
||||
}
|
||||
}
|
||||
(ty::Param(p), ty::Dynamic(..) | ty::Opaque(..))
|
||||
| (ty::Dynamic(..) | ty::Opaque(..), ty::Param(p)) => {
|
||||
(ty::Param(p), ty::Dynamic(..) | ty::Alias(ty::Opaque, ..))
|
||||
| (ty::Dynamic(..) | ty::Alias(ty::Opaque, ..), ty::Param(p)) => {
|
||||
let generics = self.generics_of(body_owner_def_id);
|
||||
let p_span = self.def_span(generics.type_param(p, self).def_id);
|
||||
if !sp.contains(p_span) {
|
||||
@@ -553,7 +553,7 @@ impl<T> Trait<T> for X {
|
||||
diag.span_label(p_span, "this type parameter");
|
||||
}
|
||||
}
|
||||
(ty::Projection(proj_ty), _) if self.def_kind(proj_ty.def_id) != DefKind::ImplTraitPlaceholder => {
|
||||
(ty::Alias(ty::Projection, proj_ty), _) if self.def_kind(proj_ty.def_id) != DefKind::ImplTraitPlaceholder => {
|
||||
self.expected_projection(
|
||||
diag,
|
||||
proj_ty,
|
||||
@@ -562,7 +562,7 @@ impl<T> Trait<T> for X {
|
||||
cause.code(),
|
||||
);
|
||||
}
|
||||
(_, ty::Projection(proj_ty)) if self.def_kind(proj_ty.def_id) != DefKind::ImplTraitPlaceholder => {
|
||||
(_, ty::Alias(ty::Projection, proj_ty)) if self.def_kind(proj_ty.def_id) != DefKind::ImplTraitPlaceholder => {
|
||||
let msg = format!(
|
||||
"consider constraining the associated type `{}` to `{}`",
|
||||
values.found, values.expected,
|
||||
@@ -779,7 +779,8 @@ fn foo(&self) -> Self::T { String::new() }
|
||||
ty: Ty<'tcx>,
|
||||
) -> bool {
|
||||
let assoc = self.associated_item(proj_ty.def_id);
|
||||
if let ty::Opaque(ty::AliasTy { def_id, substs: _ }) = *proj_ty.self_ty().kind() {
|
||||
if let ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs: _ }) = *proj_ty.self_ty().kind()
|
||||
{
|
||||
let opaque_local_def_id = def_id.as_local();
|
||||
let opaque_hir_ty = if let Some(opaque_local_def_id) = opaque_local_def_id {
|
||||
match &self.hir().expect_item(opaque_local_def_id).kind {
|
||||
@@ -828,7 +829,7 @@ fn foo(&self) -> Self::T { String::new() }
|
||||
.filter_map(|(_, item)| {
|
||||
let method = self.fn_sig(item.def_id);
|
||||
match *method.output().skip_binder().kind() {
|
||||
ty::Projection(ty::AliasTy { def_id: item_def_id, .. })
|
||||
ty::Alias(ty::Projection, ty::AliasTy { def_id: item_def_id, .. })
|
||||
if item_def_id == proj_ty_item_def_id =>
|
||||
{
|
||||
Some((
|
||||
|
||||
Reference in New Issue
Block a user