Move predicate error early check to its own method
This commit is contained in:
parent
124d6d843e
commit
568b316ce3
@ -104,6 +104,8 @@ fn report_selection_error(
|
|||||||
error: &SelectionError<'tcx>,
|
error: &SelectionError<'tcx>,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
fn fn_arg_obligation(&self, obligation: &PredicateObligation<'tcx>) -> bool;
|
||||||
|
|
||||||
fn report_const_param_not_wf(
|
fn report_const_param_not_wf(
|
||||||
&self,
|
&self,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
@ -434,20 +436,7 @@ fn report_selection_error(
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if let ObligationCauseCode::FunctionArgumentObligation {
|
if self.fn_arg_obligation(&obligation) {
|
||||||
arg_hir_id,
|
|
||||||
..
|
|
||||||
} = obligation.cause.code()
|
|
||||||
&& let Some(Node::Expr(arg)) = self.tcx.hir().find(*arg_hir_id)
|
|
||||||
&& let arg = arg.peel_borrows()
|
|
||||||
&& let hir::ExprKind::Path(hir::QPath::Resolved(
|
|
||||||
None,
|
|
||||||
hir::Path { res: hir::def::Res::Local(hir_id), .. },
|
|
||||||
)) = arg.kind
|
|
||||||
&& let Some(Node::Pat(pat)) = self.tcx.hir().find(*hir_id)
|
|
||||||
&& let Some(preds) = self.reported_trait_errors.borrow().get(&pat.span)
|
|
||||||
&& preds.contains(&obligation.predicate)
|
|
||||||
{
|
|
||||||
// Silence redundant errors on binding acccess that are already
|
// Silence redundant errors on binding acccess that are already
|
||||||
// reported on the binding definition (#56607).
|
// reported on the binding definition (#56607).
|
||||||
return;
|
return;
|
||||||
@ -948,6 +937,26 @@ fn report_selection_error(
|
|||||||
err.emit();
|
err.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn fn_arg_obligation(&self, obligation: &PredicateObligation<'tcx>) -> bool {
|
||||||
|
if let ObligationCauseCode::FunctionArgumentObligation {
|
||||||
|
arg_hir_id,
|
||||||
|
..
|
||||||
|
} = obligation.cause.code()
|
||||||
|
&& let Some(Node::Expr(arg)) = self.tcx.hir().find(*arg_hir_id)
|
||||||
|
&& let arg = arg.peel_borrows()
|
||||||
|
&& let hir::ExprKind::Path(hir::QPath::Resolved(
|
||||||
|
None,
|
||||||
|
hir::Path { res: hir::def::Res::Local(hir_id), .. },
|
||||||
|
)) = arg.kind
|
||||||
|
&& let Some(Node::Pat(pat)) = self.tcx.hir().find(*hir_id)
|
||||||
|
&& let Some(preds) = self.reported_trait_errors.borrow().get(&pat.span)
|
||||||
|
&& preds.contains(&obligation.predicate)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
fn report_const_param_not_wf(
|
fn report_const_param_not_wf(
|
||||||
&self,
|
&self,
|
||||||
ty: Ty<'tcx>,
|
ty: Ty<'tcx>,
|
||||||
|
Loading…
Reference in New Issue
Block a user