Skip to content

Commit 74f08cf

Browse files
committed
Fix a few more borrows
1 parent 2b44ba7 commit 74f08cf

File tree

3 files changed

+24
-22
lines changed

3 files changed

+24
-22
lines changed

compiler/rustc_infer/src/infer/at.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ impl<'a, 'b, 'tcx> Trace<'a, 'b, 'tcx> {
191191
T: Relate<'tcx>,
192192
{
193193
debug!("sub({:?} <: {:?})", a, b);
194-
let Trace { at, trace, a_is_expected } = self;
195-
at.infcx.commit_if_ok(|infcx, _| {
196-
let mut fields = infcx.combine_fields(trace, at.param_env);
194+
let Trace { at: At { param_env, infcx, .. }, trace, a_is_expected } = self;
195+
infcx.commit_if_ok(|infcx, _| {
196+
let mut fields = infcx.combine_fields(trace, param_env);
197197
fields
198198
.sub(a_is_expected)
199199
.relate(a, b)
@@ -208,9 +208,9 @@ impl<'a, 'b, 'tcx> Trace<'a, 'b, 'tcx> {
208208
T: Relate<'tcx>,
209209
{
210210
debug!("eq({:?} == {:?})", a, b);
211-
let Trace { at, trace, a_is_expected } = self;
212-
at.infcx.commit_if_ok(|infcx, _| {
213-
let mut fields = infcx.combine_fields(trace, at.param_env);
211+
let Trace { at: At { param_env, infcx, .. }, trace, a_is_expected } = self;
212+
infcx.commit_if_ok(|infcx, _| {
213+
let mut fields = infcx.combine_fields(trace, param_env);
214214
fields
215215
.equate(a_is_expected)
216216
.relate(a, b)
@@ -223,9 +223,9 @@ impl<'a, 'b, 'tcx> Trace<'a, 'b, 'tcx> {
223223
T: Relate<'tcx>,
224224
{
225225
debug!("lub({:?} \\/ {:?})", a, b);
226-
let Trace { at, trace, a_is_expected } = self;
227-
at.infcx.commit_if_ok(|infcx, _| {
228-
let mut fields = infcx.combine_fields(trace, at.param_env);
226+
let Trace { at: At { param_env, infcx, .. }, trace, a_is_expected } = self;
227+
infcx.commit_if_ok(|infcx, _| {
228+
let mut fields = infcx.combine_fields(trace, param_env);
229229
fields
230230
.lub(a_is_expected)
231231
.relate(a, b)
@@ -238,9 +238,9 @@ impl<'a, 'b, 'tcx> Trace<'a, 'b, 'tcx> {
238238
T: Relate<'tcx>,
239239
{
240240
debug!("glb({:?} /\\ {:?})", a, b);
241-
let Trace { at, trace, a_is_expected } = self;
242-
at.infcx.commit_if_ok(|infcx, _| {
243-
let mut fields = infcx.combine_fields(trace, at.param_env);
241+
let Trace { at: At { param_env, infcx, .. }, trace, a_is_expected } = self;
242+
infcx.commit_if_ok(|infcx, _| {
243+
let mut fields = infcx.combine_fields(trace, param_env);
244244
fields
245245
.glb(a_is_expected)
246246
.relate(a, b)

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
5151
/// for each of the canonical inputs to your query.
5252
5353
pub fn instantiate_canonical_with_fresh_inference_vars<T>(
54-
&self,
54+
&mut self,
5555
span: Span,
5656
canonical: &Canonical<'tcx, T>,
5757
) -> (T, CanonicalVarValues<'tcx>)
@@ -80,7 +80,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
8080
/// details). You can then use `substitute` to instantiate the
8181
/// canonical variable with these inference variables.
8282
fn instantiate_canonical_vars(
83-
&self,
83+
&mut self,
8484
span: Span,
8585
variables: &List<CanonicalVarInfo<'tcx>>,
8686
universe_map: impl Fn(ty::UniverseIndex) -> ty::UniverseIndex,
@@ -137,16 +137,18 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
137137
self.tcx.mk_region(ty::RePlaceholder(placeholder_mapped)).into()
138138
}
139139

140-
CanonicalVarKind::Const(ui) => self
141-
.next_const_var_in_universe(
142-
self.next_ty_var_in_universe(
143-
TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span },
144-
universe_map(ui),
145-
),
140+
CanonicalVarKind::Const(ui) => {
141+
let ty_var = self.next_ty_var_in_universe(
142+
TypeVariableOrigin { kind: TypeVariableOriginKind::MiscVariable, span },
143+
universe_map(ui),
144+
);
145+
self.next_const_var_in_universe(
146+
ty_var,
146147
ConstVariableOrigin { kind: ConstVariableOriginKind::MiscVariable, span },
147148
universe_map(ui),
148149
)
149-
.into(),
150+
.into()
151+
}
150152

151153
CanonicalVarKind::PlaceholderConst(ty::PlaceholderConst { universe, name }) => {
152154
let universe_mapped = universe_map(universe);

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ impl<'tcx> InferCtxtBuilder<'tcx> {
570570
where
571571
T: TypeFoldable<'tcx>,
572572
{
573-
self.enter(|infcx| {
573+
self.enter(|mut infcx| {
574574
let (value, subst) =
575575
infcx.instantiate_canonical_with_fresh_inference_vars(span, canonical);
576576
f(infcx, value, subst)

0 commit comments

Comments
 (0)