Make assigning to the return type interesting

This commit is contained in:
Matthew Jasper 2018-08-07 21:17:59 +01:00
parent 23f09bbed4
commit 092f03a07a
2 changed files with 17 additions and 4 deletions

View File

@ -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

View File

@ -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,