@@ -15,6 +15,7 @@ pub use self::AssocItemContainer::*;
15
15
pub use self :: BorrowKind :: * ;
16
16
pub use self :: IntVarValue :: * ;
17
17
pub use self :: Variance :: * ;
18
+ pub use upvar:: * ;
18
19
19
20
use crate :: hir:: exports:: ExportMap ;
20
21
use crate :: hir:: place:: {
@@ -115,6 +116,7 @@ mod instance;
115
116
mod list;
116
117
mod structural_impls;
117
118
mod sty;
119
+ mod upvar;
118
120
119
121
// Data types
120
122
@@ -515,37 +517,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TyS<'tcx> {
515
517
#[ rustc_diagnostic_item = "Ty" ]
516
518
pub type Ty < ' tcx > = & ' tcx TyS < ' tcx > ;
517
519
518
- #[ derive(
519
- Clone ,
520
- Copy ,
521
- Debug ,
522
- PartialEq ,
523
- Eq ,
524
- Hash ,
525
- TyEncodable ,
526
- TyDecodable ,
527
- TypeFoldable ,
528
- HashStable
529
- ) ]
530
- pub struct UpvarPath {
531
- pub hir_id : hir:: HirId ,
532
- }
533
-
534
- /// Upvars do not get their own `NodeId`. Instead, we use the pair of
535
- /// the original var ID (that is, the root variable that is referenced
536
- /// by the upvar) and the ID of the closure expression.
537
- #[ derive( Clone , Copy , PartialEq , Eq , Hash , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
538
- pub struct UpvarId {
539
- pub var_path : UpvarPath ,
540
- pub closure_expr_id : LocalDefId ,
541
- }
542
-
543
- impl UpvarId {
544
- pub fn new ( var_hir_id : hir:: HirId , closure_def_id : LocalDefId ) -> UpvarId {
545
- UpvarId { var_path : UpvarPath { hir_id : var_hir_id } , closure_expr_id : closure_def_id }
546
- }
547
- }
548
-
549
520
#[ derive( Clone , PartialEq , Debug , TyEncodable , TyDecodable , TypeFoldable , Copy , HashStable ) ]
550
521
pub enum BorrowKind {
551
522
/// Data must be immutable and is aliasable.
@@ -598,36 +569,6 @@ pub enum BorrowKind {
598
569
MutBorrow ,
599
570
}
600
571
601
- /// Information describing the capture of an upvar. This is computed
602
- /// during `typeck`, specifically by `regionck`.
603
- #[ derive( PartialEq , Clone , Debug , Copy , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
604
- pub enum UpvarCapture < ' tcx > {
605
- /// Upvar is captured by value. This is always true when the
606
- /// closure is labeled `move`, but can also be true in other cases
607
- /// depending on inference.
608
- ///
609
- /// If the upvar was inferred to be captured by value (e.g. `move`
610
- /// was not used), then the `Span` points to a usage that
611
- /// required it. There may be more than one such usage
612
- /// (e.g. `|| { a; a; }`), in which case we pick an
613
- /// arbitrary one.
614
- ByValue ( Option < Span > ) ,
615
-
616
- /// Upvar is captured by reference.
617
- ByRef ( UpvarBorrow < ' tcx > ) ,
618
- }
619
-
620
- #[ derive( PartialEq , Clone , Copy , TyEncodable , TyDecodable , TypeFoldable , HashStable ) ]
621
- pub struct UpvarBorrow < ' tcx > {
622
- /// The kind of borrow: by-ref upvars have access to shared
623
- /// immutable borrows, which are not part of the normal language
624
- /// syntax.
625
- pub kind : BorrowKind ,
626
-
627
- /// Region of the resulting reference.
628
- pub region : ty:: Region < ' tcx > ,
629
- }
630
-
631
572
/// Given the closure DefId this map provides a map of root variables to minimum
632
573
/// set of `CapturedPlace`s that need to be tracked to support all captures of that closure.
633
574
pub type MinCaptureInformationMap < ' tcx > = FxHashMap < DefId , RootVariableMinCaptureList < ' tcx > > ;
@@ -749,9 +690,6 @@ pub struct CaptureInfo<'tcx> {
749
690
pub capture_kind : UpvarCapture < ' tcx > ,
750
691
}
751
692
752
- pub type UpvarListMap = FxHashMap < DefId , FxIndexMap < hir:: HirId , UpvarId > > ;
753
- pub type UpvarCaptureMap < ' tcx > = FxHashMap < UpvarId , UpvarCapture < ' tcx > > ;
754
-
755
693
impl ty:: EarlyBoundRegion {
756
694
/// Does this early bound region have a name? Early bound regions normally
757
695
/// always have names except when using anonymous lifetimes (`'_`).
0 commit comments