@@ -670,8 +670,7 @@ impl<'tcx> Binder<ExistentialPredicate<'tcx>> {
670
670
ty:: Predicate :: Projection ( Binder ( p. with_self_ty ( tcx, self_ty) ) )
671
671
}
672
672
ExistentialPredicate :: AutoTrait ( did) => {
673
- let trait_ref =
674
- Binder ( ty:: TraitRef { def_id : did, substs : tcx. mk_substs_trait ( self_ty, & [ ] ) } ) ;
673
+ let trait_ref = Binder ( ty:: TraitRef :: new ( did, tcx. mk_substs_trait ( self_ty, & [ ] ) ) ) ;
675
674
trait_ref. to_predicate ( )
676
675
}
677
676
}
@@ -784,17 +783,32 @@ impl<'tcx> Binder<&'tcx List<ExistentialPredicate<'tcx>>> {
784
783
pub struct TraitRef < ' tcx > {
785
784
pub def_id : DefId ,
786
785
pub substs : SubstsRef < ' tcx > ,
786
+
787
+ /// Whether the reference to the trait is prefixed by `?const`.
788
+ //
789
+ // FIXME(ecstaticmorse): This field causes `TraitRef` to increase in size by an entire machine
790
+ // word, despite it never being used during trait solving. Try implementing the checks in
791
+ // `qualify_min_const_fn` using `hir::TraitRef` instead.
792
+ pub maybe_const : bool ,
787
793
}
788
794
789
795
impl < ' tcx > TraitRef < ' tcx > {
790
796
pub fn new ( def_id : DefId , substs : SubstsRef < ' tcx > ) -> TraitRef < ' tcx > {
791
- TraitRef { def_id, substs }
797
+ TraitRef :: new_maybe_const ( def_id, substs, false )
798
+ }
799
+
800
+ pub fn new_maybe_const (
801
+ def_id : DefId ,
802
+ substs : SubstsRef < ' tcx > ,
803
+ maybe_const : bool ,
804
+ ) -> TraitRef < ' tcx > {
805
+ TraitRef { def_id, substs, maybe_const }
792
806
}
793
807
794
808
/// Returns a `TraitRef` of the form `P0: Foo<P1..Pn>` where `Pi`
795
809
/// are the parameters defined on trait.
796
810
pub fn identity ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> TraitRef < ' tcx > {
797
- TraitRef { def_id, substs : InternalSubsts :: identity_for_item ( tcx, def_id) }
811
+ TraitRef :: new ( def_id, InternalSubsts :: identity_for_item ( tcx, def_id) )
798
812
}
799
813
800
814
#[ inline]
@@ -817,7 +831,7 @@ impl<'tcx> TraitRef<'tcx> {
817
831
) -> ty:: TraitRef < ' tcx > {
818
832
let defs = tcx. generics_of ( trait_id) ;
819
833
820
- ty:: TraitRef { def_id : trait_id, substs : tcx. intern_substs ( & substs[ ..defs. params . len ( ) ] ) }
834
+ ty:: TraitRef :: new ( trait_id, tcx. intern_substs ( & substs[ ..defs. params . len ( ) ] ) )
821
835
}
822
836
}
823
837
@@ -882,7 +896,7 @@ impl<'tcx> ExistentialTraitRef<'tcx> {
882
896
// otherwise the escaping vars would be captured by the binder
883
897
// debug_assert!(!self_ty.has_escaping_bound_vars());
884
898
885
- ty:: TraitRef { def_id : self . def_id , substs : tcx. mk_substs_trait ( self_ty, self . substs ) }
899
+ ty:: TraitRef :: new ( self . def_id , tcx. mk_substs_trait ( self_ty, self . substs ) )
886
900
}
887
901
}
888
902
@@ -1058,7 +1072,7 @@ impl<'tcx> ProjectionTy<'tcx> {
1058
1072
/// then this function would return a `T: Iterator` trait reference.
1059
1073
pub fn trait_ref ( & self , tcx : TyCtxt < ' tcx > ) -> ty:: TraitRef < ' tcx > {
1060
1074
let def_id = tcx. associated_item ( self . item_def_id ) . container . id ( ) ;
1061
- ty:: TraitRef { def_id, substs : self . substs . truncate_to ( tcx, tcx. generics_of ( def_id) ) }
1075
+ ty:: TraitRef :: new ( def_id, self . substs . truncate_to ( tcx, tcx. generics_of ( def_id) ) )
1062
1076
}
1063
1077
1064
1078
pub fn self_ty ( & self ) -> Ty < ' tcx > {
0 commit comments