about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs2
-rw-r--r--src/librustc_mir/borrow_check/nll/type_check/mod.rs19
2 files changed, 17 insertions, 4 deletions
diff --git a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
index 6acf3aadf51..fbecab2dd1f 100644
--- a/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
+++ b/src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
@@ -587,7 +587,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
             infcx.extract_type_name(&return_ty)
         });
 
-                let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir");
+        let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir");
 
         let (return_span, mir_description) = if let hir::ExprKind::Closure(_, _, _, span, gen_move)
             = tcx.hir.expect_expr(mir_node_id).node
diff --git a/src/librustc_mir/borrow_check/nll/type_check/mod.rs b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
index eb689f0a9c6..9f790612124 100644
--- a/src/librustc_mir/borrow_check/nll/type_check/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/type_check/mod.rs
@@ -877,8 +877,9 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
                 // they are not caused by the user, but rather artifacts
                 // of lowering. Assignments to other sorts of places *are* interesting
                 // though.
-                let is_temp = if let Place::Local(l) = place {
-                    !mir.local_decls[*l].is_user_variable.is_some()
+                let is_temp = if let Place::Local(l) = *place {
+                    l != RETURN_PLACE &&
+                    !mir.local_decls[l].is_user_variable.is_some()
                 } else {
                     false
                 };
@@ -1119,7 +1120,19 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
         match *destination {
             Some((ref dest, _target_block)) => {
                 let dest_ty = dest.ty(mir, tcx).to_ty(tcx);
-                let locations = term_location.interesting();
+                let is_temp = if let Place::Local(l) = *dest {
+                    l != RETURN_PLACE &&
+                    !mir.local_decls[l].is_user_variable.is_some()
+                } else {
+                    false
+                };
+
+                let locations = if is_temp {
+                    term_location.boring()
+                } else {
+                    term_location.interesting()
+                };
+
                 if let Err(terr) = self.sub_types(sig.output(), dest_ty, locations) {
                     span_mirbug!(
                         self,