Store a LocalDefId in hir::GenericParam.

This commit is contained in:
Camille GILLOT
2022-11-06 18:26:36 +00:00
parent e82c08f58e
commit 18482f7b23
19 changed files with 67 additions and 88 deletions

View File

@@ -2619,11 +2619,10 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
let Some(param) = generics.params.iter().find(|param| param.span == span) else {
return;
};
let param_def_id = self.tcx.hir().local_def_id(param.hir_id);
// Check that none of the explicit trait bounds is `Sized`. Assume that an explicit
// `Sized` bound is there intentionally and we don't need to suggest relaxing it.
let explicitly_sized = generics
.bounds_for_param(param_def_id)
.bounds_for_param(param.def_id)
.flat_map(|bp| bp.bounds)
.any(|bound| bound.trait_ref().and_then(|tr| tr.trait_def_id()) == sized_trait);
if explicitly_sized {
@@ -2646,7 +2645,7 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
_ => {}
};
// Didn't add an indirection suggestion, so add a general suggestion to relax `Sized`.
let (span, separator) = if let Some(s) = generics.bounds_span_for_suggestions(param_def_id)
let (span, separator) = if let Some(s) = generics.bounds_span_for_suggestions(param.def_id)
{
(s, " +")
} else {