Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3ee9366

Browse files
authoredMay 20, 2024
Unrolled build for rust-lang#125255
Rollup merge of rust-lang#125255 - compiler-errors:eval-ctxt-generic, r=lcnr Make `EvalCtxt` generic over `InferCtxtLike` ...but don't change any of the impls, yet! These can get uplifted as we add more methods to `InferCtxtLike`/`Interner` :3 This is built on top of rust-lang#125230. r? lcnr
2 parents 44d679b + 9dc073a commit 3ee9366

File tree

19 files changed

+212
-174
lines changed

19 files changed

+212
-174
lines changed
 

‎compiler/rustc_middle/src/ty/context.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,10 @@ impl<'tcx> Interner for TyCtxt<'tcx> {
233233
fn parent(self, def_id: Self::DefId) -> Self::DefId {
234234
self.parent(def_id)
235235
}
236+
237+
fn recursion_limit(self) -> usize {
238+
self.recursion_limit().0
239+
}
236240
}
237241

238242
impl<'tcx> rustc_type_ir::inherent::Abi<TyCtxt<'tcx>> for abi::Abi {

‎compiler/rustc_middle/src/ty/predicate.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,11 @@ pub struct Predicate<'tcx>(
3737
pub(super) Interned<'tcx, WithCachedTypeInfo<ty::Binder<'tcx, PredicateKind<'tcx>>>>,
3838
);
3939

40-
impl<'tcx> rustc_type_ir::inherent::Predicate<TyCtxt<'tcx>> for Predicate<'tcx> {}
40+
impl<'tcx> rustc_type_ir::inherent::Predicate<TyCtxt<'tcx>> for Predicate<'tcx> {
41+
fn is_coinductive(self, interner: TyCtxt<'tcx>) -> bool {
42+
self.is_coinductive(interner)
43+
}
44+
}
4145

