Skip to content

Commit 1ead9af

Browse files
Aatchpnkfelix
authored andcommitted
---
yaml --- r: 185814 b: refs/heads/auto c: 85defff h: refs/heads/master v: v3
1 parent d7bf1a7 commit 1ead9af

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
@@ -10,7 +10,7 @@ refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
1010
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1111
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1212
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
13-
refs/heads/auto: 4bae133070e90a2c42824620b3d94fa752c96b0b
13+
refs/heads/auto: 85defffea58139e3e5cc0811e499330fa24267ac
1414
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1515
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1616
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/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)