]> git.lizzy.rs Git - rust.git/commitdiff
Fix typo in E0308 if/else label
authorEsteban Küber <esteban@kuber.com.ar>
Wed, 21 Aug 2019 18:46:31 +0000 (11:46 -0700)
committerEsteban Küber <esteban@kuber.com.ar>
Wed, 21 Aug 2019 22:05:20 +0000 (15:05 -0700)
src/librustc/infer/error_reporting/mod.rs
src/librustc/ty/error.rs

index 84687b8cab5c0b9160103167a97ab4a149c7efe6..9be73cf3c6d1645439e9e3af528318a097acdf5f 100644 (file)
@@ -1650,7 +1650,7 @@ fn as_requirement_str(&self) -> &'static str {
                 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",
index d6d17a67e01e95ef54529bfdd4eddd790321a612..6daecd7ae941aca89851207c958000cea1e7959d 100644 (file)
@@ -247,13 +247,15 @@ pub fn sort_string(&self, tcx: TyCtxt<'_>) -> Cow<'static, str> {
 }
 
 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);
@@ -261,6 +263,15 @@ pub fn note_and_explain_type_err(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
                 {