4246
impl<'tcx> rustc_type_ir::visit::Flags for Predicate<'tcx> {
4347
fn flags(&self) -> TypeFlags {

‎compiler/rustc_trait_selection/src/solve/alias_relate.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@
1616
//! relate them structurally.
1717
1818
use super::EvalCtxt;
19+
use rustc_infer::infer::InferCtxt;
1920
use rustc_middle::traits::solve::{Certainty, Goal, QueryResult};
2021
use rustc_middle::ty;
2122

22-
impl<'tcx> EvalCtxt<'_, 'tcx> {
23+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
2324
#[instrument(level = "trace", skip(self), ret)]
2425
pub(super) fn compute_alias_relate_goal(
2526
&mut self,

‎compiler/rustc_trait_selection/src/solve/assembly/mod.rs

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Code shared by trait and projection goals for candidate assembly.
22
3-
use crate::solve::GoalSource;
4-
use crate::solve::{EvalCtxt, SolverMode};
53
use rustc_hir::def_id::DefId;
4+
use rustc_infer::infer::InferCtxt;
65
use rustc_infer::traits::query::NoSolution;
76
use rustc_middle::bug;
87
use rustc_middle::traits::solve::inspect::ProbeKind;
@@ -17,6 +16,9 @@ use rustc_middle::ty::{TypeVisitableExt, Upcast};
1716
use rustc_span::{ErrorGuaranteed, DUMMY_SP};
1817
use std::fmt::Debug;
1918

19+
use crate::solve::GoalSource;
20+
use crate::solve::{EvalCtxt, SolverMode};
21+
2022
pub(super) mod structural_traits;
2123

2224
/// A candidate is a possible way to prove a goal.
@@ -46,18 +48,18 @@ pub(super) trait GoalKind<'tcx>:
4648
/// work, then produce a response (typically by executing
4749
/// [`EvalCtxt::evaluate_added_goals_and_make_canonical_response`]).
4850
fn probe_and_match_goal_against_assumption(
49-
ecx: &mut EvalCtxt<'_, 'tcx>,
51+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
5052
source: CandidateSource<'tcx>,
5153
goal: Goal<'tcx, Self>,
5254
assumption: ty::Clause<'tcx>,
53-
then: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> QueryResult<'tcx>,
55+
then: impl FnOnce(&mut EvalCtxt<'_, InferCtxt<'tcx>>) -> QueryResult<'tcx>,
5456
) -> Result<Candidate<'tcx>, NoSolution>;
5557

5658
/// Consider a clause, which consists of a "assumption" and some "requirements",
5759
/// to satisfy a goal. If the requirements hold, then attempt to satisfy our
5860
/// goal by equating it with the assumption.
5961
fn probe_and_consider_implied_clause(
60-
ecx: &mut EvalCtxt<'_, 'tcx>,
62+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
6163
parent_source: CandidateSource<'tcx>,
6264
goal: Goal<'tcx, Self>,
6365
assumption: ty::Clause<'tcx>,
@@ -75,7 +77,7 @@ pub(super) trait GoalKind<'tcx>:
7577
/// additionally checking all of the supertraits and object bounds to hold,
7678
/// since they're not implied by the well-formedness of the object type.
7779
fn probe_and_consider_object_bound_candidate(
78-
ecx: &mut EvalCtxt<'_, 'tcx>,
80+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
7981
source: CandidateSource<'tcx>,
8082
goal: Goal<'tcx, Self>,
8183
assumption: ty::Clause<'tcx>,
@@ -99,7 +101,7 @@ pub(super) trait GoalKind<'tcx>:
99101
}
100102

101103
fn consider_impl_candidate(
102-
ecx: &mut EvalCtxt<'_, 'tcx>,
104+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
103105
goal: Goal<'tcx, Self>,
104106
impl_def_id: DefId,
105107
) -> Result<Candidate<'tcx>, NoSolution>;
@@ -111,7 +113,7 @@ pub(super) trait GoalKind<'tcx>:
111113
/// Trait goals always hold while projection goals never do. This is a bit arbitrary
112114
/// but prevents incorrect normalization while hiding any trait errors.
113115
fn consider_error_guaranteed_candidate(
114-
ecx: &mut EvalCtxt<'_, 'tcx>,
116+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
115117
guar: ErrorGuaranteed,
116118
) -> Result<Candidate<'tcx>, NoSolution>;
117119

@@ -120,13 +122,13 @@ pub(super) trait GoalKind<'tcx>:
120122
/// These components are given by built-in rules from
121123
/// [`structural_traits::instantiate_constituent_tys_for_auto_trait`].
122124
fn consider_auto_trait_candidate(
123-
ecx: &mut EvalCtxt<'_, 'tcx>,
125+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
124126
goal: Goal<'tcx, Self>,
125127
) -> Result<Candidate<'tcx>, NoSolution>;
126128

127129
/// A trait alias holds if the RHS traits and `where` clauses hold.
128130
fn consider_trait_alias_candidate(
129-
ecx: &mut EvalCtxt<'_, 'tcx>,
131+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
130132
goal: Goal<'tcx, Self>,
131133
) -> Result<Candidate<'tcx>, NoSolution>;
132134

@@ -135,7 +137,7 @@ pub(super) trait GoalKind<'tcx>:
135137
/// These components are given by built-in rules from
136138
/// [`structural_traits::instantiate_constituent_tys_for_sized_trait`].
137139
fn consider_builtin_sized_candidate(
138-
ecx: &mut EvalCtxt<'_, 'tcx>,
140+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
139141
goal: Goal<'tcx, Self>,
140142
) -> Result<Candidate<'tcx>, NoSolution>;
141143

@@ -144,35 +146,35 @@ pub(super) trait GoalKind<'tcx>:
144146
/// These components are given by built-in rules from
145147
/// [`structural_traits::instantiate_constituent_tys_for_copy_clone_trait`].
146148
fn consider_builtin_copy_clone_candidate(
147-
ecx: &mut EvalCtxt<'_, 'tcx>,
149+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
148150
goal: Goal<'tcx, Self>,
149151
) -> Result<Candidate<'tcx>, NoSolution>;
150152

151153
/// A type is `PointerLike` if we can compute its layout, and that layout
152154
/// matches the layout of `usize`.
153155
fn consider_builtin_pointer_like_candidate(
154-
ecx: &mut EvalCtxt<'_, 'tcx>,
156+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
155157
goal: Goal<'tcx, Self>,
156158
) -> Result<Candidate<'tcx>, NoSolution>;
157159

158160
/// A type is a `FnPtr` if it is of `FnPtr` type.
159161
fn consider_builtin_fn_ptr_trait_candidate(
160-
ecx: &mut EvalCtxt<'_, 'tcx>,
162+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
161163
goal: Goal<'tcx, Self>,
162164
) -> Result<Candidate<'tcx>, NoSolution>;
163165

164166
/// A callable type (a closure, fn def, or fn ptr) is known to implement the `Fn<A>`
165167
/// family of traits where `A` is given by the signature of the type.
166168
fn consider_builtin_fn_trait_candidates(
167-
ecx: &mut EvalCtxt<'_, 'tcx>,
169+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
168170
goal: Goal<'tcx, Self>,
169171
kind: ty::ClosureKind,
170172
) -> Result<Candidate<'tcx>, NoSolution>;
171173

172174
/// An async closure is known to implement the `AsyncFn<A>` family of traits
173175
/// where `A` is given by the signature of the type.
174176
fn consider_builtin_async_fn_trait_candidates(
175-
ecx: &mut EvalCtxt<'_, 'tcx>,
177+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
176178
goal: Goal<'tcx, Self>,
177179
kind: ty::ClosureKind,
178180
) -> Result<Candidate<'tcx>, NoSolution>;
@@ -181,13 +183,13 @@ pub(super) trait GoalKind<'tcx>:
181183
/// is used internally to delay computation for async closures until after
182184
/// upvar analysis is performed in HIR typeck.
183185
fn consider_builtin_async_fn_kind_helper_candidate(
184-
ecx: &mut EvalCtxt<'_, 'tcx>,
186+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
185187
goal: Goal<'tcx, Self>,
186188
) -> Result<Candidate<'tcx>, NoSolution>;
187189

188190
/// `Tuple` is implemented if the `Self` type is a tuple.
189191
fn consider_builtin_tuple_candidate(
190-
ecx: &mut EvalCtxt<'_, 'tcx>,
192+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
191193
goal: Goal<'tcx, Self>,
192194
) -> Result<Candidate<'tcx>, NoSolution>;
193195

@@ -197,63 +199,63 @@ pub(super) trait GoalKind<'tcx>:
197199
/// the built-in types. For structs, the metadata type is given by the struct
198200
/// tail.
199201
fn consider_builtin_pointee_candidate(
200-
ecx: &mut EvalCtxt<'_, 'tcx>,
202+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
201203
goal: Goal<'tcx, Self>,
202204
) -> Result<Candidate<'tcx>, NoSolution>;
203205

204206
/// A coroutine (that comes from an `async` desugaring) is known to implement
205207
/// `Future<Output = O>`, where `O` is given by the coroutine's return type
206208
/// that was computed during type-checking.
207209
fn consider_builtin_future_candidate(
208-
ecx: &mut EvalCtxt<'_, 'tcx>,
210+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
209211
goal: Goal<'tcx, Self>,
210212
) -> Result<Candidate<'tcx>, NoSolution>;
211213

212214
/// A coroutine (that comes from a `gen` desugaring) is known to implement
213215
/// `Iterator<Item = O>`, where `O` is given by the generator's yield type
214216
/// that was computed during type-checking.
215217
fn consider_builtin_iterator_candidate(
216-
ecx: &mut EvalCtxt<'_, 'tcx>,
218+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
217219
goal: Goal<'tcx, Self>,
218220
) -> Result<Candidate<'tcx>, NoSolution>;
219221

220222
/// A coroutine (that comes from a `gen` desugaring) is known to implement
221223
/// `FusedIterator`
222224
fn consider_builtin_fused_iterator_candidate(
223-
ecx: &mut EvalCtxt<'_, 'tcx>,
225+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
224226
goal: Goal<'tcx, Self>,
225227
) -> Result<Candidate<'tcx>, NoSolution>;
226228

227229
fn consider_builtin_async_iterator_candidate(
228-
ecx: &mut EvalCtxt<'_, 'tcx>,
230+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
229231
goal: Goal<'tcx, Self>,
230232
) -> Result<Candidate<'tcx>, NoSolution>;
231233

232234
/// A coroutine (that doesn't come from an `async` or `gen` desugaring) is known to
233235
/// implement `Coroutine<R, Yield = Y, Return = O>`, given the resume, yield,
234236
/// and return types of the coroutine computed during type-checking.
235237
fn consider_builtin_coroutine_candidate(
236-
ecx: &mut EvalCtxt<'_, 'tcx>,
238+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
237239
goal: Goal<'tcx, Self>,
238240
) -> Result<Candidate<'tcx>, NoSolution>;
239241

240242
fn consider_builtin_discriminant_kind_candidate(
241-
ecx: &mut EvalCtxt<'_, 'tcx>,
243+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
242244
goal: Goal<'tcx, Self>,
243245
) -> Result<Candidate<'tcx>, NoSolution>;
244246

245247
fn consider_builtin_async_destruct_candidate(
246-
ecx: &mut EvalCtxt<'_, 'tcx>,
248+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
247249
goal: Goal<'tcx, Self>,
248250
) -> Result<Candidate<'tcx>, NoSolution>;
249251

250252
fn consider_builtin_destruct_candidate(
251-
ecx: &mut EvalCtxt<'_, 'tcx>,
253+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
252254
goal: Goal<'tcx, Self>,
253255
) -> Result<Candidate<'tcx>, NoSolution>;
254256

255257
fn consider_builtin_transmute_candidate(
256-
ecx: &mut EvalCtxt<'_, 'tcx>,
258+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
257259
goal: Goal<'tcx, Self>,
258260
) -> Result<Candidate<'tcx>, NoSolution>;
259261

@@ -265,12 +267,12 @@ pub(super) trait GoalKind<'tcx>:
265267
/// otherwise recompute this for codegen. This is a bit of a mess but the
266268
/// easiest way to maintain the existing behavior for now.
267269
fn consider_structural_builtin_unsize_candidates(
268-
ecx: &mut EvalCtxt<'_, 'tcx>,
270+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
269271
goal: Goal<'tcx, Self>,
270272
) -> Vec<Candidate<'tcx>>;
271273
}
272274

273-
impl<'tcx> EvalCtxt<'_, 'tcx> {
275+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
274276
pub(super) fn assemble_and_evaluate_candidates<G: GoalKind<'tcx>>(
275277
&mut self,
276278
goal: Goal<'tcx, G>,

‎compiler/rustc_trait_selection/src/solve/assembly/structural_traits.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use rustc_data_structures::fx::FxHashMap;
44
use rustc_hir::LangItem;
55
use rustc_hir::{def_id::DefId, Movability, Mutability};
6+
use rustc_infer::infer::InferCtxt;
67
use rustc_infer::traits::query::NoSolution;
78
use rustc_macros::{TypeFoldable, TypeVisitable};
89
use rustc_middle::bug;
@@ -18,7 +19,7 @@ use crate::solve::EvalCtxt;
1819
// instantiate the binder with placeholders eagerly.
1920
#[instrument(level = "trace", skip(ecx), ret)]
2021
pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<'tcx>(
21-
ecx: &EvalCtxt<'_, 'tcx>,
22+
ecx: &EvalCtxt<'_, InferCtxt<'tcx>>,
2223
ty: Ty<'tcx>,
2324
) -> Result<Vec<ty::Binder<'tcx, Ty<'tcx>>>, NoSolution> {
2425
let tcx = ecx.tcx();
@@ -97,7 +98,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_auto_trait<'tcx>(
9798

9899
#[instrument(level = "trace", skip(ecx), ret)]
99100
pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
100-
ecx: &EvalCtxt<'_, 'tcx>,
101+
ecx: &EvalCtxt<'_, InferCtxt<'tcx>>,
101102
ty: Ty<'tcx>,
102103
) -> Result<Vec<ty::Binder<'tcx, Ty<'tcx>>>, NoSolution> {
103104
match *ty.kind() {
@@ -161,7 +162,7 @@ pub(in crate::solve) fn instantiate_constituent_tys_for_sized_trait<'tcx>(
161162

162163
#[instrument(level = "trace", skip(ecx), ret)]
163164
pub(in crate::solve) fn instantiate_constituent_tys_for_copy_clone_trait<'tcx>(
164-
ecx: &EvalCtxt<'_, 'tcx>,
165+
ecx: &EvalCtxt<'_, InferCtxt<'tcx>>,
165166
ty: Ty<'tcx>,
166167
) -> Result<Vec<ty::Binder<'tcx, Ty<'tcx>>>, NoSolution> {
167168
match *ty.kind() {
@@ -663,7 +664,7 @@ fn coroutine_closure_to_ambiguous_coroutine<'tcx>(
663664
// normalize eagerly here. See https://github.com/lcnr/solver-woes/issues/9
664665
// for more details.
665666
pub(in crate::solve) fn predicates_for_object_candidate<'tcx>(
666-
ecx: &EvalCtxt<'_, 'tcx>,
667+
ecx: &EvalCtxt<'_, InferCtxt<'tcx>>,
667668
param_env: ty::ParamEnv<'tcx>,
668669
trait_ref: ty::TraitRef<'tcx>,
669670
object_bound: &'tcx ty::List<ty::PolyExistentialPredicate<'tcx>>,
@@ -716,7 +717,7 @@ pub(in crate::solve) fn predicates_for_object_candidate<'tcx>(
716717
}
717718

718719
struct ReplaceProjectionWith<'a, 'tcx> {
719-
ecx: &'a EvalCtxt<'a, 'tcx>,
720+
ecx: &'a EvalCtxt<'a, InferCtxt<'tcx>>,
720721
param_env: ty::ParamEnv<'tcx>,
721722
mapping: FxHashMap<DefId, ty::PolyProjectionPredicate<'tcx>>,
722723
nested: Vec<Goal<'tcx, ty::Predicate<'tcx>>>,

‎compiler/rustc_trait_selection/src/solve/eval_ctxt/canonical.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ impl<'tcx, T> ResponseT<'tcx> for inspect::State<TyCtxt<'tcx>, T> {
5252
}
5353
}
5454

55-
impl<'tcx> EvalCtxt<'_, 'tcx> {
55+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
5656
/// Canonicalizes the goal remembering the original values
5757
/// for each bound variable.
5858
pub(super) fn canonicalize_goal<T: TypeFoldable<TyCtxt<'tcx>>>(

‎compiler/rustc_trait_selection/src/solve/eval_ctxt/mod.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use std::ops::ControlFlow;
44
use rustc_data_structures::stack::ensure_sufficient_stack;
55
use rustc_hir::def_id::DefId;
66
use rustc_infer::infer::at::ToTrace;
7-
use rustc_infer::infer::canonical::CanonicalVarValues;
87
use rustc_infer::infer::{
98
BoundRegionConversionTime, DefineOpaqueTypes, InferCtxt, InferOk, TyCtxtInferExt,
109
};
@@ -13,10 +12,8 @@ use rustc_infer::traits::solve::{MaybeCause, NestedNormalizationGoals};
1312
use rustc_infer::traits::ObligationCause;
1413
use rustc_macros::{extension, HashStable, HashStable_NoContext, TyDecodable, TyEncodable};
1514
use rustc_middle::bug;
16-
use rustc_middle::infer::canonical::CanonicalVarInfos;
1715
use rustc_middle::traits::solve::{
18-
inspect, CanonicalInput, CanonicalResponse, Certainty, PredefinedOpaques,
19-
PredefinedOpaquesData, QueryResult,
16+
inspect, CanonicalInput, CanonicalResponse, Certainty, PredefinedOpaquesData, QueryResult,
2017
};
2118
use rustc_middle::traits::specialization_graph;
2219
use rustc_middle::ty::{
@@ -25,7 +22,7 @@ use rustc_middle::ty::{
2522
};
2623
use rustc_session::config::DumpSolverProofTree;
2724
use rustc_span::DUMMY_SP;
28-
use rustc_type_ir::{self as ir, Interner};
25+
use rustc_type_ir::{self as ir, CanonicalVarValues, Interner};
2926
use rustc_type_ir_macros::{Lift_Generic, TypeFoldable_Generic, TypeVisitable_Generic};
3027

3128
use crate::traits::coherence;
@@ -41,7 +38,11 @@ pub(super) mod canonical;
4138
mod probe;
4239
mod select;
4340

44-
pub struct EvalCtxt<'a, 'tcx> {
41+
pub struct EvalCtxt<
42+
'a,
43+
Infcx: InferCtxtLike<Interner = I>,
44+
I: Interner = <Infcx as InferCtxtLike>::Interner,
45+
> {
4546
/// The inference context that backs (mostly) inference and placeholder terms
4647
/// instantiated while solving goals.
4748
///
@@ -57,11 +58,11 @@ pub struct EvalCtxt<'a, 'tcx> {
5758
/// If some `InferCtxt` method is missing, please first think defensively about
5859
/// the method's compatibility with this solver, or if an existing one does
5960
/// the job already.
60-
infcx: &'a InferCtxt<'tcx>,
61+
infcx: &'a Infcx,
6162

6263
/// The variable info for the `var_values`, only used to make an ambiguous response
6364
/// with no constraints.
64-
variables: CanonicalVarInfos<'tcx>,
65+
variables: I::CanonicalVars,
6566
/// Whether we're currently computing a `NormalizesTo` goal. Unlike other goals,
6667
/// `NormalizesTo` goals act like functions with the expected term always being
6768
/// fully unconstrained. This would weaken inference however, as the nested goals
@@ -70,9 +71,9 @@ pub struct EvalCtxt<'a, 'tcx> {
7071
/// when then adds these to its own context. The caller is always an `AliasRelate`
7172
/// goal so this never leaks out of the solver.
7273
is_normalizes_to_goal: bool,
73-
pub(super) var_values: CanonicalVarValues<'tcx>,
74+
pub(super) var_values: CanonicalVarValues<I>,
7475

75-
predefined_opaques_in_body: PredefinedOpaques<'tcx>,
76+
predefined_opaques_in_body: I::PredefinedOpaques,
7677

7778
/// The highest universe index nameable by the caller.
7879
///
@@ -85,9 +86,9 @@ pub struct EvalCtxt<'a, 'tcx> {
8586
/// new placeholders to the caller.
8687
pub(super) max_input_universe: ty::UniverseIndex,
8788

88-
pub(super) search_graph: &'a mut SearchGraph<'tcx>,
89+
pub(super) search_graph: &'a mut SearchGraph<I>,
8990

90-
nested_goals: NestedGoals<TyCtxt<'tcx>>,
91+
nested_goals: NestedGoals<I>,
9192

9293
// Has this `EvalCtxt` errored out with `NoSolution` in `try_evaluate_added_goals`?
9394
//
@@ -97,7 +98,7 @@ pub struct EvalCtxt<'a, 'tcx> {
9798
// evaluation code.
9899
tainted: Result<(), NoSolution>,
99100

100-
pub(super) inspect: ProofTreeBuilder<TyCtxt<'tcx>>,
101+
pub(super) inspect: ProofTreeBuilder<I>,
101102
}
102103

103104
#[derive(derivative::Derivative)]
@@ -157,7 +158,7 @@ impl<'tcx> InferCtxt<'tcx> {
157158
}
158159
}
159160

160-
impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
161+
impl<'a, 'tcx> EvalCtxt<'a, InferCtxt<'tcx>> {
161162
pub(super) fn solver_mode(&self) -> SolverMode {
162163
self.search_graph.solver_mode()
163164
}
@@ -172,7 +173,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
172173
pub(super) fn enter_root<R>(
173174
infcx: &InferCtxt<'tcx>,
174175
generate_proof_tree: GenerateProofTree,
175-
f: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> R,
176+
f: impl FnOnce(&mut EvalCtxt<'_, InferCtxt<'tcx>>) -> R,
176177
) -> (R, Option<inspect::GoalEvaluation<TyCtxt<'tcx>>>) {
177178
let mode = if infcx.intercrate { SolverMode::Coherence } else { SolverMode::Normal };
178179
let mut search_graph = search_graph::SearchGraph::new(mode);
@@ -225,10 +226,10 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
225226
/// and registering opaques from the canonicalized input.
226227
fn enter_canonical<R>(
227228
tcx: TyCtxt<'tcx>,
228-
search_graph: &'a mut search_graph::SearchGraph<'tcx>,
229+
search_graph: &'a mut search_graph::SearchGraph<TyCtxt<'tcx>>,
229230
canonical_input: CanonicalInput<'tcx>,
230231
canonical_goal_evaluation: &mut ProofTreeBuilder<TyCtxt<'tcx>>,
231-
f: impl FnOnce(&mut EvalCtxt<'_, 'tcx>, Goal<'tcx, ty::Predicate<'tcx>>) -> R,
232+
f: impl FnOnce(&mut EvalCtxt<'_, InferCtxt<'tcx>>, Goal<'tcx, ty::Predicate<'tcx>>) -> R,
232233
) -> R {
233234
let intercrate = match search_graph.solver_mode() {
234235
SolverMode::Normal => false,
@@ -287,7 +288,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
287288
#[instrument(level = "debug", skip(tcx, search_graph, goal_evaluation), ret)]
288289
fn evaluate_canonical_goal(
289290
tcx: TyCtxt<'tcx>,
290-
search_graph: &'a mut search_graph::SearchGraph<'tcx>,
291+
search_graph: &'a mut search_graph::SearchGraph<TyCtxt<'tcx>>,
291292
canonical_input: CanonicalInput<'tcx>,
292293
goal_evaluation: &mut ProofTreeBuilder<TyCtxt<'tcx>>,
293294
) -> QueryResult<'tcx> {
@@ -600,7 +601,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
600601
}
601602
}
602603

603-
impl<'tcx> EvalCtxt<'_, 'tcx> {
604+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
604605
pub(super) fn tcx(&self) -> TyCtxt<'tcx> {
605606
self.infcx.tcx
606607
}

‎compiler/rustc_trait_selection/src/solve/eval_ctxt/probe.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
use crate::solve::assembly::Candidate;
22

33
use super::EvalCtxt;
4+
use rustc_infer::infer::InferCtxt;
45
use rustc_infer::traits::BuiltinImplSource;
56
use rustc_middle::traits::query::NoSolution;
67
use rustc_middle::traits::solve::{inspect, CandidateSource, QueryResult};
78
use rustc_middle::ty::TyCtxt;
89
use std::marker::PhantomData;
910

1011
pub(in crate::solve) struct ProbeCtxt<'me, 'a, 'tcx, F, T> {
11-
ecx: &'me mut EvalCtxt<'a, 'tcx>,
12+
ecx: &'me mut EvalCtxt<'a, InferCtxt<'tcx>>,
1213
probe_kind: F,
1314
_result: PhantomData<T>,
1415
}
@@ -17,7 +18,10 @@ impl<'tcx, F, T> ProbeCtxt<'_, '_, 'tcx, F, T>
1718
where
1819
F: FnOnce(&T) -> inspect::ProbeKind<TyCtxt<'tcx>>,
1920
{
20-
pub(in crate::solve) fn enter(self, f: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> T) -> T {
21+
pub(in crate::solve) fn enter(
22+
self,
23+
f: impl FnOnce(&mut EvalCtxt<'_, InferCtxt<'tcx>>) -> T,
24+
) -> T {
2125
let ProbeCtxt { ecx: outer_ecx, probe_kind, _result } = self;
2226

2327
let infcx = outer_ecx.infcx;
@@ -60,13 +64,13 @@ where
6064
#[instrument(level = "debug", skip_all, fields(source = ?self.source))]
6165
pub(in crate::solve) fn enter(
6266
self,
63-
f: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> QueryResult<'tcx>,
67+
f: impl FnOnce(&mut EvalCtxt<'_, InferCtxt<'tcx>>) -> QueryResult<'tcx>,
6468
) -> Result<Candidate<'tcx>, NoSolution> {
6569
self.cx.enter(|ecx| f(ecx)).map(|result| Candidate { source: self.source, result })
6670
}
6771
}
6872

69-
impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
73+
impl<'a, 'tcx> EvalCtxt<'a, InferCtxt<'tcx>> {
7074
/// `probe_kind` is only called when proof tree building is enabled so it can be
7175
/// as expensive as necessary to output the desired information.
7276
pub(in crate::solve) fn probe<F, T>(&mut self, probe_kind: F) -> ProbeCtxt<'_, 'a, 'tcx, F, T>

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
//! about it on zulip.
1616
use rustc_hir::def_id::DefId;
1717
use rustc_infer::infer::canonical::{Canonical, CanonicalVarValues};
18+
use rustc_infer::infer::InferCtxt;
1819
use rustc_infer::traits::query::NoSolution;
1920
use rustc_macros::extension;
2021
use rustc_middle::bug;
@@ -82,7 +83,7 @@ impl<'tcx> Canonical<'tcx, Response<TyCtxt<'tcx>>> {
8283
}
8384
}
8485

85-
impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
86+
impl<'a, 'tcx> EvalCtxt<'a, InferCtxt<'tcx>> {
8687
#[instrument(level = "trace", skip(self))]
8788
fn compute_type_outlives_goal(
8889
&mut self,
@@ -201,7 +202,7 @@ impl<'a, 'tcx> EvalCtxt<'a, 'tcx> {
201202
}
202203
}
203204

204-
impl<'tcx> EvalCtxt<'_, 'tcx> {
205+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
205206
#[instrument(level = "trace", skip(self, goals))]
206207
fn add_goals(
207208
&mut self,

‎compiler/rustc_trait_selection/src/solve/normalizes_to/anon_const.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
use crate::solve::EvalCtxt;
2+
use rustc_infer::infer::InferCtxt;
23
use rustc_middle::traits::solve::{Certainty, Goal, QueryResult};
34
use rustc_middle::ty;
45

5-
impl<'tcx> EvalCtxt<'_, 'tcx> {
6+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
67
#[instrument(level = "trace", skip(self), ret)]
78
pub(super) fn normalize_anon_const(
89
&mut self,

‎compiler/rustc_trait_selection/src/solve/normalizes_to/inherent.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
//! 1. instantiate generic parameters,
55
//! 2. equate the self type, and
66
//! 3. instantiate and register where clauses.
7+
use rustc_infer::infer::InferCtxt;
78
use rustc_middle::traits::solve::{Certainty, Goal, GoalSource, QueryResult};
89
use rustc_middle::ty;
910

1011
use crate::solve::EvalCtxt;
1112

12-
impl<'tcx> EvalCtxt<'_, 'tcx> {
13+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
1314
pub(super) fn normalize_inherent_associated_type(
1415
&mut self,
1516
goal: Goal<'tcx, ty::NormalizesTo<'tcx>>,

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

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use super::assembly::{self, structural_traits, Candidate};
55
use super::{EvalCtxt, GoalSource};
66
use rustc_hir::def_id::DefId;
77
use rustc_hir::LangItem;
8+
use rustc_infer::infer::InferCtxt;
89
use rustc_infer::traits::query::NoSolution;
910
use rustc_infer::traits::solve::inspect::ProbeKind;
1011
use rustc_infer::traits::solve::MaybeCause;
@@ -24,7 +25,7 @@ mod inherent;
2425
mod opaque_types;
2526
mod weak_types;
2627

27-
impl<'tcx> EvalCtxt<'_, 'tcx> {
28+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
2829
#[instrument(level = "trace", skip(self), ret)]
2930
pub(super) fn compute_normalizes_to_goal(
3031
&mut self,
@@ -98,11 +99,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
9899
}
99100

100101
fn probe_and_match_goal_against_assumption(
101-
ecx: &mut EvalCtxt<'_, 'tcx>,
102+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
102103
source: CandidateSource<'tcx>,
103104
goal: Goal<'tcx, Self>,
104105
assumption: ty::Clause<'tcx>,
105-
then: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> QueryResult<'tcx>,
106+
then: impl FnOnce(&mut EvalCtxt<'_, InferCtxt<'tcx>>) -> QueryResult<'tcx>,
106107
) -> Result<Candidate<'tcx>, NoSolution> {
107108
if let Some(projection_pred) = assumption.as_projection_clause() {
108109
if projection_pred.projection_def_id() == goal.predicate.def_id() {
@@ -137,7 +138,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
137138
}
138139

139140
fn consider_impl_candidate(
140-
ecx: &mut EvalCtxt<'_, 'tcx>,
141+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
141142
goal: Goal<'tcx, NormalizesTo<'tcx>>,
142143
impl_def_id: DefId,
143144
) -> Result<Candidate<'tcx>, NoSolution> {
@@ -199,7 +200,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
199200
return ecx.evaluate_added_goals_and_make_canonical_response(Certainty::AMBIGUOUS);
200201
};
201202

202-
let error_response = |ecx: &mut EvalCtxt<'_, 'tcx>, reason| {
203+
let error_response = |ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>, reason| {
203204
let guar = tcx.dcx().span_delayed_bug(tcx.def_span(assoc_def.item.def_id), reason);
204205
let error_term = match assoc_def.item.kind {
205206
ty::AssocKind::Const => ty::Const::new_error(
@@ -279,14 +280,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
279280
/// Fail to normalize if the predicate contains an error, alternatively, we could normalize to `ty::Error`
280281
/// and succeed. Can experiment with this to figure out what results in better error messages.
281282
fn consider_error_guaranteed_candidate(
282-
_ecx: &mut EvalCtxt<'_, 'tcx>,
283+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
283284
_guar: ErrorGuaranteed,
284285
) -> Result<Candidate<'tcx>, NoSolution> {
285286
Err(NoSolution)
286287
}
287288

288289
fn consider_auto_trait_candidate(
289-
ecx: &mut EvalCtxt<'_, 'tcx>,
290+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
290291
goal: Goal<'tcx, Self>,
291292
) -> Result<Candidate<'tcx>, NoSolution> {
292293
ecx.tcx().dcx().span_delayed_bug(
@@ -297,42 +298,42 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
297298
}
298299

299300
fn consider_trait_alias_candidate(
300-
_ecx: &mut EvalCtxt<'_, 'tcx>,
301+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
301302
goal: Goal<'tcx, Self>,
302303
) -> Result<Candidate<'tcx>, NoSolution> {
303304
bug!("trait aliases do not have associated types: {:?}", goal);
304305
}
305306

306307
fn consider_builtin_sized_candidate(
307-
_ecx: &mut EvalCtxt<'_, 'tcx>,
308+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
308309
goal: Goal<'tcx, Self>,
309310
) -> Result<Candidate<'tcx>, NoSolution> {
310311
bug!("`Sized` does not have an associated type: {:?}", goal);
311312
}
312313

313314
fn consider_builtin_copy_clone_candidate(
314-
_ecx: &mut EvalCtxt<'_, 'tcx>,
315+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
315316
goal: Goal<'tcx, Self>,
316317
) -> Result<Candidate<'tcx>, NoSolution> {
317318
bug!("`Copy`/`Clone` does not have an associated type: {:?}", goal);
318319
}
319320

320321
fn consider_builtin_pointer_like_candidate(
321-
_ecx: &mut EvalCtxt<'_, 'tcx>,
322+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
322323
goal: Goal<'tcx, Self>,
323324
) -> Result<Candidate<'tcx>, NoSolution> {
324325
bug!("`PointerLike` does not have an associated type: {:?}", goal);
325326
}
326327

327328
fn consider_builtin_fn_ptr_trait_candidate(
328-
_ecx: &mut EvalCtxt<'_, 'tcx>,
329+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
329330
goal: Goal<'tcx, Self>,
330331
) -> Result<Candidate<'tcx>, NoSolution> {
331332
bug!("`FnPtr` does not have an associated type: {:?}", goal);
332333
}
333334

334335
fn consider_builtin_fn_trait_candidates(
335-
ecx: &mut EvalCtxt<'_, 'tcx>,
336+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
336337
goal: Goal<'tcx, Self>,
337338
goal_kind: ty::ClosureKind,
338339
) -> Result<Candidate<'tcx>, NoSolution> {
@@ -375,7 +376,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
375376
}
376377

377378
fn consider_builtin_async_fn_trait_candidates(
378-
ecx: &mut EvalCtxt<'_, 'tcx>,
379+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
379380
goal: Goal<'tcx, Self>,
380381
goal_kind: ty::ClosureKind,
381382
) -> Result<Candidate<'tcx>, NoSolution> {
@@ -460,7 +461,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
460461
}
461462

462463
fn consider_builtin_async_fn_kind_helper_candidate(
463-
ecx: &mut EvalCtxt<'_, 'tcx>,
464+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
464465
goal: Goal<'tcx, Self>,
465466
) -> Result<Candidate<'tcx>, NoSolution> {
466467
let [
@@ -507,14 +508,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
507508
}
508509

509510
fn consider_builtin_tuple_candidate(
510-
_ecx: &mut EvalCtxt<'_, 'tcx>,
511+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
511512
goal: Goal<'tcx, Self>,
512513
) -> Result<Candidate<'tcx>, NoSolution> {
513514
bug!("`Tuple` does not have an associated type: {:?}", goal);
514515
}
515516

516517
fn consider_builtin_pointee_candidate(
517-
ecx: &mut EvalCtxt<'_, 'tcx>,
518+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
518519
goal: Goal<'tcx, Self>,
519520
) -> Result<Candidate<'tcx>, NoSolution> {
520521
let tcx = ecx.tcx();
@@ -596,7 +597,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
596597
}
597598

598599
fn consider_builtin_future_candidate(
599-
ecx: &mut EvalCtxt<'_, 'tcx>,
600+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
600601
goal: Goal<'tcx, Self>,
601602
) -> Result<Candidate<'tcx>, NoSolution> {
602603
let self_ty = goal.predicate.self_ty();
@@ -628,7 +629,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
628629
}
629630

630631
fn consider_builtin_iterator_candidate(
631-
ecx: &mut EvalCtxt<'_, 'tcx>,
632+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
632633
goal: Goal<'tcx, Self>,
633634
) -> Result<Candidate<'tcx>, NoSolution> {
634635
let self_ty = goal.predicate.self_ty();
@@ -660,14 +661,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
660661
}
661662

662663
fn consider_builtin_fused_iterator_candidate(
663-
_ecx: &mut EvalCtxt<'_, 'tcx>,
664+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
664665
goal: Goal<'tcx, Self>,
665666
) -> Result<Candidate<'tcx>, NoSolution> {
666667
bug!("`FusedIterator` does not have an associated type: {:?}", goal);
667668
}
668669

669670
fn consider_builtin_async_iterator_candidate(
670-
ecx: &mut EvalCtxt<'_, 'tcx>,
671+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
671672
goal: Goal<'tcx, Self>,
672673
) -> Result<Candidate<'tcx>, NoSolution> {
673674
let self_ty = goal.predicate.self_ty();
@@ -703,7 +704,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
703704
}
704705

705706
fn consider_builtin_coroutine_candidate(
706-
ecx: &mut EvalCtxt<'_, 'tcx>,
707+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
707708
goal: Goal<'tcx, Self>,
708709
) -> Result<Candidate<'tcx>, NoSolution> {
709710
let self_ty = goal.predicate.self_ty();
@@ -748,14 +749,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
748749
}
749750

750751
fn consider_structural_builtin_unsize_candidates(
751-
_ecx: &mut EvalCtxt<'_, 'tcx>,
752+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
752753
goal: Goal<'tcx, Self>,
753754
) -> Vec<Candidate<'tcx>> {
754755
bug!("`Unsize` does not have an associated type: {:?}", goal);
755756
}
756757

