|
32 | 32 | debug_assert!(self.term_is_fully_unconstrained(goal)); |
33 | 33 | let cx = self.cx(); |
34 | 34 | match goal.predicate.alias.kind(cx) { |
35 | | - ty::AliasTermKind::ProjectionTy | ty::AliasTermKind::ProjectionConst => { |
| 35 | + ty::AliasTermKind::ProjectionTy | ty::AliasTermKind::ProjectionConst { .. } => { |
36 | 36 | let trait_ref = goal.predicate.alias.trait_ref(cx); |
37 | 37 | let (_, proven_via) = |
38 | 38 | self.probe(|_| ProbeKind::ShadowedEnvProbing).enter(|ecx| { |
@@ -83,11 +83,11 @@ where |
83 | 83 | }, |
84 | 84 | ) |
85 | 85 | } |
86 | | - ty::AliasTermKind::InherentTy | ty::AliasTermKind::InherentConst => { |
| 86 | + ty::AliasTermKind::InherentTy | ty::AliasTermKind::InherentConst { .. } => { |
87 | 87 | self.normalize_inherent_associated_term(goal) |
88 | 88 | } |
89 | 89 | ty::AliasTermKind::OpaqueTy => self.normalize_opaque_type(goal), |
90 | | - ty::AliasTermKind::FreeTy | ty::AliasTermKind::FreeConst => { |
| 90 | + ty::AliasTermKind::FreeTy | ty::AliasTermKind::FreeConst { .. } => { |
91 | 91 | self.normalize_free_alias(goal) |
92 | 92 | } |
93 | 93 | ty::AliasTermKind::UnevaluatedConst => self.normalize_anon_const(goal), |
@@ -264,7 +264,7 @@ where |
264 | 264 | let error_response = |ecx: &mut EvalCtxt<'_, D>, guar| { |
265 | 265 | let error_term = match goal.predicate.alias.kind(cx) { |
266 | 266 | ty::AliasTermKind::ProjectionTy => Ty::new_error(cx, guar).into(), |
267 | | - ty::AliasTermKind::ProjectionConst => Const::new_error(cx, guar).into(), |
| 267 | + ty::AliasTermKind::ProjectionConst { .. } => Const::new_error(cx, guar).into(), |
268 | 268 | kind => panic!("expected projection, found {kind:?}"), |
269 | 269 | }; |
270 | 270 | ecx.instantiate_normalizes_to_term(goal, error_term); |
@@ -380,15 +380,29 @@ where |
380 | 380 | // Finally we construct the actual value of the associated type. |
381 | 381 | let term = match goal.predicate.alias.kind(cx) { |
382 | 382 | ty::AliasTermKind::ProjectionTy => { |
383 | | - cx.type_of(target_item_def_id).map_bound(|ty| ty.into()) |
| 383 | + cx.type_of(target_item_def_id).instantiate(cx, target_args).into() |
384 | 384 | } |
385 | | - ty::AliasTermKind::ProjectionConst => { |
386 | | - cx.const_of_item(target_item_def_id).map_bound(|ct| ct.into()) |
| 385 | + ty::AliasTermKind::ProjectionConst { is_type_const: true } => { |
| 386 | + cx.const_of_item(target_item_def_id).instantiate(cx, target_args).into() |
| 387 | + } |
| 388 | + ty::AliasTermKind::ProjectionConst { is_type_const: false } => { |
| 389 | + ecx.try_evaluate_added_goals()?; |
| 390 | + let uv = ty::UnevaluatedConst::new( |
| 391 | + target_item_def_id.try_into().unwrap(), |
| 392 | + target_args, |
| 393 | + ); |
| 394 | + if let Some(eval) = ecx.evaluate_const(goal.param_env, uv) { |
| 395 | + eval.into() |
| 396 | + } else { |
| 397 | + return ecx.evaluate_added_goals_and_make_canonical_response( |
| 398 | + Certainty::AMBIGUOUS, |
| 399 | + ); |
| 400 | + } |
387 | 401 | } |
388 | 402 | kind => panic!("expected projection, found {kind:?}"), |
389 | 403 | }; |
390 | 404 |
|
391 | | - ecx.instantiate_normalizes_to_term(goal, term.instantiate(cx, target_args)); |
| 405 | + ecx.instantiate_normalizes_to_term(goal, term); |
392 | 406 | ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes) |
393 | 407 | }) |
394 | 408 | } |
|
0 commit comments