Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeParameterDefinition always require a DefId #113319

Merged
merged 1 commit into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
type BreakTy = ty::GenericArg<'tcx>;
fn visit_ty(&mut self, ty: Ty<'tcx>) -> std::ops::ControlFlow<Self::BreakTy> {
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
&& let generics = self.0.tcx.generics_of(self.1)
&& let Some(index) = generics.param_def_id_to_index(self.0.tcx, def_id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ impl<'tcx> InferCtxt<'tcx> {
kind: UnderspecifiedArgKind::Type {
prefix: "type parameter".into(),
},
parent: def_id.and_then(|def_id| {
InferenceDiagnosticsParentData::for_def_id(self.tcx, def_id)
}),
parent: InferenceDiagnosticsParentData::for_def_id(
self.tcx, def_id,
),
};
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,7 +1110,7 @@ impl<'tcx> InferCtxt<'tcx> {
TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeParameterDefinition(
param.name,
Some(param.def_id),
param.def_id,
),
span,
},
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_infer/src/infer/type_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub enum TypeVariableOriginKind {
NormalizeProjectionType,
TypeInference,
OpaqueTypeInference(DefId),
TypeParameterDefinition(Symbol, Option<DefId>),
TypeParameterDefinition(Symbol, DefId),

/// One of the upvars or closure kind parameters in a `ClosureSubsts`
/// (before it has been determined).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2642,11 +2642,11 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
}

fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only used in a probe

if let ty::Param(ty::ParamTy { name, .. }) = *ty.kind() {
if let ty::Param(_) = *ty.kind() {
let infcx = self.infcx;
*self.var_map.entry(ty).or_insert_with(|| {
infcx.next_ty_var(TypeVariableOrigin {
kind: TypeVariableOriginKind::TypeParameterDefinition(name, None),
kind: TypeVariableOriginKind::MiscVariable,
span: DUMMY_SP,
})
})
Expand Down