757758
fn consider_builtin_discriminant_kind_candidate(
758-
ecx: &mut EvalCtxt<'_, 'tcx>,
759+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
759760
goal: Goal<'tcx, Self>,
760761
) -> Result<Candidate<'tcx>, NoSolution> {
761762
let self_ty = goal.predicate.self_ty();
@@ -807,7 +808,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
807808
}
808809

809810
fn consider_builtin_async_destruct_candidate(
810-
ecx: &mut EvalCtxt<'_, 'tcx>,
811+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
811812
goal: Goal<'tcx, Self>,
812813
) -> Result<Candidate<'tcx>, NoSolution> {
813814
let self_ty = goal.predicate.self_ty();
@@ -860,14 +861,14 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
860861
}
861862

862863
fn consider_builtin_destruct_candidate(
863-
_ecx: &mut EvalCtxt<'_, 'tcx>,
864+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
864865
goal: Goal<'tcx, Self>,
865866
) -> Result<Candidate<'tcx>, NoSolution> {
866867
bug!("`Destruct` does not have an associated type: {:?}", goal);
867868
}
868869

869870
fn consider_builtin_transmute_candidate(
870-
_ecx: &mut EvalCtxt<'_, 'tcx>,
871+
_ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
871872
goal: Goal<'tcx, Self>,
872873
) -> Result<Candidate<'tcx>, NoSolution> {
873874
bug!("`BikeshedIntrinsicFrom` does not have an associated type: {:?}", goal)
@@ -880,7 +881,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for NormalizesTo<'tcx> {
880881
/// diverge.
881882
#[instrument(level = "trace", skip(ecx, param_env), ret)]
882883
fn fetch_eligible_assoc_item_def<'tcx>(
883-
ecx: &EvalCtxt<'_, 'tcx>,
884+
ecx: &EvalCtxt<'_, InferCtxt<'tcx>>,
884885
param_env: ty::ParamEnv<'tcx>,
885886
goal_trait_ref: ty::TraitRef<'tcx>,
886887
trait_assoc_def_id: DefId,

