Skip to content

Commit ab02e3e

Browse files
committed
WIP2: compute_unstable_feature_goal
1 parent 9171d47 commit ab02e3e

File tree

4 files changed

+15
-10
lines changed

4 files changed

+15
-10
lines changed

compiler/rustc_middle/src/ty/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,10 @@ impl<'tcx> rustc_type_ir::inherent::Features<TyCtxt<'tcx>> for &'tcx rustc_featu
814814
fn associated_const_equality(self) -> bool {
815815
self.associated_const_equality()
816816
}
817+
818+
fn impl_stability(self) -> bool {
819+
self.impl_stability()
820+
}
817821
}
818822

819823
impl<'tcx> rustc_type_ir::inherent::Span<TyCtxt<'tcx>> for Span {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ where
529529
self.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) })
530530
}
531531
ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
532-
self.compute_unstable_feature_goal(Goal {param_env, predicate}, symbol)
532+
self.compute_unstable_feature_goal(param_env, symbol)
533533
},
534534
ty::PredicateKind::Subtype(predicate) => {
535535
self.compute_subtype_goal(Goal { param_env, predicate })

compiler/rustc_next_trait_solver/src/solve/mod.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -147,26 +147,25 @@ where
147147
}
148148
}
149149

150-
fn compute_unstable_feature_goal(&mut self, goal: Goal<I, I::Term>, symbol: Symbol) -> QueryResult<I> {
150+
fn compute_unstable_feature_goal(&mut self, param_env: <I as Interner>::ParamEnv, symbol: <I as Interner>::Symbol) -> QueryResult<I> {
151151
// Iterate through all goals in param_env to find the one that has the same
152152
// symbol as the one in the goal
153-
for pred in goal.param_env.caller_bounds() {
153+
for pred in param_env.caller_bounds().iter() {
154154
match pred.kind().skip_binder() {
155155
ty::ClauseKind::UnstableFeature(sym) => {
156156
if sym == symbol {
157-
self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes)
157+
return self.evaluate_added_goals_and_make_canonical_response(Certainty::Yes);
158158
}
159159
}
160160
_ => {} // don't care
161161
}
162162
}
163163

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
164+
if self.cx().features().impl_stability() {
165+
return self.evaluate_added_goals_and_make_canonical_response(Certainty::Maybe(MaybeCause::Ambiguity));
166+
} else {
167+
todo!();
168+
}
170169

171170
}
172171

compiler/rustc_type_ir/src/inherent.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,8 @@ pub trait Features<I: Interner>: Copy {
570570
fn coroutine_clone(self) -> bool;
571571

572572
fn associated_const_equality(self) -> bool;
573+
574+
fn impl_stability(self) -> bool;
573575
}
574576

575577
pub trait DefId<I: Interner>: Copy + Debug + Hash + Eq + TypeFoldable<I> {

0 commit comments

Comments
 (0)