@@ -15,6 +15,7 @@ pub use self::AssocItemContainer::*;
1515pub use self :: BorrowKind :: * ;
1616pub use self :: IntVarValue :: * ;
1717pub use self :: Variance :: * ;
18+ pub use upvar:: * ;
1819
1920use crate :: hir:: exports:: ExportMap ;
2021use crate :: hir:: place:: {
@@ -115,6 +116,7 @@ mod instance;
115116mod list;
116117mod structural_impls;
117118mod sty;
119+ mod upvar;
118120
119121// Data types
120122
@@ -515,37 +517,6 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TyS<'tcx> {
515517#[ rustc_diagnostic_item = "Ty" ]
516518pub type Ty < ' tcx > = & ' tcx TyS < ' tcx > ;
517519
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-
549520#[ derive( Clone , PartialEq , Debug , TyEncodable , TyDecodable , TypeFoldable , Copy , HashStable ) ]
550521pub enum BorrowKind {
551522 /// Data must be immutable and is aliasable.
@@ -598,36 +569,6 @@ pub enum BorrowKind {
598569 MutBorrow ,
599570}
600571
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-
631572/// Given the closure DefId this map provides a map of root variables to minimum
632573/// set of `CapturedPlace`s that need to be tracked to support all captures of that closure.
633574pub type MinCaptureInformationMap < ' tcx > = FxHashMap < DefId , RootVariableMinCaptureList < ' tcx > > ;
@@ -749,9 +690,6 @@ pub struct CaptureInfo<'tcx> {
749690 pub capture_kind : UpvarCapture < ' tcx > ,
750691}
751692
752- pub type UpvarListMap = FxHashMap < DefId , FxIndexMap < hir:: HirId , UpvarId > > ;
753- pub type UpvarCaptureMap < ' tcx > = FxHashMap < UpvarId , UpvarCapture < ' tcx > > ;
754-
755693impl ty:: EarlyBoundRegion {
756694 /// Does this early bound region have a name? Early bound regions normally
757695 /// always have names except when using anonymous lifetimes (`'_`).
0 commit comments