‎compiler/rustc_trait_selection/src/solve/normalizes_to/opaque_types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! Computes a normalizes-to (projection) goal for opaque types. This goal
22
//! behaves differently depending on the param-env's reveal mode and whether
33
//! the opaque is in a defining scope.
4+
use rustc_infer::infer::InferCtxt;
45
use rustc_middle::traits::query::NoSolution;
56
use rustc_middle::traits::solve::{Certainty, Goal, QueryResult};
67
use rustc_middle::traits::Reveal;
@@ -9,7 +10,7 @@ use rustc_middle::ty::util::NotUniqueParam;
910

1011
use crate::solve::{EvalCtxt, SolverMode};
1112

12-
impl<'tcx> EvalCtxt<'_, 'tcx> {
13+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
1314
pub(super) fn normalize_opaque_type(
1415
&mut self,
1516
goal: Goal<'tcx, ty::NormalizesTo<'tcx>>,

‎compiler/rustc_trait_selection/src/solve/normalizes_to/weak_types.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
//!
44
//! Since a weak alias is never ambiguous, this just computes the `type_of` of
55
//! the alias and registers the where-clauses of the type alias.
6+
use rustc_infer::infer::InferCtxt;
67
use rustc_middle::traits::solve::{Certainty, Goal, GoalSource, QueryResult};
78
use rustc_middle::ty;
89

910
use crate::solve::EvalCtxt;
1011

11-
impl<'tcx> EvalCtxt<'_, 'tcx> {
12+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
1213
pub(super) fn normalize_weak_type(
1314
&mut self,
1415
goal: Goal<'tcx, ty::NormalizesTo<'tcx>>,

‎compiler/rustc_trait_selection/src/solve/project_goals.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
use crate::solve::GoalSource;
22

33
use super::EvalCtxt;
4+
use rustc_infer::infer::InferCtxt;
45
use rustc_middle::traits::solve::{Certainty, Goal, QueryResult};
56
use rustc_middle::ty::{self, ProjectionPredicate};
67

7-
impl<'tcx> EvalCtxt<'_, 'tcx> {
8+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
89
#[instrument(level = "trace", skip(self), ret)]
910
pub(super) fn compute_projection_goal(
1011
&mut self,

‎compiler/rustc_trait_selection/src/solve/search_graph.rs

Lines changed: 60 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
use crate::solve::FIXPOINT_STEP_LIMIT;
1+
use std::mem;
22

3-
use super::inspect;
4-
use super::inspect::ProofTreeBuilder;
5-
use super::SolverMode;
6-
use rustc_data_structures::fx::FxHashMap;
7-
use rustc_data_structures::fx::FxHashSet;
3+
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
84
use rustc_index::Idx;
95
use rustc_index::IndexVec;
106
use rustc_middle::dep_graph::dep_kinds;
117
use rustc_middle::traits::solve::CacheData;
12-
use rustc_middle::traits::solve::{CanonicalInput, Certainty, EvaluationCache, QueryResult};
8+
use rustc_middle::traits::solve::EvaluationCache;
139
use rustc_middle::ty::TyCtxt;
10+
use rustc_next_trait_solver::solve::{CanonicalInput, Certainty, QueryResult};
1411
use rustc_session::Limit;
15-
use std::mem;
12+
use rustc_type_ir::inherent::*;
13+
use rustc_type_ir::Interner;
14+
15+
use super::inspect;
16+
use super::inspect::ProofTreeBuilder;
17+
use super::SolverMode;
18+
use crate::solve::FIXPOINT_STEP_LIMIT;
1619

1720
rustc_index::newtype_index! {
1821
#[orderable]
@@ -30,9 +33,10 @@ bitflags::bitflags! {
3033
}
3134
}
3235

33-
#[derive(Debug)]
34-
struct StackEntry<'tcx> {
35-
input: CanonicalInput<'tcx>,
36+
#[derive(derivative::Derivative)]
37+
#[derivative(Debug(bound = ""))]
38+
struct StackEntry<I: Interner> {
39+
input: CanonicalInput<I>,
3640

3741
available_depth: Limit,
3842

@@ -53,11 +57,11 @@ struct StackEntry<'tcx> {
5357
has_been_used: HasBeenUsed,
5458
/// Starts out as `None` and gets set when rerunning this
5559
/// goal in case we encounter a cycle.
56-
provisional_result: Option<QueryResult<'tcx>>,
60+
provisional_result: Option<QueryResult<I>>,
5761
}
5862

5963
/// The provisional result for a goal which is not on the stack.
60-
struct DetachedEntry<'tcx> {
64+
struct DetachedEntry<I: Interner> {
6165
/// The head of the smallest non-trivial cycle involving this entry.
6266
///
6367
/// Given the following rules, when proving `A` the head for
@@ -68,7 +72,7 @@ struct DetachedEntry<'tcx> {
6872
/// C :- A + B + C
6973
/// ```
7074
head: StackDepth,
71-
result: QueryResult<'tcx>,
75+
result: QueryResult<I>,
7276
}
7377

7478
/// Stores the stack depth of a currently evaluated goal *and* already
@@ -83,40 +87,41 @@ struct DetachedEntry<'tcx> {
8387
///
8488
/// The provisional cache can theoretically result in changes to the observable behavior,
8589
/// see tests/ui/traits/next-solver/cycles/provisional-cache-impacts-behavior.rs.
86-
#[derive(Default)]
87-
struct ProvisionalCacheEntry<'tcx> {
90+
#[derive(derivative::Derivative)]
91+
#[derivative(Default(bound = ""))]
92+
struct ProvisionalCacheEntry<I: Interner> {
8893
stack_depth: Option<StackDepth>,
89-
with_inductive_stack: Option<DetachedEntry<'tcx>>,
90-
with_coinductive_stack: Option<DetachedEntry<'tcx>>,
94+
with_inductive_stack: Option<DetachedEntry<I>>,
95+
with_coinductive_stack: Option<DetachedEntry<I>>,
9196
}
9297

93-
impl<'tcx> ProvisionalCacheEntry<'tcx> {
98+
impl<I: Interner> ProvisionalCacheEntry<I> {
9499
fn is_empty(&self) -> bool {
95100
self.stack_depth.is_none()
96101
&& self.with_inductive_stack.is_none()
97102
&& self.with_coinductive_stack.is_none()
98103
}
99104
}
100105

101-
pub(super) struct SearchGraph<'tcx> {
106+
pub(super) struct SearchGraph<I: Interner> {
102107
mode: SolverMode,
103108
/// The stack of goals currently being computed.
104109
///
105110
/// An element is *deeper* in the stack if its index is *lower*.
106-
stack: IndexVec<StackDepth, StackEntry<'tcx>>,
107-
provisional_cache: FxHashMap<CanonicalInput<'tcx>, ProvisionalCacheEntry<'tcx>>,
111+
stack: IndexVec<StackDepth, StackEntry<I>>,
112+
provisional_cache: FxHashMap<CanonicalInput<I>, ProvisionalCacheEntry<I>>,
108113
/// We put only the root goal of a coinductive cycle into the global cache.
109114
///
110115
/// If we were to use that result when later trying to prove another cycle
111116
/// participant, we can end up with unstable query results.
112117
///
113118
/// See tests/ui/next-solver/coinduction/incompleteness-unstable-result.rs for
114119
/// an example of where this is needed.
115-
cycle_participants: FxHashSet<CanonicalInput<'tcx>>,
120+
cycle_participants: FxHashSet<CanonicalInput<I>>,
116121
}
117122

118-
impl<'tcx> SearchGraph<'tcx> {
119-
pub(super) fn new(mode: SolverMode) -> SearchGraph<'tcx> {
123+
impl<I: Interner> SearchGraph<I> {
124+
pub(super) fn new(mode: SolverMode) -> SearchGraph<I> {
120125
Self {
121126
mode,
122127
stack: Default::default(),
@@ -144,7 +149,7 @@ impl<'tcx> SearchGraph<'tcx> {
144149
///
145150
/// Directly popping from the stack instead of using this method
146151
/// would cause us to not track overflow and recursion depth correctly.
147-
fn pop_stack(&mut self) -> StackEntry<'tcx> {
152+
fn pop_stack(&mut self) -> StackEntry<I> {
148153
let elem = self.stack.pop().unwrap();
149154
if let Some(last) = self.stack.raw.last_mut() {
150155
last.reached_depth = last.reached_depth.max(elem.reached_depth);
@@ -153,17 +158,6 @@ impl<'tcx> SearchGraph<'tcx> {
153158
elem
154159
}
155160

156-
/// The trait solver behavior is different for coherence
157-
/// so we use a separate cache. Alternatively we could use
158-
/// a single cache and share it between coherence and ordinary
159-
/// trait solving.
160-
pub(super) fn global_cache(&self, tcx: TyCtxt<'tcx>) -> &'tcx EvaluationCache<'tcx> {
161-
match self.mode {
162-
SolverMode::Normal => &tcx.new_solver_evaluation_cache,
163-
SolverMode::Coherence => &tcx.new_solver_coherence_evaluation_cache,
164-
}
165-
}
166-
167161
pub(super) fn is_empty(&self) -> bool {
168162
if self.stack.is_empty() {
169163
debug_assert!(self.provisional_cache.is_empty());
@@ -181,8 +175,8 @@ impl<'tcx> SearchGraph<'tcx> {
181175
/// the remaining depth of all nested goals to prevent hangs
182176
/// in case there is exponential blowup.
183177
fn allowed_depth_for_nested(
184-
tcx: TyCtxt<'tcx>,
185-
stack: &IndexVec<StackDepth, StackEntry<'tcx>>,
178+
tcx: I,
179+
stack: &IndexVec<StackDepth, StackEntry<I>>,
186180
) -> Option<Limit> {
187181
if let Some(last) = stack.raw.last() {
188182
if last.available_depth.0 == 0 {
@@ -195,13 +189,13 @@ impl<'tcx> SearchGraph<'tcx> {
195189
Limit(last.available_depth.0 - 1)
196190
})
197191
} else {
198-
Some(tcx.recursion_limit())
192+
Some(Limit(tcx.recursion_limit()))
199193
}
200194
}
201195

202196
fn stack_coinductive_from(
203-
tcx: TyCtxt<'tcx>,
204-
stack: &IndexVec<StackDepth, StackEntry<'tcx>>,
197+
tcx: I,
198+
stack: &IndexVec<StackDepth, StackEntry<I>>,
205199
head: StackDepth,
206200
) -> bool {
207201
stack.raw[head.index()..]
@@ -220,8 +214,8 @@ impl<'tcx> SearchGraph<'tcx> {
220214
// we reach a fixpoint and all other cycle participants to make sure that
221215
// their result does not get moved to the global cache.
222216
fn tag_cycle_participants(
223-
stack: &mut IndexVec<StackDepth, StackEntry<'tcx>>,
224-
cycle_participants: &mut FxHashSet<CanonicalInput<'tcx>>,
217+
stack: &mut IndexVec<StackDepth, StackEntry<I>>,
218+
cycle_participants: &mut FxHashSet<CanonicalInput<I>>,
225219
usage_kind: HasBeenUsed,
226220
head: StackDepth,
227221
) {
@@ -234,7 +228,7 @@ impl<'tcx> SearchGraph<'tcx> {
234228
}
235229

236230
fn clear_dependent_provisional_results(
237-
provisional_cache: &mut FxHashMap<CanonicalInput<'tcx>, ProvisionalCacheEntry<'tcx>>,
231+
provisional_cache: &mut FxHashMap<CanonicalInput<I>, ProvisionalCacheEntry<I>>,
238232
head: StackDepth,
239233
) {
240234
#[allow(rustc::potential_query_instability)]
@@ -244,6 +238,19 @@ impl<'tcx> SearchGraph<'tcx> {
244238
!entry.is_empty()
245239
});
246240
}
241+
}
242+
243+
impl<'tcx> SearchGraph<TyCtxt<'tcx>> {
244+
/// The trait solver behavior is different for coherence
245+
/// so we use a separate cache. Alternatively we could use
246+
/// a single cache and share it between coherence and ordinary
247+
/// trait solving.
248+
pub(super) fn global_cache(&self, tcx: TyCtxt<'tcx>) -> &'tcx EvaluationCache<'tcx> {
249+
match self.mode {
250+
SolverMode::Normal => &tcx.new_solver_evaluation_cache,
251+
SolverMode::Coherence => &tcx.new_solver_coherence_evaluation_cache,
252+
}
253+
}
247254

248255
/// Probably the most involved method of the whole solver.
249256
///
@@ -252,10 +259,13 @@ impl<'tcx> SearchGraph<'tcx> {
252259
pub(super) fn with_new_goal(
253260
&mut self,
254261
tcx: TyCtxt<'tcx>,
255-
input: CanonicalInput<'tcx>,
262+
input: CanonicalInput<TyCtxt<'tcx>>,
256263
inspect: &mut ProofTreeBuilder<TyCtxt<'tcx>>,
257-
mut prove_goal: impl FnMut(&mut Self, &mut ProofTreeBuilder<TyCtxt<'tcx>>) -> QueryResult<'tcx>,
258-
) -> QueryResult<'tcx> {
264+
mut prove_goal: impl FnMut(
265+
&mut Self,
266+
&mut ProofTreeBuilder<TyCtxt<'tcx>>,
267+
) -> QueryResult<TyCtxt<'tcx>>,
268+
) -> QueryResult<TyCtxt<'tcx>> {
259269
// Check for overflow.
260270
let Some(available_depth) = Self::allowed_depth_for_nested(tcx, &self.stack) else {
261271
if let Some(last) = self.stack.raw.last_mut() {
@@ -489,9 +499,9 @@ impl<'tcx> SearchGraph<'tcx> {
489499

490500
fn response_no_constraints(
491501
tcx: TyCtxt<'tcx>,
492-
goal: CanonicalInput<'tcx>,
502+
goal: CanonicalInput<TyCtxt<'tcx>>,
493503
certainty: Certainty,
494-
) -> QueryResult<'tcx> {
504+
) -> QueryResult<TyCtxt<'tcx>> {
495505
Ok(super::response_no_constraints_raw(tcx, goal.max_universe, goal.variables, certainty))
496506
}
497507
}

‎compiler/rustc_trait_selection/src/solve/trait_goals.rs

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use super::{EvalCtxt, GoalSource, SolverMode};
88
use rustc_data_structures::fx::FxIndexSet;
99
use rustc_hir::def_id::DefId;
1010
use rustc_hir::{LangItem, Movability};
11+
use rustc_infer::infer::InferCtxt;
1112
use rustc_infer::traits::query::NoSolution;
1213
use rustc_infer::traits::solve::MaybeCause;
1314
use rustc_middle::bug;
@@ -37,7 +38,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
3738
}
3839

3940
fn consider_impl_candidate(
40-
ecx: &mut EvalCtxt<'_, 'tcx>,
41+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
4142
goal: Goal<'tcx, TraitPredicate<'tcx>>,
4243
impl_def_id: DefId,
4344
) -> Result<Candidate<'tcx>, NoSolution> {
@@ -93,7 +94,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
9394
}
9495

9596
fn consider_error_guaranteed_candidate(
96-
ecx: &mut EvalCtxt<'_, 'tcx>,
97+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
9798
_guar: ErrorGuaranteed,
9899
) -> Result<Candidate<'tcx>, NoSolution> {
99100
// FIXME: don't need to enter a probe here.
@@ -102,11 +103,11 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
102103
}
103104

104105
fn probe_and_match_goal_against_assumption(
105-
ecx: &mut EvalCtxt<'_, 'tcx>,
106+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
106107
source: CandidateSource<'tcx>,
107108
goal: Goal<'tcx, Self>,
108109
assumption: ty::Clause<'tcx>,
109-
then: impl FnOnce(&mut EvalCtxt<'_, 'tcx>) -> QueryResult<'tcx>,
110+
then: impl FnOnce(&mut EvalCtxt<'_, InferCtxt<'tcx>>) -> QueryResult<'tcx>,
110111
) -> Result<Candidate<'tcx>, NoSolution> {
111112
if let Some(trait_clause) = assumption.as_trait_clause() {
112113
if trait_clause.def_id() == goal.predicate.def_id()
@@ -130,7 +131,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
130131
}
131132

132133
fn consider_auto_trait_candidate(
133-
ecx: &mut EvalCtxt<'_, 'tcx>,
134+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
134135
goal: Goal<'tcx, Self>,
135136
) -> Result<Candidate<'tcx>, NoSolution> {
136137
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -173,7 +174,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
173174
}
174175

175176
fn consider_trait_alias_candidate(
176-
ecx: &mut EvalCtxt<'_, 'tcx>,
177+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
177178
goal: Goal<'tcx, Self>,
178179
) -> Result<Candidate<'tcx>, NoSolution> {
179180
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -196,7 +197,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
196197
}
197198

198199
fn consider_builtin_sized_candidate(
199-
ecx: &mut EvalCtxt<'_, 'tcx>,
200+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
200201
goal: Goal<'tcx, Self>,
201202
) -> Result<Candidate<'tcx>, NoSolution> {
202203
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -211,7 +212,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
211212
}
212213

213214
fn consider_builtin_copy_clone_candidate(
214-
ecx: &mut EvalCtxt<'_, 'tcx>,
215+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
215216
goal: Goal<'tcx, Self>,
216217
) -> Result<Candidate<'tcx>, NoSolution> {
217218
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -226,7 +227,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
226227
}
227228

228229
fn consider_builtin_pointer_like_candidate(
229-
ecx: &mut EvalCtxt<'_, 'tcx>,
230+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
230231
goal: Goal<'tcx, Self>,
231232
) -> Result<Candidate<'tcx>, NoSolution> {
232233
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -256,7 +257,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
256257
}
257258

258259
fn consider_builtin_fn_ptr_trait_candidate(
259-
ecx: &mut EvalCtxt<'_, 'tcx>,
260+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
260261
goal: Goal<'tcx, Self>,
261262
) -> Result<Candidate<'tcx>, NoSolution> {
262263
let self_ty = goal.predicate.self_ty();
@@ -287,7 +288,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
287288
}
288289

289290
fn consider_builtin_fn_trait_candidates(
290-
ecx: &mut EvalCtxt<'_, 'tcx>,
291+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
291292
goal: Goal<'tcx, Self>,
292293
goal_kind: ty::ClosureKind,
293294
) -> Result<Candidate<'tcx>, NoSolution> {
@@ -328,7 +329,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
328329
}
329330

330331
fn consider_builtin_async_fn_trait_candidates(
331-
ecx: &mut EvalCtxt<'_, 'tcx>,
332+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
332333
goal: Goal<'tcx, Self>,
333334
goal_kind: ty::ClosureKind,
334335
) -> Result<Candidate<'tcx>, NoSolution> {
@@ -379,7 +380,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
379380
}
380381

381382
fn consider_builtin_async_fn_kind_helper_candidate(
382-
ecx: &mut EvalCtxt<'_, 'tcx>,
383+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
383384
goal: Goal<'tcx, Self>,
384385
) -> Result<Candidate<'tcx>, NoSolution> {
385386
let [closure_fn_kind_ty, goal_kind_ty] = **goal.predicate.trait_ref.args else {
@@ -406,7 +407,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
406407
/// impl Tuple for (T1, .., Tn) {}
407408
/// ```
408409
fn consider_builtin_tuple_candidate(
409-
ecx: &mut EvalCtxt<'_, 'tcx>,
410+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
410411
goal: Goal<'tcx, Self>,
411412
) -> Result<Candidate<'tcx>, NoSolution> {
412413
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -422,7 +423,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
422423
}
423424

424425
fn consider_builtin_pointee_candidate(
425-
ecx: &mut EvalCtxt<'_, 'tcx>,
426+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
426427
goal: Goal<'tcx, Self>,
427428
) -> Result<Candidate<'tcx>, NoSolution> {
428429
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -434,7 +435,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
434435
}
435436

436437
fn consider_builtin_future_candidate(
437-
ecx: &mut EvalCtxt<'_, 'tcx>,
438+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
438439
goal: Goal<'tcx, Self>,
439440
) -> Result<Candidate<'tcx>, NoSolution> {
440441
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -460,7 +461,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
460461
}
461462

462463
fn consider_builtin_iterator_candidate(
463-
ecx: &mut EvalCtxt<'_, 'tcx>,
464+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
464465
goal: Goal<'tcx, Self>,
465466
) -> Result<Candidate<'tcx>, NoSolution> {
466467
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -486,7 +487,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
486487
}
487488

488489
fn consider_builtin_fused_iterator_candidate(
489-
ecx: &mut EvalCtxt<'_, 'tcx>,
490+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
490491
goal: Goal<'tcx, Self>,
491492
) -> Result<Candidate<'tcx>, NoSolution> {
492493
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -510,7 +511,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
510511
}
511512

512513
fn consider_builtin_async_iterator_candidate(
513-
ecx: &mut EvalCtxt<'_, 'tcx>,
514+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
514515
goal: Goal<'tcx, Self>,
515516
) -> Result<Candidate<'tcx>, NoSolution> {
516517
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -536,7 +537,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
536537
}
537538

538539
fn consider_builtin_coroutine_candidate(
539-
ecx: &mut EvalCtxt<'_, 'tcx>,
540+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
540541
goal: Goal<'tcx, Self>,
541542
) -> Result<Candidate<'tcx>, NoSolution> {
542543
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -568,7 +569,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
568569
}
569570

