Skip to content

Commit 9171d47

Browse files
committed
WIP: implement compute_unstable_feature_goal
1 parent f96e6a6 commit 9171d47

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
@@ -528,7 +528,9 @@ where
528528
ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(ct, ty)) => {
529529
self.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) })
530530
}
531-
ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(_)) => todo!(),
531+
ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
532+
self.compute_unstable_feature_goal(Goal {param_env, predicate}, symbol)
533+
},
532534
ty::PredicateKind::Subtype(predicate) => {
533535
self.compute_subtype_goal(Goal { param_env, predicate })
534536
}

compiler/rustc_next_trait_solver/src/solve/mod.rs

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

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

0 commit comments

Comments
 (0)