@@ -189,96 +189,42 @@ pub struct Rvalue {
189
189
pub mode : RvalueMode
190
190
}
191
191
192
- // XXX: reduce this to a smaller kernel of constructors.
193
- impl Lvalue { // These are all constructors for various Lvalues.
194
- pub fn new ( source : & ' static str ) -> Lvalue {
195
- Lvalue { source : source, drop_flag_info : DropFlagInfo :: None }
196
- }
197
-
198
- pub fn upvar < ' blk , ' tcx > ( source : & ' static str ,
199
- bcx : Block < ' blk , ' tcx > ,
200
- id : ast:: NodeId ) -> Lvalue {
201
- let info = if Lvalue :: has_dropflag_hint ( bcx, id) {
202
- DropFlagInfo :: ZeroAndMaintain ( id)
203
- } else {
204
- DropFlagInfo :: None
205
- } ;
206
- let info = if bcx. tcx ( ) . sess . nonzeroing_move_hints ( ) { info } else { DropFlagInfo :: None } ;
207
- debug ! ( "upvar Lvalue at {}, id: {} info: {:?}" , source, id, info) ;
208
- Lvalue { source : source, drop_flag_info : info }
209
- }
210
-
211
- pub fn match_input < ' blk , ' tcx > ( source : & ' static str ,
212
- bcx : Block < ' blk , ' tcx > ,
213
- id : ast:: NodeId ) -> Lvalue
214
- {
215
- let info = if Lvalue :: has_dropflag_hint ( bcx, id) {
216
- // match_input is used to move from the input into a
217
- // separate stack slot; it must zero (at least until we
218
- // improve things to track drop flags for the fragmented
219
- // parent match input expression).
220
- DropFlagInfo :: ZeroAndMaintain ( id)
221
- } else {
222
- DropFlagInfo :: None
223
- } ;
224
- let info = if bcx. tcx ( ) . sess . nonzeroing_move_hints ( ) { info } else { DropFlagInfo :: None } ;
225
- debug ! ( "match_input Lvalue at {}, id: {} info: {:?}" , source, id, info) ;
226
- Lvalue { source : source, drop_flag_info : info }
227
- }
192
+ #[ derive( Copy , Clone , Debug ) ]
193
+ pub enum HintKind {
194
+ ZeroAndMaintain ,
195
+ DontZeroJustUse ,
196
+ }
228
197
229
- pub fn local < ' blk , ' tcx > ( source : & ' static str ,
230
- bcx : Block < ' blk , ' tcx > ,
231
- id : ast:: NodeId ,
232
- aliases_other_state : bool )
233
- -> Lvalue
234
- {
235
- let info = if Lvalue :: has_dropflag_hint ( bcx, id) {
236
- if aliases_other_state {
237
- DropFlagInfo :: ZeroAndMaintain ( id)
238
- } else {
239
- DropFlagInfo :: DontZeroJustUse ( id)
240
- }
241
- } else {
242
- DropFlagInfo :: None
243
- } ;
244
- let info = if bcx. tcx ( ) . sess . nonzeroing_move_hints ( ) { info } else { DropFlagInfo :: None } ;
245
- debug ! ( "local Lvalue at {}, id: {} info: {:?}" , source, id, info) ;
246
- Lvalue { source : source, drop_flag_info : info }
198
+ impl Lvalue { // Constructors for various Lvalues.
199
+ pub fn new < ' blk , ' tcx > ( source : & ' static str ) -> Lvalue {
200
+ debug ! ( "Lvalue at {} no drop flag info" , source) ;
201
+ Lvalue { source : source, drop_flag_info : DropFlagInfo :: None }
247
202
}
248
203
249
- pub fn store_arg < ' blk , ' tcx > ( source : & ' static str ,
250
- bcx : Block < ' blk , ' tcx > ,
251
- id : ast:: NodeId ) -> Lvalue
252
- {
253
- let info = if Lvalue :: has_dropflag_hint ( bcx, id) {
254
- DropFlagInfo :: ZeroAndMaintain ( id)
255
- } else {
256
- DropFlagInfo :: None
257
- } ;
258
- let info = if bcx. tcx ( ) . sess . nonzeroing_move_hints ( ) { info } else { DropFlagInfo :: None } ;
259
- debug ! ( "store_arg Lvalue at {}, id: {} info: {:?}" , source, id, info) ;
260
- Lvalue { source : source, drop_flag_info : info }
204
+ pub fn new_dropflag_hint ( source : & ' static str ) -> Lvalue {
205
+ debug ! ( "Lvalue at {} is drop flag hint" , source) ;
206
+ Lvalue { source : source, drop_flag_info : DropFlagInfo :: None }
261
207
}
262
208
263
- pub fn binding < ' blk , ' tcx > ( source : & ' static str ,
264
- bcx : Block < ' blk , ' tcx > ,
265
- id : ast:: NodeId ,
266
- name : ast:: Name ) -> Lvalue {
267
- let info = if Lvalue :: has_dropflag_hint ( bcx, id) {
268
- DropFlagInfo :: DontZeroJustUse ( id)
269
- } else {
270
- DropFlagInfo :: None
209
+ pub fn new_with_hint < ' blk , ' tcx > ( source : & ' static str ,
210
+ bcx : Block < ' blk , ' tcx > ,
211
+ id : ast:: NodeId ,
212
+ k : HintKind ) -> Lvalue {
213
+ let ( opt_id, info) = {
214
+ let hint_available = Lvalue :: has_dropflag_hint ( bcx, id) &&
215
+ bcx. tcx ( ) . sess . nonzeroing_move_hints ( ) ;
216
+ let info = match k {
217
+ HintKind :: ZeroAndMaintain if hint_available =>
218
+ DropFlagInfo :: ZeroAndMaintain ( id) ,
219
+ HintKind :: DontZeroJustUse if hint_available =>
220
+ DropFlagInfo :: DontZeroJustUse ( id) ,
221
+ _ => DropFlagInfo :: None ,
222
+ } ;
223
+ ( Some ( id) , info)
271
224
} ;
272
- let info = if bcx. tcx ( ) . sess . nonzeroing_move_hints ( ) { info } else { DropFlagInfo :: None } ;
273
- debug ! ( "binding Lvalue at {}, id: {} name: {} info: {:?}" ,
274
- source, id, name, info) ;
225
+ debug ! ( "Lvalue at {}, id: {:?} info: {:?}" , source, opt_id, info) ;
275
226
Lvalue { source : source, drop_flag_info : info }
276
227
}
277
-
278
- pub fn new_dropflag_hint ( source : & ' static str ) -> Lvalue {
279
- debug ! ( "dropflag hint Lvalue at {}" , source) ;
280
- Lvalue { source : source, drop_flag_info : DropFlagInfo :: None }
281
- }
282
228
} // end Lvalue constructor methods.
283
229
284
230
impl Lvalue {
@@ -454,11 +400,15 @@ impl KindOps for Lvalue {
454
400
}
455
401
bcx
456
402
} else {
457
- // XXX would be nice to assert this, but we currently are
458
- // adding e.g. DontZeroJustUse flags. (The dropflag hint
459
- // construction should be taking !type_needs_drop into
460
- // account; earlier analysis phases may not have all the
461
- // info they need to do it properly, I think...)
403
+ // FIXME (#5016) would be nice to assert this, but we have
404
+ // to allow for e.g. DontZeroJustUse flags, for now.
405
+ //
406
+ // (The dropflag hint construction should be taking
407
+ // !type_needs_drop into account; earlier analysis phases
408
+ // may not have all the info they need to include such
409
+ // information properly, I think; in particular the
410
+ // fragments analysis works on a non-monomorphized view of
411
+ // the code.)
462
412
//
463
413
// assert_eq!(self.drop_flag_info, DropFlagInfo::None);
464
414
bcx
0 commit comments