@@ -25,8 +25,9 @@ use super::GenericParamDefKind;
2525use crate :: infer:: canonical:: Canonical ;
2626use crate :: ty:: InferTy :: * ;
2727use crate :: ty:: {
28- self , AdtDef , BoundRegionKind , Discr , GenericArg , GenericArgs , GenericArgsRef , List , ParamEnv ,
29- Region , Ty , TyCtxt , TypeFlags , TypeSuperVisitable , TypeVisitable , TypeVisitor , UintTy ,
28+ self , AdtDef , BoundRegionKind , Discr , FieldPath , GenericArg , GenericArgs , GenericArgsRef , List ,
29+ ParamEnv , Region , Ty , TyCtxt , TypeFlags , TypeSuperVisitable , TypeVisitable , TypeVisitor ,
30+ UintTy ,
3031} ;
3132
3233// Re-export and re-parameterize some `I = TyCtxt<'tcx>` types here
@@ -667,6 +668,15 @@ impl<'tcx> Ty<'tcx> {
667668 Ty :: new ( tcx, Adt ( def, args) )
668669 }
669670
671+ pub fn new_field_type (
672+ tcx : TyCtxt < ' tcx > ,
673+ container : Ty < ' tcx > ,
674+ field_path : FieldPath < ' tcx > ,
675+ ) -> Ty < ' tcx > {
676+ assert ! ( !field_path. 0 . is_empty( ) ) ;
677+ Ty :: new ( tcx, Field ( container, field_path) )
678+ }
679+
670680 #[ inline]
671681 pub fn new_foreign ( tcx : TyCtxt < ' tcx > , def_id : DefId ) -> Ty < ' tcx > {
672682 Ty :: new ( tcx, Foreign ( def_id) )
@@ -972,6 +982,14 @@ impl<'tcx> rustc_type_ir::inherent::Ty<TyCtxt<'tcx>> for Ty<'tcx> {
972982 Ty :: new_adt ( interner, adt_def, args)
973983 }
974984
985+ fn new_field_type (
986+ interner : TyCtxt < ' tcx > ,
987+ container : Ty < ' tcx > ,
988+ field_path : FieldPath < ' tcx > ,
989+ ) -> Self {
990+ Ty :: new_field_type ( interner, container, field_path)
991+ }
992+
975993 fn new_foreign ( interner : TyCtxt < ' tcx > , def_id : DefId ) -> Self {
976994 Ty :: new_foreign ( interner, def_id)
977995 }
@@ -1967,6 +1985,7 @@ impl<'tcx> Ty<'tcx> {
19671985 } ,
19681986
19691987 ty:: Adt ( _, _)
1988+ | ty:: Field ( _, _)
19701989 | ty:: Tuple ( _)
19711990 | ty:: Array ( ..)
19721991 | ty:: Foreign ( _)
0 commit comments