@@ -10,13 +10,13 @@ use rustc_infer::traits::query::NoSolution;
10
10
use rustc_infer:: traits:: solve:: inspect:: ProbeKind ;
11
11
use rustc_infer:: traits:: solve:: MaybeCause ;
12
12
use rustc_infer:: traits:: Reveal ;
13
+ use rustc_middle:: bug;
13
14
use rustc_middle:: traits:: solve:: { CandidateSource , Certainty , Goal , QueryResult } ;
14
15
use rustc_middle:: traits:: BuiltinImplSource ;
15
16
use rustc_middle:: ty:: fast_reject:: { DeepRejectCtxt , TreatParams } ;
16
17
use rustc_middle:: ty:: NormalizesTo ;
17
18
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
18
19
use rustc_middle:: ty:: { TypeVisitableExt , Upcast } ;
19
- use rustc_middle:: { bug, span_bug} ;
20
20
use rustc_span:: { ErrorGuaranteed , DUMMY_SP } ;
21
21
22
22
mod anon_const;
@@ -200,14 +200,10 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
200
200
201
201
let error_response = |ecx : & mut EvalCtxt < ' _ , InferCtxt < ' tcx > > , reason| {
202
202
let guar = tcx. dcx ( ) . span_delayed_bug ( tcx. def_span ( assoc_def. item . def_id ) , reason) ;
203
- let error_term = match assoc_def. item . kind {
204
- ty:: AssocKind :: Const => ty:: Const :: new_error ( tcx, guar) . into ( ) ,
205
- ty:: AssocKind :: Type => Ty :: new_error ( tcx, guar) . into ( ) ,
206
- // This makes no sense...
207
- ty:: AssocKind :: Fn => span_bug ! (
208
- tcx. def_span( assoc_def. item. def_id) ,
209
- "cannot project to an associated function"
210
- ) ,
203
+ let error_term = match goal. predicate . alias . kind ( tcx) {
204
+ ty:: AliasTermKind :: ProjectionTy => Ty :: new_error ( tcx, guar) . into ( ) ,
205
+ ty:: AliasTermKind :: ProjectionConst => ty:: Const :: new_error ( tcx, guar) . into ( ) ,
206
+ kind => bug ! ( "expected projection, found {kind:?}" ) ,
211
207
} ;
212
208
ecx. instantiate_normalizes_to_term ( goal, error_term) ;
213
209
ecx. evaluate_added_goals_and_make_canonical_response ( Certainty :: Yes )
@@ -238,9 +234,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
238
234
}
239
235
240
236
// Finally we construct the actual value of the associated type.
241
- let term = match assoc_def. item . kind {
242
- ty:: AssocKind :: Type => tcx. type_of ( assoc_def. item . def_id ) . map_bound ( |ty| ty. into ( ) ) ,
243
- ty:: AssocKind :: Const => {
237
+ let term = match goal. predicate . alias . kind ( tcx) {
238
+ ty:: AliasTermKind :: ProjectionTy => {
239
+ tcx. type_of ( assoc_def. item . def_id ) . map_bound ( |ty| ty. into ( ) )
240
+ }
241
+ ty:: AliasTermKind :: ProjectionConst => {
244
242
if tcx. features ( ) . associated_const_equality {
245
243
bug ! ( "associated const projection is not supported yet" )
246
244
} else {
@@ -254,7 +252,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
254
252
)
255
253
}
256
254
}
257
- ty :: AssocKind :: Fn => unreachable ! ( "we should never project to a fn " ) ,
255
+ kind => bug ! ( "expected projection, found {kind:?} " ) ,
258
256
} ;
259
257
260
258
ecx. instantiate_normalizes_to_term ( goal, term. instantiate ( tcx, associated_item_args) ) ;
0 commit comments