@@ -65,7 +65,6 @@ use std::ptr;
65
65
use std:: str;
66
66
67
67
pub use self :: sty:: BoundRegionKind :: * ;
68
- pub use self :: sty:: InferTy :: * ;
69
68
pub use self :: sty:: RegionKind ;
70
69
pub use self :: sty:: RegionKind :: * ;
71
70
pub use self :: sty:: TyKind :: * ;
@@ -74,13 +73,14 @@ pub use self::sty::{BoundRegion, BoundRegionKind, EarlyBoundRegion, FreeRegion,
74
73
pub use self :: sty:: { CanonicalPolyFnSig , FnSig , GenSig , PolyFnSig , PolyGenSig } ;
75
74
pub use self :: sty:: { ClosureSubsts , GeneratorSubsts , TypeAndMut , UpvarSubsts } ;
76
75
pub use self :: sty:: { ClosureSubstsParts , GeneratorSubstsParts } ;
77
- pub use self :: sty:: { ConstVid , FloatVid , IntVid , RegionVid , TyVid } ;
78
- pub use self :: sty:: { ExistentialPredicate , InferTy , ParamConst , ParamTy , ProjectionTy } ;
76
+ pub use self :: sty:: { ConstVid , RegionVid } ;
77
+ pub use self :: sty:: { ExistentialPredicate , ParamConst , ParamTy , ProjectionTy } ;
79
78
pub use self :: sty:: { ExistentialProjection , PolyExistentialProjection } ;
80
79
pub use self :: sty:: { ExistentialTraitRef , PolyExistentialTraitRef } ;
81
80
pub use self :: sty:: { PolyTraitRef , TraitRef , TyKind } ;
82
81
pub use crate :: ty:: diagnostics:: * ;
83
- pub use rustc_type_ir:: { DebruijnIndex , TypeFlags , INNERMOST } ;
82
+ pub use rustc_type_ir:: InferTy :: * ;
83
+ pub use rustc_type_ir:: * ;
84
84
85
85
pub use self :: binding:: BindingMode ;
86
86
pub use self :: binding:: BindingMode :: * ;
@@ -421,14 +421,6 @@ impl Visibility {
421
421
}
422
422
}
423
423
424
- #[ derive( Copy , Clone , PartialEq , TyDecodable , TyEncodable , HashStable ) ]
425
- pub enum Variance {
426
- Covariant , // T<A> <: T<B> iff A <: B -- e.g., function return type
427
- Invariant , // T<A> <: T<B> iff B == A -- e.g., type of mutable cell
428
- Contravariant , // T<A> <: T<B> iff B <: A -- e.g., function param type
429
- Bivariant , // T<A> <: T<B> -- e.g., unused type parameter
430
- }
431
-
432
424
/// The crate variances map is computed during typeck and contains the
433
425
/// variance of every item in the local crate. You should not use it
434
426
/// directly, because to do so will make your pass dependent on the
@@ -443,66 +435,6 @@ pub struct CrateVariancesMap<'tcx> {
443
435
pub variances : FxHashMap < DefId , & ' tcx [ ty:: Variance ] > ,
444
436
}
445
437
446
- impl Variance {
447
- /// `a.xform(b)` combines the variance of a context with the
448
- /// variance of a type with the following meaning. If we are in a
449
- /// context with variance `a`, and we encounter a type argument in
450
- /// a position with variance `b`, then `a.xform(b)` is the new
451
- /// variance with which the argument appears.
452
- ///
453
- /// Example 1:
454
- ///
455
- /// *mut Vec<i32>
456
- ///
457
- /// Here, the "ambient" variance starts as covariant. `*mut T` is
458
- /// invariant with respect to `T`, so the variance in which the
459
- /// `Vec<i32>` appears is `Covariant.xform(Invariant)`, which
460
- /// yields `Invariant`. Now, the type `Vec<T>` is covariant with
461
- /// respect to its type argument `T`, and hence the variance of
462
- /// the `i32` here is `Invariant.xform(Covariant)`, which results
463
- /// (again) in `Invariant`.
464
- ///
465
- /// Example 2:
466
- ///
467
- /// fn(*const Vec<i32>, *mut Vec<i32)
468
- ///
469
- /// The ambient variance is covariant. A `fn` type is
470
- /// contravariant with respect to its parameters, so the variance
471
- /// within which both pointer types appear is
472
- /// `Covariant.xform(Contravariant)`, or `Contravariant`. `*const
473
- /// T` is covariant with respect to `T`, so the variance within
474
- /// which the first `Vec<i32>` appears is
475
- /// `Contravariant.xform(Covariant)` or `Contravariant`. The same
476
- /// is true for its `i32` argument. In the `*mut T` case, the
477
- /// variance of `Vec<i32>` is `Contravariant.xform(Invariant)`,
478
- /// and hence the outermost type is `Invariant` with respect to
479
- /// `Vec<i32>` (and its `i32` argument).
480
- ///
481
- /// Source: Figure 1 of "Taming the Wildcards:
482
- /// Combining Definition- and Use-Site Variance" published in PLDI'11.
483
- pub fn xform ( self , v : ty:: Variance ) -> ty:: Variance {
484
- match ( self , v) {
485
- // Figure 1, column 1.
486
- ( ty:: Covariant , ty:: Covariant ) => ty:: Covariant ,
487
- ( ty:: Covariant , ty:: Contravariant ) => ty:: Contravariant ,
488
- ( ty:: Covariant , ty:: Invariant ) => ty:: Invariant ,
489
- ( ty:: Covariant , ty:: Bivariant ) => ty:: Bivariant ,
490
-
491
- // Figure 1, column 2.
492
- ( ty:: Contravariant , ty:: Covariant ) => ty:: Contravariant ,
493
- ( ty:: Contravariant , ty:: Contravariant ) => ty:: Covariant ,
494
- ( ty:: Contravariant , ty:: Invariant ) => ty:: Invariant ,
495
- ( ty:: Contravariant , ty:: Bivariant ) => ty:: Bivariant ,
496
-
497
- // Figure 1, column 3.
498
- ( ty:: Invariant , _) => ty:: Invariant ,
499
-
500
- // Figure 1, column 4.
501
- ( ty:: Bivariant , _) => ty:: Bivariant ,
502
- }
503
- }
504
- }
505
-
506
438
// Contains information needed to resolve types and (in the future) look up
507
439
// the types of AST nodes.
508
440
#[ derive( Copy , Clone , PartialEq , Eq , Hash ) ]
@@ -804,15 +736,6 @@ pub struct CaptureInfo<'tcx> {
804
736
pub type UpvarListMap = FxHashMap < DefId , FxIndexMap < hir:: HirId , UpvarId > > ;
805
737
pub type UpvarCaptureMap < ' tcx > = FxHashMap < UpvarId , UpvarCapture < ' tcx > > ;
806
738
807
- #[ derive( Clone , Copy , PartialEq , Eq ) ]
808
- pub enum IntVarValue {
809
- IntType ( ast:: IntTy ) ,
810
- UintType ( ast:: UintTy ) ,
811
- }
812
-
813
- #[ derive( Clone , Copy , PartialEq , Eq ) ]
814
- pub struct FloatVarValue ( pub ast:: FloatTy ) ;
815
-
816
739
impl ty:: EarlyBoundRegion {
817
740
/// Does this early bound region have a name? Early bound regions normally
818
741
/// always have names except when using anonymous lifetimes (`'_`).
0 commit comments