diff --git a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs index f522e272ecf..0441e3a1693 100644 --- a/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs +++ b/compiler/rustc_trait_selection/src/traits/error_reporting/mod.rs @@ -1088,6 +1088,13 @@ fn suggest_unsized_bound_if_applicable( obligation: &PredicateObligation<'tcx>, ); + fn maybe_suggest_unsized_generics( + &self, + err: &mut DiagnosticBuilder<'tcx>, + span: Span, + node: Node<'hir>, + ); + fn is_recursive_obligation( &self, obligated_types: &mut Vec<&ty::TyS<'tcx>>, @@ -1774,6 +1781,15 @@ fn suggest_unsized_bound_if_applicable( (Some(node), true) => node, _ => return, }; + self.maybe_suggest_unsized_generics(err, span, node); + } + + fn maybe_suggest_unsized_generics( + &self, + err: &mut DiagnosticBuilder<'tcx>, + span: Span, + node: Node<'hir>, + ) { let generics = match node.generics() { Some(generics) => generics, None => return, @@ -1792,7 +1808,7 @@ fn suggest_unsized_bound_if_applicable( { continue; } - debug!("suggest_unsized_bound_if_applicable: param={:?}", param); + debug!("maybe_suggest_unsized_generics: param={:?}", param); match node { hir::Node::Item( item