1
Fork 0

Shorten error message for callable with wrong return type

```
error: expected `{closure@...}` to return `Ret`, but it returns `Other`
```
instead of
```
error: expected `{closure@...}` to be a closure that returns `Ret`, but it returns `Other`
```
This commit is contained in:
Esteban Küber 2025-02-02 01:00:12 +00:00
parent 7f36543a48
commit 9ebbba4ad9
23 changed files with 29 additions and 31 deletions

View file

@ -1518,7 +1518,6 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
with_forced_trimmed_paths! {
if self.tcx.is_lang_item(projection_term.def_id, LangItem::FnOnceOutput) {
let fn_kind = self_ty.prefix_string(self.tcx);
let (span, closure_span) = if let ty::Closure(def_id, _) = self_ty.kind() {
let def_span = self.tcx.def_span(def_id);
if let Some(local_def_id) = def_id.as_local()
@ -1555,8 +1554,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
_ => self_ty.to_string(),
};
Some((format!(
"expected `{item}` to be a {fn_kind} that returns `{expected_ty}`, but it \
returns `{normalized_ty}`",
"expected `{item}` to return `{expected_ty}`, but it returns `{normalized_ty}`",
), span, closure_span))
} else if self.tcx.is_lang_item(trait_def_id, LangItem::Future) {
Some((format!(