@@ -22,7 +22,7 @@ use rustc_span::symbol::{sym, Symbol};
2222use rustc_span:: { Span , DUMMY_SP } ;
2323use rustc_target:: abi:: { FieldIdx , VariantIdx , FIRST_VARIANT } ;
2424use rustc_target:: spec:: abi:: { self , Abi } ;
25- use std:: assert_matches:: debug_assert_matches;
25+ use std:: assert_matches:: { assert_matches , debug_assert_matches} ;
2626use std:: borrow:: Cow ;
2727use std:: iter;
2828use std:: ops:: { ControlFlow , Deref , Range } ;
@@ -1195,24 +1195,31 @@ impl<'tcx> AliasTerm<'tcx> {
11951195 tcx : TyCtxt < ' tcx > ,
11961196 def_id : DefId ,
11971197 args : impl IntoIterator < Item : Into < GenericArg < ' tcx > > > ,
1198- ) -> ty :: AliasTerm < ' tcx > {
1198+ ) -> AliasTerm < ' tcx > {
11991199 let args = tcx. check_and_mk_args ( def_id, args) ;
1200- ty :: AliasTerm { def_id, args, _use_alias_term_new_instead : ( ) }
1200+ AliasTerm { def_id, args, _use_alias_term_new_instead : ( ) }
12011201 }
12021202
1203- pub fn expect_ty ( self , _interner : TyCtxt < ' tcx > ) -> AliasTy < ' tcx > {
1204- todo ! ( )
1203+ pub fn expect_ty ( self , tcx : TyCtxt < ' tcx > ) -> AliasTy < ' tcx > {
1204+ assert_matches ! (
1205+ self . kind( tcx) ,
1206+ ty:: AliasTermKind :: ProjectionTy
1207+ | ty:: AliasTermKind :: OpaqueTy
1208+ | ty:: AliasTermKind :: WeakTy
1209+ | ty:: AliasTermKind :: InherentTy
1210+ ) ;
1211+ ty:: AliasTy { def_id : self . def_id , args : self . args , _use_alias_ty_new_instead : ( ) }
12051212 }
12061213
12071214 pub fn kind ( self , tcx : TyCtxt < ' tcx > ) -> ty:: AliasTermKind {
12081215 match tcx. def_kind ( self . def_id ) {
1209- DefKind :: AssocTy
1210- if let DefKind :: Impl { of_trait : false } =
1211- tcx. def_kind ( tcx. parent ( self . def_id ) ) =>
1212- {
1213- ty:: AliasTermKind :: InherentTy
1216+ DefKind :: AssocTy => {
1217+ if let DefKind :: Impl { of_trait : false } = tcx. def_kind ( tcx. parent ( self . def_id ) ) {
1218+ ty:: AliasTermKind :: InherentTy
1219+ } else {
1220+ ty:: AliasTermKind :: ProjectionTy
1221+ }
12141222 }
1215- DefKind :: AssocTy => ty:: AliasTermKind :: ProjectionTy ,
12161223 DefKind :: OpaqueTy => ty:: AliasTermKind :: OpaqueTy ,
12171224 DefKind :: TyAlias => ty:: AliasTermKind :: WeakTy ,
12181225 DefKind :: AssocConst | DefKind :: AnonConst => ty:: AliasTermKind :: UnevaluatedConst ,
@@ -1312,6 +1319,12 @@ impl<'tcx> From<AliasTy<'tcx>> for AliasTerm<'tcx> {
13121319 }
13131320}
13141321
1322+ impl < ' tcx > From < ty:: UnevaluatedConst < ' tcx > > for AliasTerm < ' tcx > {
1323+ fn from ( ct : ty:: UnevaluatedConst < ' tcx > ) -> Self {
1324+ AliasTerm { args : ct. args , def_id : ct. def , _use_alias_term_new_instead : ( ) }
1325+ }
1326+ }
1327+
13151328/// Represents the projection of an associated type.
13161329///
13171330/// * For a projection, this would be `<Ty as Trait<...>>::N<...>`.
0 commit comments