hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
_ => "match arms have compatible types",
},
- IfExpression { .. } => "if and else have compatible types",
+ IfExpression { .. } => "if and else have incompatible types",
IfExpressionWithNoElse => "if missing an else returns ()",
MainFunctionType => "`main` function has the correct type",
StartFunctionType => "`start` function has the correct type",
}
impl<'tcx> TyCtxt<'tcx> {
- pub fn note_and_explain_type_err(self,
- db: &mut DiagnosticBuilder<'_>,
- err: &TypeError<'tcx>,
- sp: Span) {
+ pub fn note_and_explain_type_err(
+ self,
+ db: &mut DiagnosticBuilder<'_>,
+ err: &TypeError<'tcx>,
+ sp: Span,
+ ) {
use self::TypeError::*;
- match err.clone() {
+ match err {
Sorts(values) => {
let expected_str = values.expected.sort_string(self);
let found_str = values.found.sort_string(self);
db.note("no two closures, even if identical, have the same type");
db.help("consider boxing your closure and/or using it as a trait object");
}
+ if expected_str == found_str && expected_str == "opaque type" { // Issue #63167
+ db.note("distinct uses of `impl Trait` result in different opaque types");
+ let e_str = values.expected.to_string();
+ let f_str = values.found.to_string();
+ if &e_str == &f_str && &e_str == "impl std::future::Future" {
+ db.help("if both futures resolve to the same type, consider `await`ing \
+ on both of them");
+ }
+ }
if let (ty::Infer(ty::IntVar(_)), ty::Float(_)) =
(&values.found.sty, &values.expected.sty) // Issue #53280
{