Rollup merge of #113651 - lcnr:parent-def-id, r=compiler-errors

self type param infer, avoid ICE

fixes #113610, which is caused by 33a2c2487a/compiler/rustc_hir_analysis/src/collect/generics_of.rs (L190-L205)
This commit is contained in:
Matthias Krüger 2023-07-17 12:58:53 +02:00 committed by GitHub
commit eca9c0101c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 13 deletions

View file

@ -2388,14 +2388,11 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
// If there is only one implementation of the trait, suggest using it.
// Otherwise, use a placeholder comment for the implementation.
let (message, impl_suggestion) = if non_blanket_impl_count == 1 {(
"use the fully-qualified path to the only available implementation".to_string(),
"use the fully-qualified path to the only available implementation",
format!("<{} as ", self.tcx.type_of(impl_def_id).instantiate_identity())
)} else {(
format!(
"use a fully-qualified path to a specific available implementation ({} found)",
non_blanket_impl_count
),
"</* self type */ as ".to_string()
)} else {
("use a fully-qualified path to a specific available implementation",
"</* self type */ as ".to_string()
)};
let mut suggestions = vec![(
path.span.shrink_to_lo(),