Skip to content

Commit 2ad0cbb

Browse files
committed
WIP: implement compute_unstable_feature_goal
1 parent 2d050c9 commit 2ad0cbb

File tree

2 files changed

+26
-1
lines changed
  • compiler/rustc_next_trait_solver/src/solve

2 files changed

+26
-1
lines changed

compiler/rustc_next_trait_solver/src/solve/eval_ctxt/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,9 @@ where
596596
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
597597
self.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) })
598598
}
599-
ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_)) => todo!(),
599+
ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
600+
self.compute_unstable_feature_goal(Goal {param_env, predicate}, symbol)
601+
},
600602
ty::PredicateKind::Subtype(predicate) => {
601603
self.compute_subtype_goal(Goal { param_env, predicate })
602604
}

compiler/rustc_next_trait_solver/src/solve/mod.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,29 @@ where
147147
None => self.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS),
148148
}
149149
}
150+
151+
fn compute_unstable_feature_goal(&mut self, goal: Goal<I, I::Term>, symbol: Symbol) -> QueryResult<I> {
152+
// Iterate through all goals in param_env to find the one that has the same
153+
// symbol as the one in the goal
154+
for pred in goal.param_env.caller_bounds() {
155+
match pred.kind().skip_binder() {
156+
ty::ClauseKind::UnstableFeature(sym) => {
157+
if sym == symbol {
158+
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
159+
}
160+
}
161+
_ => {} // don't care
162+
}
163+
}
164+
165+
166+
// TODO: If stability attrs feature is enabled
167+
//if self.origin_span...
168+
169+
170+
// TODO: If stability attrs feature is not enabled
171+
172+
}
150173

151174
#[instrument(level = "trace", skip(self))]
152175
fn compute_const_evaluatable_goal(

0 commit comments

Comments
 (0)