|
1 | 1 | use crate::infer::type_variable::TypeVariableOriginKind;
|
2 |
| -use crate::infer::InferCtxt; |
3 |
| -use crate::rustc_middle::ty::TypeFoldable; |
| 2 | +use crate::infer::{InferCtxt, Symbol}; |
4 | 3 | use rustc_errors::{pluralize, struct_span_err, Applicability, DiagnosticBuilder};
|
5 | 4 | use rustc_hir as hir;
|
6 | 5 | use rustc_hir::def::{DefKind, Namespace};
|
@@ -938,8 +937,17 @@ impl<'tcx> TypeFolder<'tcx> for ResolvedTypeParamEraser<'tcx> {
|
938 | 937 | let substs: Vec<_> = substs
|
939 | 938 | .iter()
|
940 | 939 | .zip(generics.params.iter())
|
941 |
| - .map(|(subst, param)| match ¶m.kind { |
942 |
| - ty::GenericParamDefKind::Type { has_default: true, .. } => subst, |
| 940 | + .map(|(subst, param)| match &(subst.unpack(), ¶m.kind) { |
| 941 | + (_, ty::GenericParamDefKind::Type { has_default: true, .. }) => subst, |
| 942 | + (crate::infer::GenericArgKind::Const(c), _) => { |
| 943 | + match c.val { |
| 944 | + ty::ConstKind::Infer(..) => { |
| 945 | + // Replace not yet inferred const params with their def name. |
| 946 | + self.tcx().mk_const_param(param.index, param.name, c.ty).into() |
| 947 | + } |
| 948 | + _ => subst, |
| 949 | + } |
| 950 | + } |
943 | 951 | _ => subst.super_fold_with(self),
|
944 | 952 | })
|
945 | 953 | .collect();
|
@@ -977,8 +985,19 @@ impl<'tcx> TypeFolder<'tcx> for ResolvedTypeParamEraser<'tcx> {
|
977 | 985 | | ty::FnPtr(_)
|
978 | 986 | | ty::Opaque(..)
|
979 | 987 | | ty::Projection(_)
|
980 |
| - | ty::Never |
981 |
| - | ty::Array(..) => t.super_fold_with(self), |
| 988 | + | ty::Never => t.super_fold_with(self), |
| 989 | + ty::Array(ty, c) => { |
| 990 | + self.tcx().mk_ty(ty::Array( |
| 991 | + self.fold_ty(ty), |
| 992 | + match c.val { |
| 993 | + ty::ConstKind::Infer(..) => { |
| 994 | + // Replace not yet inferred const params with their def name. |
| 995 | + self.tcx().mk_const_param(0, Symbol::intern("N"), c.ty).into() |
| 996 | + } |
| 997 | + _ => c, |
| 998 | + }, |
| 999 | + )) |
| 1000 | + } |
982 | 1001 | // We don't want to hide type params that haven't been resolved yet.
|
983 | 1002 | // This would be the type that will be written out with the type param
|
984 | 1003 | // name in the output.
|
|
0 commit comments