Skip to content

Commit 3b005a5

Browse files
committed
---
yaml --- r: 228857 b: refs/heads/try c: b4dd765 h: refs/heads/master i: 228855: 526093f v: v3
1 parent 0d47b81 commit 3b005a5

File tree

3 files changed

+39
-5
lines changed

3 files changed

+39
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: aca2057ed5fb7af3f8905b2bc01f72fa001c35c8
33
refs/heads/snap-stage3: 1af31d4974e33027a68126fa5a5a3c2c6491824f
4-
refs/heads/try: 22796c8bade7d44c4e28d1e48196065705a2de60
4+
refs/heads/try: b4dd765e6884820bb9b5c46d18215657abb7ef22
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc_trans/trans/_match.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -952,9 +952,24 @@ fn insert_lllocals<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
952952
Lvalue::new("_match::insert_lllocals"),
953953
TrByMoveIntoCopy(..) => {
954954
// match_input moves from the input into a
955-
// separate stack slot; it must zero (at least
956-
// until we track drop flags for a fragmented
957-
// parent match input expression).
955+
// separate stack slot.
956+
//
957+
// E.g. consider moving the value `D(A)` out
958+
// of the tuple `(D(A), D(B))` and into the
959+
// local variable `x` via the pattern `(x,_)`,
960+
// leaving the remainder of the tuple `(_,
961+
// D(B))` still to be dropped in the future.
962+
//
963+
// Thus, here we must must zero the place that
964+
// we are moving *from*, because we do not yet
965+
// track drop flags for a fragmented parent
966+
// match input expression.
967+
//
968+
// Longer term we will be able to map the move
969+
// into `(x, _)` up to the parent path that
970+
// owns the whole tuple, and mark the
971+
// corresponding stack-local drop-flag
972+
// tracking the first component of the tuple.
958973
let hint_kind = HintKind::ZeroAndMaintain;
959974
Lvalue::new_with_hint("_match::insert_lllocals (match_input)",
960975
bcx, binding_info.id, hint_kind)

branches/try/src/librustc_trans/trans/datum.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,27 @@ pub struct Rvalue {
189189
pub mode: RvalueMode
190190
}
191191

192+
/// Classifies what action we should take when a value is moved away
193+
/// with respect to its drop-flag.
194+
///
195+
/// Long term there will be no need for this classification: all flags
196+
/// (which will be stored on the stack frame) will have the same
197+
/// interpretation and maintenance code associated with them.
192198
#[derive(Copy, Clone, Debug)]
193199
pub enum HintKind {
200+
/// When the value is moved, set the drop-flag to "dropped"
201+
/// (i.e. "zero the flag", even when the specific representation
202+
/// is not literally 0) and when it is reinitialized, set the
203+
/// drop-flag back to "initialized".
194204
ZeroAndMaintain,
205+
206+
/// When the value is moved, do not set the drop-flag to "dropped"
207+
/// However, continue to read the drop-flag in deciding whether to
208+
/// drop. (In essence, the path/fragment in question will never
209+
/// need to be dropped at the points where it is moved away by
210+
/// this code, but we are defending against the scenario where
211+
/// some *other* code could move away (or drop) the value and thus
212+
/// zero-the-flag, which is why we will still read from it.
195213
DontZeroJustUse,
196214
}
197215

@@ -218,7 +236,8 @@ impl Lvalue { // Constructors for various Lvalues.
218236
DropFlagInfo::ZeroAndMaintain(id),
219237
HintKind::DontZeroJustUse if hint_available =>
220238
DropFlagInfo::DontZeroJustUse(id),
221-
_ => DropFlagInfo::None,
239+
_ =>
240+
DropFlagInfo::None,
222241
};
223242
(Some(id), info)
224243
};

0 commit comments

Comments
 (0)