Skip to content

Commit 2ed1bdb

Browse files
Stop using def_kind() in solver
1 parent 6ee22e1 commit 2ed1bdb

File tree

1 file changed

+8
-17
lines changed
  • compiler/rustc_trait_selection/src/solve/normalizes_to

1 file changed

+8
-17
lines changed

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

+8-17
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use crate::traits::specialization_graph;
33
use super::assembly::structural_traits::AsyncCallableRelevantTypes;
44
use super::assembly::{self, structural_traits, Candidate};
55
use super::{EvalCtxt, GoalSource};
6-
use rustc_hir::def::DefKind;
76
use rustc_hir::def_id::DefId;
87
use rustc_hir::LangItem;
98
use rustc_infer::traits::query::NoSolution;
@@ -54,23 +53,15 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
5453
&mut self,
5554
goal: Goal<'tcx, NormalizesTo<'tcx>>,
5655
) -> QueryResult<'tcx> {
57-
let def_id = goal.predicate.def_id();
58-
match self.tcx().def_kind(def_id) {
59-
DefKind::AssocTy | DefKind::AssocConst => {
60-
match self.tcx().associated_item(def_id).container {
61-
ty::AssocItemContainer::TraitContainer => {
62-
let candidates = self.assemble_and_evaluate_candidates(goal);
63-
self.merge_candidates(candidates)
64-
}
65-
ty::AssocItemContainer::ImplContainer => {
66-
self.normalize_inherent_associated_type(goal)
67-
}
68-
}
56+
match goal.predicate.alias.kind(self.tcx()) {
57+
ty::AliasTermKind::ProjectionTy | ty::AliasTermKind::ProjectionConst => {
58+
let candidates = self.assemble_and_evaluate_candidates(goal);
59+
self.merge_candidates(candidates)
6960
}
70-
DefKind::AnonConst => self.normalize_anon_const(goal),
71-
DefKind::TyAlias => self.normalize_weak_type(goal),
72-
DefKind::OpaqueTy => self.normalize_opaque_type(goal),
73-
kind => bug!("unknown DefKind {} in normalizes-to goal: {goal:#?}", kind.descr(def_id)),
61+
ty::AliasTermKind::InherentTy => self.normalize_inherent_associated_type(goal),
62+
ty::AliasTermKind::OpaqueTy => self.normalize_opaque_type(goal),
63+
ty::AliasTermKind::WeakTy => self.normalize_weak_type(goal),
64+
ty::AliasTermKind::UnevaluatedConst => self.normalize_anon_const(goal),
7465
}
7566
}
7667

0 commit comments

Comments
 (0)