@@ -224,7 +224,7 @@ pub struct ScopeTree {
224
224
/// and not the enclosing *statement*. Expressions that are not present in this
225
225
/// table are not rvalue candidates. The set of rvalue candidates is computed
226
226
/// during type check based on a traversal of the AST.
227
- pub rvalue_candidates : HirIdMap < RvalueCandidateType > ,
227
+ pub rvalue_candidates : HirIdMap < RvalueCandidate > ,
228
228
229
229
/// Backwards incompatible scoping that will be introduced in future editions.
230
230
/// This information is used later for linting to identify locals and
@@ -308,15 +308,14 @@ pub struct ScopeTree {
308
308
pub yield_in_scope : UnordMap < Scope , Vec < YieldData > > ,
309
309
}
310
310
311
- /// Identifies the reason that a given expression is an rvalue candidate
312
- /// (see the `rvalue_candidates` field for more information what rvalue
313
- /// candidates in general). In constants, the `lifetime` field is None
314
- /// to indicate that certain expressions escape into 'static and
315
- /// should have no local cleanup scope.
311
+ /// See the `rvalue_candidates` field for more information on rvalue
312
+ /// candidates in general.
313
+ /// The `lifetime` field is None to indicate that certain expressions escape
314
+ /// into 'static and should have no local cleanup scope.
316
315
#[ derive( Debug , Copy , Clone , HashStable ) ]
317
- pub enum RvalueCandidateType {
318
- Borrow { target : hir:: ItemLocalId , lifetime : Option < Scope > } ,
319
- Pattern { target : hir :: ItemLocalId , lifetime : Option < Scope > } ,
316
+ pub struct RvalueCandidate {
317
+ pub target : hir:: ItemLocalId ,
318
+ pub lifetime : Option < Scope > ,
320
319
}
321
320
322
321
#[ derive( Debug , Copy , Clone , HashStable ) ]
@@ -344,16 +343,12 @@ impl ScopeTree {
344
343
self . var_map . insert ( var, lifetime) ;
345
344
}
346
345
347
- pub fn record_rvalue_candidate ( & mut self , var : HirId , candidate_type : RvalueCandidateType ) {
348
- debug ! ( "record_rvalue_candidate(var={var:?}, type={candidate_type:?})" ) ;
349
- match & candidate_type {
350
- RvalueCandidateType :: Borrow { lifetime : Some ( lifetime) , .. }
351
- | RvalueCandidateType :: Pattern { lifetime : Some ( lifetime) , .. } => {
352
- assert ! ( var. local_id != lifetime. local_id)
353
- }
354
- _ => { }
346
+ pub fn record_rvalue_candidate ( & mut self , var : HirId , candidate : RvalueCandidate ) {
347
+ debug ! ( "record_rvalue_candidate(var={var:?}, candidate={candidate:?})" ) ;
348
+ if let Some ( lifetime) = & candidate. lifetime {
349
+ assert ! ( var. local_id != lifetime. local_id)
355
350
}
356
- self . rvalue_candidates . insert ( var, candidate_type ) ;
351
+ self . rvalue_candidates . insert ( var, candidate ) ;
357
352
}
358
353
359
354
/// Returns the narrowest scope that encloses `id`, if any.
0 commit comments