570571
fn consider_builtin_discriminant_kind_candidate(
571-
ecx: &mut EvalCtxt<'_, 'tcx>,
572+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
572573
goal: Goal<'tcx, Self>,
573574
) -> Result<Candidate<'tcx>, NoSolution> {
574575
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -581,7 +582,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
581582
}
582583

583584
fn consider_builtin_async_destruct_candidate(
584-
ecx: &mut EvalCtxt<'_, 'tcx>,
585+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
585586
goal: Goal<'tcx, Self>,
586587
) -> Result<Candidate<'tcx>, NoSolution> {
587588
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -594,7 +595,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
594595
}
595596

596597
fn consider_builtin_destruct_candidate(
597-
ecx: &mut EvalCtxt<'_, 'tcx>,
598+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
598599
goal: Goal<'tcx, Self>,
599600
) -> Result<Candidate<'tcx>, NoSolution> {
600601
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -610,7 +611,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
610611
}
611612

612613
fn consider_builtin_transmute_candidate(
613-
ecx: &mut EvalCtxt<'_, 'tcx>,
614+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
614615
goal: Goal<'tcx, Self>,
615616
) -> Result<Candidate<'tcx>, NoSolution> {
616617
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -651,7 +652,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
651652
/// impl<'a, T: Trait + 'a> Unsize<dyn Trait + 'a> for T {}
652653
/// ```
653654
fn consider_structural_builtin_unsize_candidates(
654-
ecx: &mut EvalCtxt<'_, 'tcx>,
655+
ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
655656
goal: Goal<'tcx, Self>,
656657
) -> Vec<Candidate<'tcx>> {
657658
if goal.predicate.polarity != ty::PredicatePolarity::Positive {
@@ -722,7 +723,7 @@ impl<'tcx> assembly::GoalKind<'tcx> for TraitPredicate<'tcx> {
722723
}
723724
}
724725

