Skip to content

Commit 9e2157f

Browse files
nikomatsakisdavidtwco
authored andcommitted
don't consider assignments to temporaries "interesting"
1 parent 0b62018 commit 9e2157f

File tree

1 file changed

+13
-1
lines changed
  • src/librustc_mir/borrow_check/nll/type_check

1 file changed

+13
-1
lines changed

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,9 +798,21 @@ impl<'a, 'gcx, 'tcx> TypeChecker<'a, 'gcx, 'tcx> {
798798
let tcx = self.tcx();
799799
match stmt.kind {
800800
StatementKind::Assign(ref place, ref rv) => {
801+
// Assignments to temporaries are not "interesting";
802+
// they are not caused by the user, but rather artifacts
803+
// of lowering. Assignments to other sorts of places *are* interesting
804+
// though.
805+
let is_temp = if let Place::Local(l) = place {
806+
!mir.local_decls[*l].is_user_variable.is_some()
807+
} else {
808+
false
809+
};
810+
811+
let locations = if is_temp { location.boring() } else { location.interesting() };
812+
801813
let place_ty = place.ty(mir, tcx).to_ty(tcx);
802814
let rv_ty = rv.ty(mir, tcx);
803-
if let Err(terr) = self.sub_types(rv_ty, place_ty, location.interesting()) {
815+
if let Err(terr) = self.sub_types(rv_ty, place_ty, locations) {
804816
span_mirbug!(
805817
self,
806818
stmt,

0 commit comments

Comments
 (0)