@@ -22,7 +22,7 @@ use rustc_span::symbol::{sym, Symbol};
22
22
use rustc_span:: { Span , DUMMY_SP } ;
23
23
use rustc_target:: abi:: { FieldIdx , VariantIdx , FIRST_VARIANT } ;
24
24
use rustc_target:: spec:: abi:: { self , Abi } ;
25
- use std:: assert_matches:: { assert_matches , debug_assert_matches} ;
25
+ use std:: assert_matches:: debug_assert_matches;
26
26
use std:: borrow:: Cow ;
27
27
use std:: iter;
28
28
use std:: ops:: { ControlFlow , Deref , Range } ;
@@ -1137,8 +1137,8 @@ pub struct AliasTerm<'tcx> {
1137
1137
/// aka. `tcx.parent(def_id)`.
1138
1138
pub def_id : DefId ,
1139
1139
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].
1142
1142
_use_alias_term_new_instead : ( ) ,
1143
1143
}
1144
1144
@@ -1202,13 +1202,15 @@ impl<'tcx> AliasTerm<'tcx> {
1202
1202
}
1203
1203
1204
1204
pub fn expect_ty ( self , tcx : TyCtxt < ' tcx > ) -> AliasTy < ' tcx > {
1205
- assert_matches ! (
1206
- self . kind( tcx) ,
1205
+ match self . kind ( tcx) {
1207
1206
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
+ }
1212
1214
ty:: AliasTy { def_id : self . def_id , args : self . args , _use_alias_ty_new_instead : ( ) }
1213
1215
}
1214
1216
@@ -1229,7 +1231,7 @@ impl<'tcx> AliasTerm<'tcx> {
1229
1231
}
1230
1232
}
1231
1233
1232
- /// The following methods work only with (trait) associated type projections.
1234
+ /// The following methods work only with (trait) associated item projections.
1233
1235
impl < ' tcx > AliasTerm < ' tcx > {
1234
1236
pub fn self_ty ( self ) -> Ty < ' tcx > {
1235
1237
self . args . type_at ( 0 )
@@ -1269,7 +1271,6 @@ impl<'tcx> AliasTerm<'tcx> {
1269
1271
self ,
1270
1272
tcx : TyCtxt < ' tcx > ,
1271
1273
) -> ( ty:: TraitRef < ' tcx > , & ' tcx [ ty:: GenericArg < ' tcx > ] ) {
1272
- debug_assert ! ( matches!( tcx. def_kind( self . def_id) , DefKind :: AssocTy | DefKind :: AssocConst ) ) ;
1273
1274
let trait_def_id = self . trait_def_id ( tcx) ;
1274
1275
let trait_generics = tcx. generics_of ( trait_def_id) ;
1275
1276
(
@@ -1358,7 +1359,7 @@ pub struct AliasTy<'tcx> {
1358
1359
/// aka. `tcx.parent(def_id)`.
1359
1360
pub def_id : DefId ,
1360
1361
1361
- /// This field exists to prevent the creation of `AliasTy ` without using
1362
+ /// This field exists to prevent the creation of `AliasT ` without using
1362
1363
/// [AliasTy::new].
1363
1364
_use_alias_ty_new_instead : ( ) ,
1364
1365
}
@@ -1422,7 +1423,6 @@ impl<'tcx> AliasTy<'tcx> {
1422
1423
self ,
1423
1424
tcx : TyCtxt < ' tcx > ,
1424
1425
) -> ( ty:: TraitRef < ' tcx > , & ' tcx [ ty:: GenericArg < ' tcx > ] ) {
1425
- debug_assert ! ( matches!( tcx. def_kind( self . def_id) , DefKind :: AssocTy | DefKind :: AssocConst ) ) ;
1426
1426
let trait_def_id = self . trait_def_id ( tcx) ;
1427
1427
let trait_generics = tcx. generics_of ( trait_def_id) ;
1428
1428
(
0 commit comments