Skip to content

Commit 0b68060

Browse files
Stop using AssocKind in new solver
1 parent 2ea9c31 commit 0b68060

File tree

1 file changed

+11
-13
lines changed
  • compiler/rustc_trait_selection/src/solve/normalizes_to

1 file changed

+11
-13
lines changed

compiler/rustc_trait_selection/src/solve/normalizes_to/mod.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ use rustc_infer::traits::query::NoSolution;
1010
use rustc_infer::traits::solve::inspect::ProbeKind;
1111
use rustc_infer::traits::solve::MaybeCause;
1212
use rustc_infer::traits::Reveal;
13+
use rustc_middle::bug;
1314
use rustc_middle::traits::solve::{CandidateSource, Certainty, Goal, QueryResult};
1415
use rustc_middle::traits::BuiltinImplSource;
1516
use rustc_middle::ty::fast_reject::{DeepRejectCtxt, TreatParams};
1617
use rustc_middle::ty::NormalizesTo;
1718
use rustc_middle::ty::{self, Ty, TyCtxt};
1819
use rustc_middle::ty::{TypeVisitableExt, Upcast};
19-
use rustc_middle::{bug, span_bug};
2020
use rustc_span::{ErrorGuaranteed, DUMMY_SP};
2121

2222
mod anon_const;
@@ -200,14 +200,10 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
200200

201201
let error_response = |ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>, reason| {
202202
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:?}"),
211207
};
212208
ecx.instantiate_normalizes_to_term(goal, error_term);
213209
ecx.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
@@ -238,9 +234,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
238234
}
239235

240236
// 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 => {
244242
if tcx.features().associated_const_equality {
245243
bug!("associated const projection is not supported yet")
246244
} else {
@@ -254,7 +252,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
254252
)
255253
}
256254
}
257-
ty::AssocKind::Fn => unreachable!("we should never project to a fn"),
255+
kind => bug!("expected projection, found {kind:?}"),
258256
};
259257

260258
ecx.instantiate_normalizes_to_term(goal, term.instantiate(tcx, associated_item_args));

0 commit comments

Comments
 (0)