]> git.lizzy.rs Git - rust.git/commitdiff
Make assigning to the return type interesting
authorMatthew Jasper <mjjasper1@gmail.com>
Tue, 7 Aug 2018 20:17:59 +0000 (21:17 +0100)
committerMatthew Jasper <mjjasper1@gmail.com>
Tue, 14 Aug 2018 19:35:46 +0000 (20:35 +0100)
src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs
src/librustc_mir/borrow_check/nll/type_check/mod.rs

index 6acf3aadf5169b77642a1d8f93c707539b588c2e..fbecab2dd1f5e0b24a1f2b19fa5f99fad9e7dc67 100644 (file)
@@ -587,7 +587,7 @@ fn give_name_if_anonymous_region_appears_in_output(
             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
index eb689f0a9c6c9602f9e8c9f34009a125af601ca5..9f790612124e67445ef78ae034b49b7edbf4a18d 100644 (file)
@@ -877,8 +877,9 @@ fn check_stmt(&mut self, mir: &Mir<'tcx>, stmt: &Statement<'tcx>, location: Loca
                 // 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 @@ fn check_call_dest(
         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,