]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_hir_typeck/src/coercion.rs
Rollup merge of #104171 - ehuss:update-books, r=ehuss
[rust.git] / compiler / rustc_hir_typeck / src / coercion.rs
index 86597a703e833810dafaa5f4a25062d7bbd67a6a..4d8ab2c1c7ad94fe15c646a3115b5655291bdd20 100644 (file)
@@ -705,12 +705,7 @@ fn coerce_unsized(&self, mut source: Ty<'tcx>, mut target: Ty<'tcx>) -> CoerceRe
 
                 // Object safety violations or miscellaneous.
                 Err(err) => {
-                    self.err_ctxt().report_selection_error(
-                        obligation.clone(),
-                        &obligation,
-                        &err,
-                        false,
-                    );
+                    self.err_ctxt().report_selection_error(obligation.clone(), &obligation, &err);
                     // Treat this like an obligation and follow through
                     // with the unsizing - the lack of a coercion should
                     // be silent, as it causes a type mismatch later.
@@ -1644,9 +1639,9 @@ pub(crate) fn coerce_inner<'a>(
                 if visitor.ret_exprs.len() > 0 && let Some(expr) = expression {
                     self.note_unreachable_loop_return(&mut err, &expr, &visitor.ret_exprs);
                 }
-                err.emit_unless(unsized_return);
+                let reported = err.emit_unless(unsized_return);
 
-                self.final_ty = Some(fcx.tcx.ty_error());
+                self.final_ty = Some(fcx.tcx.ty_error_with_guaranteed(reported));
             }
         }
     }
@@ -1782,7 +1777,8 @@ fn report_return_mismatched_types<'a>(
             // may occur at the first return expression we see in the closure
             // (if it conflicts with the declared return type). Skip adding a
             // note in this case, since it would be incorrect.
-            && !fcx.return_type_pre_known
+            && let Some(fn_sig) = fcx.body_fn_sig()
+            && fn_sig.output().is_ty_var()
         {
             err.span_note(
                 sp,