1
Fork 0

Fix wrong span for trait selection failure error reporting

This commit is contained in:
yukang 2023-07-22 10:13:49 +08:00
parent fcf3006e01
commit 3635b48973
4 changed files with 83 additions and 0 deletions

View file

@ -2987,6 +2987,14 @@ impl<'tcx> InferCtxtPrivExt<'tcx> for TypeErrCtxt<'_, 'tcx> {
unsatisfied_const: bool,
) {
let body_def_id = obligation.cause.body_id;
let span = if let ObligationCauseCode::BinOp { rhs_span: Some(rhs_span), .. } =
obligation.cause.code()
{
*rhs_span
} else {
span
};
// Try to report a help message
if is_fn_trait
&& let Ok((implemented_kind, params)) = self.type_implements_fn_trait(