@@ -3,17 +3,20 @@ use rustc_data_structures::intern::Interned;
3
3
use rustc_hir:: def_id:: DefId ;
4
4
use rustc_macros:: { HashStable , Lift , TyDecodable , TyEncodable , TypeFoldable , TypeVisitable } ;
5
5
use rustc_type_ir:: ClauseKind as IrClauseKind ;
6
+ use rustc_type_ir:: CoercePredicate as IrCoercePredicate ;
7
+ use rustc_type_ir:: ExistentialProjection as IrExistentialProjection ;
8
+ use rustc_type_ir:: ExistentialTraitRef as IrExistentialTraitRef ;
9
+ use rustc_type_ir:: NormalizesTo as IrNormalizesTo ;
6
10
use rustc_type_ir:: PredicateKind as IrPredicateKind ;
11
+ use rustc_type_ir:: ProjectionPredicate as IrProjectionPredicate ;
12
+ use rustc_type_ir:: SubtypePredicate as IrSubtypePredicate ;
7
13
use rustc_type_ir:: TraitPredicate as IrTraitPredicate ;
8
14
use rustc_type_ir:: TraitRef as IrTraitRef ;
9
- use rustc_type_ir:: ProjectionPredicate as IrProjectionPredicate ;
10
- use rustc_type_ir:: ExistentialTraitRef as IrExistentialTraitRef ;
11
- use rustc_type_ir:: ExistentialProjection as IrExistentialProjection ;
12
15
use std:: cmp:: Ordering ;
13
16
14
17
use crate :: ty:: {
15
- self , AliasTy , Binder , DebruijnIndex , DebugWithInfcx , EarlyBinder ,
16
- PredicatePolarity , Term , Ty , TyCtxt , TypeFlags , WithCachedTypeInfo ,
18
+ self , Binder , DebruijnIndex , DebugWithInfcx , EarlyBinder , PredicatePolarity , Term , Ty , TyCtxt ,
19
+ TypeFlags , WithCachedTypeInfo ,
17
20
} ;
18
21
19
22
pub type TraitRef < ' tcx > = IrTraitRef < TyCtxt < ' tcx > > ;
@@ -23,6 +26,9 @@ pub type ExistentialProjection<'tcx> = IrExistentialProjection<TyCtxt<'tcx>>;
23
26
pub type TraitPredicate < ' tcx > = IrTraitPredicate < TyCtxt < ' tcx > > ;
24
27
pub type ClauseKind < ' tcx > = IrClauseKind < TyCtxt < ' tcx > > ;
25
28
pub type PredicateKind < ' tcx > = IrPredicateKind < TyCtxt < ' tcx > > ;
29
+ pub type NormalizesTo < ' tcx > = IrNormalizesTo < TyCtxt < ' tcx > > ;
30
+ pub type CoercePredicate < ' tcx > = IrCoercePredicate < TyCtxt < ' tcx > > ;
31
+ pub type SubtypePredicate < ' tcx > = IrSubtypePredicate < TyCtxt < ' tcx > > ;
26
32
27
33
/// A statement that can be proven by a trait solver. This includes things that may
28
34
/// show up in where clauses, such as trait predicates and projection predicates,
@@ -511,25 +517,8 @@ pub type TypeOutlivesPredicate<'tcx> = OutlivesPredicate<Ty<'tcx>, ty::Region<'t
511
517
pub type PolyRegionOutlivesPredicate < ' tcx > = ty:: Binder < ' tcx , RegionOutlivesPredicate < ' tcx > > ;
512
518
pub type PolyTypeOutlivesPredicate < ' tcx > = ty:: Binder < ' tcx , TypeOutlivesPredicate < ' tcx > > ;
513
519
514
- /// Encodes that `a` must be a subtype of `b`. The `a_is_expected` flag indicates
515
- /// whether the `a` type is the type that we should label as "expected" when
516
- /// presenting user diagnostics.
517
- #[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug , TyEncodable , TyDecodable ) ]
518
- #[ derive( HashStable , TypeFoldable , TypeVisitable , Lift ) ]
519
- pub struct SubtypePredicate < ' tcx > {
520
- pub a_is_expected : bool ,
521
- pub a : Ty < ' tcx > ,
522
- pub b : Ty < ' tcx > ,
523
- }
524
520
pub type PolySubtypePredicate < ' tcx > = ty:: Binder < ' tcx , SubtypePredicate < ' tcx > > ;
525
521
526
- /// Encodes that we have to coerce *from* the `a` type to the `b` type.
527
- #[ derive( Clone , Copy , PartialEq , Eq , Hash , Debug , TyEncodable , TyDecodable ) ]
528
- #[ derive( HashStable , TypeFoldable , TypeVisitable , Lift ) ]
529
- pub struct CoercePredicate < ' tcx > {
530
- pub a : Ty < ' tcx > ,
531
- pub b : Ty < ' tcx > ,
532
- }
533
522
pub type PolyCoercePredicate < ' tcx > = ty:: Binder < ' tcx , CoercePredicate < ' tcx > > ;
534
523
535
524
pub type PolyProjectionPredicate < ' tcx > = Binder < ' tcx , ProjectionPredicate < ' tcx > > ;
@@ -568,33 +557,6 @@ impl<'tcx> PolyProjectionPredicate<'tcx> {
568
557
}
569
558
}
570
559
571
- /// Used by the new solver. Unlike a `ProjectionPredicate` this can only be
572
- /// proven by actually normalizing `alias`.
573
- #[ derive( Copy , Clone , PartialEq , Eq , Hash , TyEncodable , TyDecodable ) ]
574
- #[ derive( HashStable , TypeFoldable , TypeVisitable , Lift ) ]
575
- pub struct NormalizesTo < ' tcx > {
576
- pub alias : AliasTy < ' tcx > ,
577
- pub term : Term < ' tcx > ,
578
- }
579
-
580
- impl < ' tcx > NormalizesTo < ' tcx > {
581
- pub fn self_ty ( self ) -> Ty < ' tcx > {
582
- self . alias . self_ty ( )
583
- }
584
-
585
- pub fn with_self_ty ( self , tcx : TyCtxt < ' tcx > , self_ty : Ty < ' tcx > ) -> NormalizesTo < ' tcx > {
586
- Self { alias : self . alias . with_self_ty ( tcx, self_ty) , ..self }
587
- }
588
-
589
- pub fn trait_def_id ( self , tcx : TyCtxt < ' tcx > ) -> DefId {
590
- self . alias . trait_def_id ( tcx)
591
- }
592
-
593
- pub fn def_id ( self ) -> DefId {
594
- self . alias . def_id
595
- }
596
- }
597
-
598
560
pub trait ToPolyTraitRef < ' tcx > {
599
561
fn to_poly_trait_ref ( & self ) -> PolyTraitRef < ' tcx > ;
600
562
}
0 commit comments