Skip to content

Commit d87b6a3

Browse files
committed
WIP2: compute_unstable_feature_goal
1 parent 2ad0cbb commit d87b6a3

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
@@ -817,6 +817,10 @@ impl<'tcx> rustc_type_ir::inherent::Features<TyCtxt<'tcx>> for &'tcx rustc_featu
817817
fn associated_const_equality(self) -> bool {
818818
self.associated_const_equality()
819819
}
820+
821+
fn impl_stability(self) -> bool {
822+
self.impl_stability()
823+
}
820824
}
821825

822826
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
@@ -597,7 +597,7 @@ where
597597
self.compute_const_arg_has_type_goal(Goal { param_env, predicate: (ct, ty) })
598598
}
599599
ty::PredicateKind::Clause(ty::ClauseKind::UnstableFeature(symbol)) => {
600-
self.compute_unstable_feature_goal(Goal {param_env, predicate}, symbol)
600+
self.compute_unstable_feature_goal(param_env, symbol)
601601
},
602602
ty::PredicateKind::Subtype(predicate) => {
603603
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
@@ -148,26 +148,25 @@ where
148148
}
149149
}
150150

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

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

172171
}
173172

compiler/rustc_type_ir/src/inherent.rs

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

585585
fn associated_const_equality(self) -> bool;
586+
587+
fn impl_stability(self) -> bool;
586588
}
587589

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

0 commit comments

Comments
 (0)