Skip to content

Commit 1c82987

Browse files
committed
Fix typo in E0308 if/else label
1 parent 7b0085a commit 1c82987

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1650,7 +1650,7 @@ impl<'tcx> ObligationCause<'tcx> {
16501650
hir::MatchSource::IfLetDesugar { .. } => "`if let` arms have compatible types",
16511651
_ => "match arms have compatible types",
16521652
},
1653-
IfExpression { .. } => "if and else have compatible types",
1653+
IfExpression { .. } => "if and else have incompatible types",
16541654
IfExpressionWithNoElse => "if missing an else returns ()",
16551655
MainFunctionType => "`main` function has the correct type",
16561656
StartFunctionType => "`start` function has the correct type",

src/librustc/ty/error.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,20 +247,31 @@ impl<'tcx> ty::TyS<'tcx> {
247247
}
248248

249249
impl<'tcx> TyCtxt<'tcx> {
250-
pub fn note_and_explain_type_err(self,
251-
db: &mut DiagnosticBuilder<'_>,
252-
err: &TypeError<'tcx>,
253-
sp: Span) {
250+
pub fn note_and_explain_type_err(
251+
self,
252+
db: &mut DiagnosticBuilder<'_>,
253+
err: &TypeError<'tcx>,
254+
sp: Span,
255+
) {
254256
use self::TypeError::*;
255257

256-
match err.clone() {
258+
match err {
257259
Sorts(values) => {
258260
let expected_str = values.expected.sort_string(self);
259261
let found_str = values.found.sort_string(self);
260262
if expected_str == found_str && expected_str == "closure" {
261263
db.note("no two closures, even if identical, have the same type");
262264
db.help("consider boxing your closure and/or using it as a trait object");
263265
}
266+
if expected_str == found_str && expected_str == "opaque type" { // Issue #63167
267+
db.note("distinct uses of `impl Trait` result in different opaque types");
268+
let e_str = values.expected.to_string();
269+
let f_str = values.found.to_string();
270+
if &e_str == &f_str && &e_str == "impl std::future::Future" {
271+
db.help("if both futures resolve to the same type, consider `await`ing \
272+
on both of them");
273+
}
274+
}
264275
if let (ty::Infer(ty::IntVar(_)), ty::Float(_)) =
265276
(&values.found.sty, &values.expected.sty) // Issue #53280
266277
{

0 commit comments

Comments
 (0)