Skip to content

Commit 42eb4d1

Browse files
Aatchpnkfelix
authored andcommitted
---
yaml --- r: 187702 b: refs/heads/tmp c: 85defff h: refs/heads/master v: v3
1 parent 31af2eb commit 42eb4d1

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@ refs/heads/building: 126db549b038c84269a1e4fe46f051b2c15d6970
3434
refs/heads/beta: 522d09dfecbeca1595f25ac58c6d0178bbd21d7d
3535
refs/heads/windistfix: 7608dbad651f02e837ed05eef3d74a6662a6e928
3636
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
37-
refs/heads/tmp: 4bae133070e90a2c42824620b3d94fa752c96b0b
37+
refs/heads/tmp: 85defffea58139e3e5cc0811e499330fa24267ac
3838
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f

branches/tmp/src/librustc_borrowck/borrowck/mod.rs

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -612,13 +612,26 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
612612
};
613613
let (suggestion, _) =
614614
move_suggestion(param_env, expr_span, expr_ty, ("moved by default", ""));
615-
self.tcx.sess.span_note(
616-
expr_span,
617-
&format!("`{}` moved here{} because it has type `{}`, which is {}",
618-
ol,
619-
moved_lp_msg,
620-
expr_ty.user_string(self.tcx),
621-
suggestion));
615+
// If the two spans are the same, it's because the expression will be evaluated
616+
// multiple times. Avoid printing the same span and adjust the wording so it makes
617+
// more sense that it's from multiple evalutations.
618+
if expr_span == use_span {
619+
self.tcx.sess.note(
620+
&format!("`{}` was previously moved here{} because it has type `{}`, \
621+
which is {}",
622+
ol,
623+
moved_lp_msg,
624+
expr_ty.user_string(self.tcx),
625+
suggestion));
626+
} else {
627+
self.tcx.sess.span_note(
628+
expr_span,
629+
&format!("`{}` moved here{} because it has type `{}`, which is {}",
630+
ol,
631+
moved_lp_msg,
632+
expr_ty.user_string(self.tcx),
633+
suggestion));
634+
}
622635
}
623636

624637
move_data::MovePat => {

0 commit comments

Comments
 (0)