factor out maybe_suggest_unsized_generics

This commit is contained in:
Taylor Yu 2021-05-31 20:46:58 -05:00
parent ce982a35e1
commit 2862f08b79

View File

@ -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