1
Fork 0

TypeParameterDefinition always require a DefId

This commit is contained in:
lcnr 2023-07-04 11:50:51 +02:00
parent 52d8c490a3
commit 594cd84a94
5 changed files with 8 additions and 8 deletions

View file

@ -254,7 +254,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
type BreakTy = ty::GenericArg<'tcx>; type BreakTy = ty::GenericArg<'tcx>;
fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> { fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> {
if let Some(origin) = self.0.type_var_origin(ty) if let Some(origin) = self.0.type_var_origin(ty)
&& let rustc_infer::infer::type_variable::TypeVariableOriginKind::TypeParameterDefinition(_, Some(def_id)) = && let rustc_infer::infer::type_variable::TypeVariableOriginKind::TypeParameterDefinition(_, def_id) =
origin.kind origin.kind
&& let generics = self.0.tcx.generics_of(self.1) && let generics = self.0.tcx.generics_of(self.1)
&& let Some(index) = generics.param_def_id_to_index(self.0.tcx, def_id) && let Some(index) = generics.param_def_id_to_index(self.0.tcx, def_id)

View file

@ -265,9 +265,9 @@ impl<'tcx> InferCtxt<'tcx> {
kind: UnderspecifiedArgKind::Type { kind: UnderspecifiedArgKind::Type {
prefix: "type parameter".into(), prefix: "type parameter".into(),
}, },
parent: def_id.and_then(|def_id| { parent: InferenceDiagnosticsParentData::for_def_id(
InferenceDiagnosticsParentData::for_def_id(self.tcx, def_id) self.tcx, def_id,
}), ),
}; };
} }
} }

View file

@ -1110,7 +1110,7 @@ impl<'tcx> InferCtxt<'tcx> {
TypeVariableOrigin { TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeParameterDefinition( kind: TypeVariableOriginKind::TypeParameterDefinition(
param.name, param.name,
Some(param.def_id), param.def_id,
), ),
span, span,
}, },

View file

@ -123,7 +123,7 @@ pub enum TypeVariableOriginKind {
NormalizeProjectionType, NormalizeProjectionType,
TypeInference, TypeInference,
OpaqueTypeInference(DefId), OpaqueTypeInference(DefId),
TypeParameterDefinition(Symbol, Option<DefId>), TypeParameterDefinition(Symbol, DefId),
/// One of the upvars or closure kind parameters in a `ClosureSubsts` /// One of the upvars or closure kind parameters in a `ClosureSubsts`
/// (before it has been determined). /// (before it has been determined).

View file

@ -2642,11 +2642,11 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
} }
fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> { fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
if let ty::Param(ty::ParamTy { name, .. }) = *ty.kind() { if let ty::Param(_) = *ty.kind() {
let infcx = self.infcx; let infcx = self.infcx;
*self.var_map.entry(ty).or_insert_with(|| { *self.var_map.entry(ty).or_insert_with(|| {
infcx.next_ty_var(TypeVariableOrigin { infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeParameterDefinition(name, None), kind: TypeVariableOriginKind::MiscVariable,
span: DUMMY_SP, span: DUMMY_SP,
}) })
}) })