@@ -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:: { assert_matches , debug_assert_matches} ;
25+ use std:: assert_matches:: debug_assert_matches;
2626use std:: borrow:: Cow ;
2727use std:: iter;
2828use std:: ops:: { ControlFlow , Deref , Range } ;
@@ -1137,8 +1137,8 @@ pub struct AliasTerm<'tcx> {
11371137 /// aka. `tcx.parent(def_id)`.
11381138 pub def_id : DefId ,
11391139
1140- /// This field exists to prevent the creation of `AliasTy ` without using
1141- /// [AliasTy ::new].
1140+ /// This field exists to prevent the creation of `AliasTerm ` without using
1141+ /// [AliasTerm ::new].
11421142 _use_alias_term_new_instead : ( ) ,
11431143}
11441144
@@ -1202,13 +1202,15 @@ impl<'tcx> AliasTerm<'tcx> {
12021202 }
12031203
12041204 pub fn expect_ty ( self , tcx : TyCtxt < ' tcx > ) -> AliasTy < ' tcx > {
1205- assert_matches ! (
1206- self . kind( tcx) ,
1205+ match self . kind ( tcx) {
12071206 ty:: AliasTermKind :: ProjectionTy
1208- | ty:: AliasTermKind :: OpaqueTy
1209- | ty:: AliasTermKind :: WeakTy
1210- | ty:: AliasTermKind :: InherentTy
1211- ) ;
1207+ | ty:: AliasTermKind :: InherentTy
1208+ | ty:: AliasTermKind :: OpaqueTy
1209+ | ty:: AliasTermKind :: WeakTy => { }
1210+ ty:: AliasTermKind :: UnevaluatedConst => {
1211+ bug ! ( "Cannot turn `UnevaluatedConst` into `AliasTy`" )
1212+ }
1213+ }
12121214 ty:: AliasTy { def_id : self . def_id , args : self . args , _use_alias_ty_new_instead : ( ) }
12131215 }
12141216
@@ -1229,7 +1231,7 @@ impl<'tcx> AliasTerm<'tcx> {
12291231 }
12301232}
12311233
1232- /// The following methods work only with (trait) associated type projections.
1234+ /// The following methods work only with (trait) associated item projections.
12331235impl < ' tcx > AliasTerm < ' tcx > {
12341236 pub fn self_ty ( self ) -> Ty < ' tcx > {
12351237 self . args . type_at ( 0 )
@@ -1269,7 +1271,6 @@ impl<'tcx> AliasTerm<'tcx> {
12691271 self ,
12701272 tcx : TyCtxt < ' tcx > ,
12711273 ) -> ( ty:: TraitRef < ' tcx > , & ' tcx [ ty:: GenericArg < ' tcx > ] ) {
1272- debug_assert ! ( matches!( tcx. def_kind( self . def_id) , DefKind :: AssocTy | DefKind :: AssocConst ) ) ;
12731274 let trait_def_id = self . trait_def_id ( tcx) ;
12741275 let trait_generics = tcx. generics_of ( trait_def_id) ;
12751276 (
@@ -1358,7 +1359,7 @@ pub struct AliasTy<'tcx> {
13581359 /// aka. `tcx.parent(def_id)`.
13591360 pub def_id : DefId ,
13601361
1361- /// This field exists to prevent the creation of `AliasTy ` without using
1362+ /// This field exists to prevent the creation of `AliasT ` without using
13621363 /// [AliasTy::new].
13631364 _use_alias_ty_new_instead : ( ) ,
13641365}
@@ -1422,7 +1423,6 @@ impl<'tcx> AliasTy<'tcx> {
14221423 self ,
14231424 tcx : TyCtxt < ' tcx > ,
14241425 ) -> ( ty:: TraitRef < ' tcx > , & ' tcx [ ty:: GenericArg < ' tcx > ] ) {
1425- debug_assert ! ( matches!( tcx. def_kind( self . def_id) , DefKind :: AssocTy | DefKind :: AssocConst ) ) ;
14261426 let trait_def_id = self . trait_def_id ( tcx) ;
14271427 let trait_generics = tcx. generics_of ( trait_def_id) ;
14281428 (
0 commit comments