1
Fork 0

review comment: change span argument

This commit is contained in:
Esteban Küber 2024-10-27 19:23:21 +00:00
parent d2a781a2ec
commit d116767113
6 changed files with 15 additions and 10 deletions

View file

@ -642,7 +642,6 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
);
let hir = tcx.hir();
infcx.err_ctxt().note_type_err(
cause.span,
&mut diag,
&cause,
hir.get_if_local(impl_m.def_id)
@ -654,6 +653,7 @@ pub(super) fn collect_return_position_impl_trait_in_trait_tys<'tcx>(
}))),
terr,
false,
None,
);
return Err(diag.emit());
}
@ -1062,7 +1062,6 @@ fn report_trait_method_mismatch<'tcx>(
cause.span = impl_err_span;
infcx.err_ctxt().note_type_err(
cause.span,
&mut diag,
&cause,
trait_err_span.map(|sp| (sp, Cow::from("type in trait"), false)),
@ -1072,6 +1071,7 @@ fn report_trait_method_mismatch<'tcx>(
}))),
terr,
false,
None,
);
diag.emit()
@ -1855,7 +1855,6 @@ fn compare_const_predicate_entailment<'tcx>(
});
infcx.err_ctxt().note_type_err(
cause.span,
&mut diag,
&cause,
trait_c_span.map(|span| (span, Cow::from("type in trait"), false)),
@ -1865,6 +1864,7 @@ fn compare_const_predicate_entailment<'tcx>(
}))),
terr,
false,
None,
);
return Err(diag.emit());
};

View file

@ -640,7 +640,6 @@ pub fn check_function_signature<'tcx>(
let failure_code = cause.as_failure_code_diag(err, cause.span, vec![]);
let mut diag = tcx.dcx().create_err(failure_code);
err_ctxt.note_type_err(
cause.span,
&mut diag,
&cause,
None,
@ -650,6 +649,7 @@ pub fn check_function_signature<'tcx>(
}))),
err,
false,
None,
);
return Err(diag.emit());
}

View file

@ -1141,13 +1141,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let trace = mk_trace(provided_span, (formal_ty, expected_ty), provided_ty);
if let Some(e) = error {
self.err_ctxt().note_type_err(
trace.cause.span,
&mut err,
&trace.cause,
None,
Some(self.param_env.and(trace.values)),
e,
true,
None,
);
}
}

View file

@ -2462,7 +2462,6 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}
infcx.err_ctxt().note_type_err(
cause.span,
&mut diag,
&cause,
None,
@ -2472,6 +2471,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}))),
terr,
false,
None,
);
diag.emit();
self.abort.set(true);

View file

@ -1386,14 +1386,19 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
#[instrument(level = "debug", skip(self, diag, secondary_span, prefer_label))]
pub fn note_type_err(
&self,
span: Span,
diag: &mut Diag<'_>,
cause: &ObligationCause<'tcx>,
secondary_span: Option<(Span, Cow<'static, str>, bool)>,
mut values: Option<ty::ParamEnvAnd<'tcx, ValuePairs<'tcx>>>,
terr: TypeError<'tcx>,
prefer_label: bool,
override_span: Option<Span>,
) {
// We use `override_span` when we want the error to point at a `Span` other than
// `cause.span`. This is used in E0271, when a closure is passed in where the return type
// isn't what was expected. We want to point at the closure's return type (or expression),
// instead of the expression where the closure is passed as call argument.
let span = override_span.unwrap_or(cause.span);
// For some types of errors, expected-found does not make
// sense, so just ignore the values we were given.
if let TypeError::CyclicTy(_) = terr {
@ -2052,13 +2057,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
);
let mut diag = self.dcx().create_err(failure_code);
self.note_type_err(
span,
&mut diag,
&trace.cause,
None,
Some(param_env.and(trace.values)),
terr,
false,
None,
);
diag
}

View file

@ -702,13 +702,13 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
);
self.note_type_err(
span,
&mut diag,
&obligation.cause,
None,
None,
TypeError::Sorts(ty::error::ExpectedFound::new(expected_ty, ct_ty)),
false,
None,
);
diag
}
@ -1488,7 +1488,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
})();
self.note_type_err(
span,
&mut diag,
&obligation.cause,
secondary_span,
@ -1500,6 +1499,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
}),
err,
false,
Some(span),
);
self.note_obligation_cause(&mut diag, obligation);
diag.emit()