Skip to content

Commit 74a05b6

Browse files
committed
Make Canonicalizer have a mut ref to InferCtxt
1 parent 74f08cf commit 74a05b6

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

compiler/rustc_infer/src/infer/canonical/canonicalizer.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
3737
///
3838
/// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#canonicalizing-the-query
3939
pub fn canonicalize_query<V>(
40-
&self,
40+
&mut self,
4141
value: V,
4242
query_state: &mut OriginalQueryValues<'tcx>,
4343
) -> Canonicalized<'tcx, V>
@@ -80,7 +80,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
8080
/// out the [chapter in the rustc dev guide][c].
8181
///
8282
/// [c]: https://rust-lang.github.io/chalk/book/canonical_queries/canonicalization.html#canonicalizing-the-query-result
83-
pub fn canonicalize_response<V>(&self, value: V) -> Canonicalized<'tcx, V>
83+
pub fn canonicalize_response<V>(&mut self, value: V) -> Canonicalized<'tcx, V>
8484
where
8585
V: TypeFoldable<'tcx>,
8686
{
@@ -94,7 +94,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
9494
)
9595
}
9696

97-
pub fn canonicalize_user_type_annotation<V>(&self, value: V) -> Canonicalized<'tcx, V>
97+
pub fn canonicalize_user_type_annotation<V>(&mut self, value: V) -> Canonicalized<'tcx, V>
9898
where
9999
V: TypeFoldable<'tcx>,
100100
{
@@ -122,7 +122,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
122122
// FIXME(#48536): once the above issues are resolved, we can remove this
123123
// and just use `canonicalize_query`.
124124
pub fn canonicalize_hr_query_hack<V>(
125-
&self,
125+
&mut self,
126126
value: V,
127127
query_state: &mut OriginalQueryValues<'tcx>,
128128
) -> Canonicalized<'tcx, V>
@@ -151,7 +151,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
151151
trait CanonicalizeRegionMode {
152152
fn canonicalize_free_region(
153153
&self,
154-
canonicalizer: &mut Canonicalizer<'_, 'tcx>,
154+
canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>,
155155
r: ty::Region<'tcx>,
156156
) -> ty::Region<'tcx>;
157157

@@ -163,7 +163,7 @@ struct CanonicalizeQueryResponse;
163163
impl CanonicalizeRegionMode for CanonicalizeQueryResponse {
164164
fn canonicalize_free_region(
165165
&self,
166-
canonicalizer: &mut Canonicalizer<'_, 'tcx>,
166+
canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>,
167167
r: ty::Region<'tcx>,
168168
) -> ty::Region<'tcx> {
169169
match r {
@@ -220,7 +220,7 @@ struct CanonicalizeUserTypeAnnotation;
220220
impl CanonicalizeRegionMode for CanonicalizeUserTypeAnnotation {
221221
fn canonicalize_free_region(
222222
&self,
223-
canonicalizer: &mut Canonicalizer<'_, 'tcx>,
223+
canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>,
224224
r: ty::Region<'tcx>,
225225
) -> ty::Region<'tcx> {
226226
match r {
@@ -243,7 +243,7 @@ struct CanonicalizeAllFreeRegions;
243243
impl CanonicalizeRegionMode for CanonicalizeAllFreeRegions {
244244
fn canonicalize_free_region(
245245
&self,
246-
canonicalizer: &mut Canonicalizer<'_, 'tcx>,
246+
canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>,
247247
r: ty::Region<'tcx>,
248248
) -> ty::Region<'tcx> {
249249
canonicalizer.canonical_var_for_region_in_root_universe(r)
@@ -259,7 +259,7 @@ struct CanonicalizeFreeRegionsOtherThanStatic;
259259
impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
260260
fn canonicalize_free_region(
261261
&self,
262-
canonicalizer: &mut Canonicalizer<'_, 'tcx>,
262+
canonicalizer: &mut Canonicalizer<'_, '_, 'tcx>,
263263
r: ty::Region<'tcx>,
264264
) -> ty::Region<'tcx> {
265265
if let ty::ReStatic = r {
@@ -274,21 +274,21 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
274274
}
275275
}
276276

277-
struct Canonicalizer<'cx, 'tcx> {
278-
infcx: Option<&'cx InferCtxt<'cx, 'tcx>>,
277+
struct Canonicalizer<'a, 'cx, 'tcx> {
278+
infcx: Option<&'a mut InferCtxt<'cx, 'tcx>>,
279279
tcx: TyCtxt<'tcx>,
280280
variables: SmallVec<[CanonicalVarInfo<'tcx>; 8]>,
281-
query_state: &'cx mut OriginalQueryValues<'tcx>,
281+
query_state: &'a mut OriginalQueryValues<'tcx>,
282282
// Note that indices is only used once `var_values` is big enough to be
283283
// heap-allocated.
284284
indices: FxHashMap<GenericArg<'tcx>, BoundVar>,
285-
canonicalize_region_mode: &'cx dyn CanonicalizeRegionMode,
285+
canonicalize_region_mode: &'a dyn CanonicalizeRegionMode,
286286
needs_canonical_flags: TypeFlags,
287287

288288
binder_index: ty::DebruijnIndex,
289289
}
290290

291-
impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
291+
impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
292292
fn tcx<'b>(&'b self) -> TyCtxt<'tcx> {
293293
self.tcx
294294
}
@@ -474,15 +474,15 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
474474
}
475475
}
476476

477-
impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
477+
impl<'cx, 'tcx> Canonicalizer<'_, 'cx, 'tcx> {
478478
/// The main `canonicalize` method, shared impl of
479479
/// `canonicalize_query` and `canonicalize_response`.
480-
fn canonicalize<V>(
480+
fn canonicalize<'a, V>(
481481
value: V,
482-
infcx: Option<&InferCtxt<'_, 'tcx>>,
482+
infcx: Option<&'a mut InferCtxt<'_, 'tcx>>,
483483
tcx: TyCtxt<'tcx>,
484484
canonicalize_region_mode: &dyn CanonicalizeRegionMode,
485-
query_state: &mut OriginalQueryValues<'tcx>,
485+
query_state: &'a mut OriginalQueryValues<'tcx>,
486486
) -> Canonicalized<'tcx, V>
487487
where
488488
V: TypeFoldable<'tcx>,

0 commit comments

Comments
 (0)