Skip to content

Commit 092f03a

Browse files
committed
Make assigning to the return type interesting
1 parent 23f09bb commit 092f03a

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

src/librustc_mir/borrow_check/nll/region_infer/error_reporting/region_name.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
587587
infcx.extract_type_name(&return_ty)
588588
});
589589

590-
let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir");
590+
let mir_node_id = tcx.hir.as_local_node_id(mir_def_id).expect("non-local mir");
591591

592592
let (return_span, mir_description) = if let hir::ExprKind::Closure(_, _, _, span, gen_move)
593593
= tcx.hir.expect_expr(mir_node_id).node

src/librustc_mir/borrow_check/nll/type_check/mod.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -877,8 +877,9 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
877877
// they are not caused by the user, but rather artifacts
878878
// of lowering. Assignments to other sorts of places *are* interesting
879879
// though.
880-
let is_temp = if let Place::Local(l) = place {
881-
!mir.local_decls[*l].is_user_variable.is_some()
880+
let is_temp = if let Place::Local(l) = *place {
881+
l != RETURN_PLACE &&
882+
!mir.local_decls[l].is_user_variable.is_some()
882883
} else {
883884
false
884885
};
@@ -1119,7 +1120,19 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
11191120
match *destination {
11201121
Some((ref dest, _target_block)) => {
11211122
let dest_ty = dest.ty(mir, tcx).to_ty(tcx);
1122-
let locations = term_location.interesting();
1123+
let is_temp = if let Place::Local(l) = *dest {
1124+
l != RETURN_PLACE &&
1125+
!mir.local_decls[l].is_user_variable.is_some()
1126+
} else {
1127+
false
1128+
};
1129+
1130+
let locations = if is_temp {
1131+
term_location.boring()
1132+
} else {
1133+
term_location.interesting()
1134+
};
1135+
11231136
if let Err(terr) = self.sub_types(sig.output(), dest_ty, locations) {
11241137
span_mirbug!(
11251138
self,

0 commit comments

Comments
 (0)