725-
impl<'tcx> EvalCtxt<'_, 'tcx> {
726+
impl<'tcx> EvalCtxt<'_, InferCtxt<'tcx>> {
726727
/// Trait upcasting allows for coercions between trait objects:
727728
/// ```ignore (builtin impl example)
728729
/// trait Super {}
@@ -846,7 +847,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
846847
// having any inference side-effects. We process obligations because
847848
// unification may initially succeed due to deferred projection equality.
848849
let projection_may_match =
849-
|ecx: &mut EvalCtxt<'_, 'tcx>,
850+
|ecx: &mut EvalCtxt<'_, InferCtxt<'tcx>>,
850851
source_projection: ty::PolyExistentialProjection<'tcx>,
851852
target_projection: ty::PolyExistentialProjection<'tcx>| {
852853
source_projection.item_def_id() == target_projection.item_def_id()
@@ -1152,7 +1153,7 @@ impl<'tcx> EvalCtxt<'_, 'tcx> {
11521153
source: CandidateSource<'tcx>,
11531154
goal: Goal<'tcx, TraitPredicate<'tcx>>,
11541155
constituent_tys: impl Fn(
1155-
&EvalCtxt<'_, 'tcx>,
1156+
&EvalCtxt<'_, InferCtxt<'tcx>>,
11561157
Ty<'tcx>,
11571158
) -> Result<Vec<ty::Binder<'tcx, Ty<'tcx>>>, NoSolution>,
11581159
) -> Result<Candidate<'tcx>, NoSolution> {

‎compiler/rustc_type_ir/src/inherent.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ pub trait GenericArgs<I: Interner<GenericArgs = Self>>:
9696
pub trait Predicate<I: Interner<Predicate = Self>>:
9797
Copy + Debug + Hash + Eq + TypeSuperVisitable<I> + TypeSuperFoldable<I> + Flags
9898
{
99+
fn is_coinductive(self, interner: I) -> bool;
99100
}
100101

101102
/// Common capabilities of placeholder kinds

‎compiler/rustc_type_ir/src/interner.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ pub trait Interner:
124124
) -> Self::GenericArgs;
125125

126126
fn parent(self, def_id: Self::DefId) -> Self::DefId;
127+
128+
fn recursion_limit(self) -> usize;
127129
}
128130

129131
/// Imagine you have a function `F: FnOnce(&[T]) -> R`, plus an iterator `iter`

0 commit comments

Comments
 (0)
This repository has been archived.