1
Fork 0

Mention fn coercion rules (needs to be expanded)

This commit is contained in:
Esteban Küber 2023-01-06 20:15:10 +00:00
parent 153ed09fb3
commit 5ae8e23816
27 changed files with 56 additions and 18 deletions

View file

@ -1865,6 +1865,18 @@ impl<'tcx> TypeErrCtxt<'_, 'tcx> {
self.check_and_note_conflicting_crates(diag, terr);
self.note_and_explain_type_err(diag, terr, cause, span, cause.body_id.to_def_id());
if let Some(exp_found) = exp_found
&& let exp_found = TypeError::Sorts(exp_found)
&& exp_found != terr
{
self.note_and_explain_type_err(
diag,
exp_found,
cause,
span,
cause.body_id.to_def_id(),
);
}
if let Some(ValuePairs::PolyTraitRefs(exp_found)) = values
&& let ty::Closure(def_id, _) = exp_found.expected.skip_binder().self_ty().kind()

View file

@ -218,6 +218,13 @@ impl<T> Trait<T> for X {
);
}
}
(ty::FnPtr(_), ty::FnDef(def, _))
if let hir::def::DefKind::Fn = tcx.def_kind(def) => {
diag.note(
"when the arguments and return types match, functions can be coerced \
to function pointers",
);
}
_ => {}
}
debug!(