Skip to content

Commit 632dd22

Browse files
committed
Fix some more function signatures
1 parent 74a05b6 commit 632dd22

File tree

4 files changed

+26
-23
lines changed

4 files changed

+26
-23
lines changed

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,13 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
4444
where
4545
V: TypeFoldable<'tcx>,
4646
{
47-
self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed);
47+
let tcx = self.tcx;
48+
tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed);
4849

4950
Canonicalizer::canonicalize(
5051
value,
5152
Some(self),
52-
self.tcx,
53+
tcx,
5354
&CanonicalizeAllFreeRegions,
5455
query_state,
5556
)
@@ -84,11 +85,12 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
8485
where
8586
V: TypeFoldable<'tcx>,
8687
{
88+
let tcx = self.tcx;
8789
let mut query_state = OriginalQueryValues::default();
8890
Canonicalizer::canonicalize(
8991
value,
9092
Some(self),
91-
self.tcx,
93+
tcx,
9294
&CanonicalizeQueryResponse,
9395
&mut query_state,
9496
)
@@ -98,11 +100,12 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
98100
where
99101
V: TypeFoldable<'tcx>,
100102
{
103+
let tcx = self.tcx;
101104
let mut query_state = OriginalQueryValues::default();
102105
Canonicalizer::canonicalize(
103106
value,
104107
Some(self),
105-
self.tcx,
108+
tcx,
106109
&CanonicalizeUserTypeAnnotation,
107110
&mut query_state,
108111
)
@@ -129,12 +132,13 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
129132
where
130133
V: TypeFoldable<'tcx>,
131134
{
132-
self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed);
135+
let tcx = self.tcx;
136+
tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed);
133137

134138
Canonicalizer::canonicalize(
135139
value,
136140
Some(self),
137-
self.tcx,
141+
tcx,
138142
&CanonicalizeFreeRegionsOtherThanStatic,
139143
query_state,
140144
)
@@ -316,6 +320,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
316320
ty::ReVar(vid) => {
317321
let resolved_vid = self
318322
.infcx
323+
.as_mut()
319324
.unwrap()
320325
.inner
321326
.unwrap_region_constraints()
@@ -342,7 +347,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
342347
match *t.kind() {
343348
ty::Infer(ty::TyVar(vid)) => {
344349
debug!("canonical: type var found with vid {:?}", vid);
345-
match self.infcx.unwrap().probe_ty_var(vid) {
350+
match self.infcx.as_mut().unwrap().probe_ty_var(vid) {
346351
// `t` could be a float / int variable; canonicalize that instead.
347352
Ok(t) => {
348353
debug!("(resolved to {:?})", t);
@@ -352,7 +357,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
352357
// `TyVar(vid)` is unresolved, track its universe index in the canonicalized
353358
// result.
354359
Err(mut ui) => {
355-
if !self.infcx.unwrap().tcx.sess.opts.debugging_opts.chalk {
360+
if !self.infcx.as_ref().unwrap().tcx.sess.opts.debugging_opts.chalk {
356361
// FIXME: perf problem described in #55921.
357362
ui = ty::UniverseIndex::ROOT;
358363
}
@@ -430,7 +435,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
430435
match ct.val {
431436
ty::ConstKind::Infer(InferConst::Var(vid)) => {
432437
debug!("canonical: const var found with vid {:?}", vid);
433-
match self.infcx.unwrap().probe_const_var(vid) {
438+
match self.infcx.as_mut().unwrap().probe_const_var(vid) {
434439
Ok(c) => {
435440
debug!("(resolved to {:?})", c);
436441
return self.fold_const(c);
@@ -439,7 +444,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'_, 'cx, 'tcx> {
439444
// `ConstVar(vid)` is unresolved, track its universe index in the
440445
// canonicalized result
441446
Err(mut ui) => {
442-
if !self.infcx.unwrap().tcx.sess.opts.debugging_opts.chalk {
447+
if !self.infcx.as_ref().unwrap().tcx.sess.opts.debugging_opts.chalk {
443448
// FIXME: perf problem described in #55921.
444449
ui = ty::UniverseIndex::ROOT;
445450
}
@@ -612,8 +617,8 @@ impl<'cx, 'tcx> Canonicalizer<'_, 'cx, 'tcx> {
612617
}
613618

614619
/// Returns the universe in which `vid` is defined.
615-
fn region_var_universe(&self, vid: ty::RegionVid) -> ty::UniverseIndex {
616-
self.infcx.unwrap().inner.unwrap_region_constraints().var_universe(vid)
620+
fn region_var_universe(&mut self, vid: ty::RegionVid) -> ty::UniverseIndex {
621+
self.infcx.as_mut().unwrap().inner.unwrap_region_constraints().var_universe(vid)
617622
}
618623

619624
/// Creates a canonical variable (with the given `info`)
@@ -634,7 +639,7 @@ impl<'cx, 'tcx> Canonicalizer<'_, 'cx, 'tcx> {
634639
/// *that*. Otherwise, create a new canonical variable for
635640
/// `ty_var`.
636641
fn canonicalize_ty_var(&mut self, info: CanonicalVarInfo<'tcx>, ty_var: Ty<'tcx>) -> Ty<'tcx> {
637-
let infcx = self.infcx.expect("encountered ty-var without infcx");
642+
let infcx = self.infcx.as_mut().expect("encountered ty-var without infcx");
638643
let bound_to = infcx.shallow_resolve(ty_var);
639644
if bound_to != ty_var {
640645
self.fold_ty(bound_to)
@@ -653,7 +658,7 @@ impl<'cx, 'tcx> Canonicalizer<'_, 'cx, 'tcx> {
653658
info: CanonicalVarInfo<'tcx>,
654659
const_var: &'tcx ty::Const<'tcx>,
655660
) -> &'tcx ty::Const<'tcx> {
656-
let infcx = self.infcx.expect("encountered const-var without infcx");
661+
let infcx = self.infcx.as_mut().expect("encountered const-var without infcx");
657662
let bound_to = infcx.shallow_resolve(const_var);
658663
if bound_to != const_var {
659664
self.fold_const(bound_to)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
7676
/// that care about regions) with this function, you have to
7777
/// do it yourself, by e.g., having them be a part of the answer.
7878
pub fn make_query_response_ignoring_pending_obligations<T>(
79-
&self,
79+
&mut self,
8080
inference_vars: CanonicalVarValues<'tcx>,
8181
answer: T,
8282
) -> Canonical<'tcx, QueryResponse<'tcx, T>>

compiler/rustc_infer/src/infer/combine.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
255255
}
256256

257257
fn unify_integral_variable(
258-
&self,
258+
&mut self,
259259
vid_is_expected: bool,
260260
vid: ty::IntVid,
261261
val: ty::IntVarValue,
@@ -271,7 +271,7 @@ impl<'infcx, 'tcx> InferCtxt<'infcx, 'tcx> {
271271
}
272272

273273
fn unify_float_variable(
274-
&self,
274+
&mut self,
275275
vid_is_expected: bool,
276276
vid: ty::FloatVid,
277277
val: ast::FloatTy,
@@ -381,7 +381,7 @@ impl<'infcx_borrow, 'infcx, 'tcx> CombineFields<'infcx_borrow, 'infcx, 'tcx> {
381381
///
382382
/// - `for_vid` is a "root vid"
383383
fn generalize(
384-
&self,
384+
&mut self,
385385
ty: Ty<'tcx>,
386386
for_vid: ty::TyVid,
387387
dir: RelationDir,
@@ -413,9 +413,9 @@ impl<'infcx_borrow, 'infcx, 'tcx> CombineFields<'infcx_borrow, 'infcx, 'tcx> {
413413
debug!("generalize: trace = {:?}", self.trace);
414414

415415
let mut generalize = Generalizer {
416+
for_vid_sub_root: self.infcx.inner.type_variables().sub_root_var(for_vid),
416417
infcx: self.infcx,
417418
cause: &self.trace.cause,
418-
for_vid_sub_root: self.infcx.inner.type_variables().sub_root_var(for_vid),
419419
for_universe,
420420
ambient_variance,
421421
needs_wf: false,
@@ -707,12 +707,10 @@ impl TypeRelation<'tcx> for Generalizer<'_, '_, 'tcx> {
707707

708708
match c.val {
709709
ty::ConstKind::Infer(InferConst::Var(vid)) => {
710-
let mut inner = self.infcx.inner;
711-
let variable_table = &mut inner.const_unification_table();
710+
let mut variable_table = self.infcx.inner.const_unification_table();
712711
let var_value = variable_table.probe_value(vid);
713712
match var_value.val {
714713
ConstVariableValue::Known { value: u } => {
715-
drop(inner);
716714
self.relate(u, u)
717715
}
718716
ConstVariableValue::Unknown { universe } => {

compiler/rustc_infer/src/infer/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
14951495
/// This handles inferences variables within both `param_env` and `substs` by
14961496
/// performing the operation on their respective canonical forms.
14971497
pub fn const_eval_resolve(
1498-
&self,
1498+
&mut self,
14991499
param_env: ty::ParamEnv<'tcx>,
15001500
def: ty::WithOptConstParam<DefId>,
15011501
substs: SubstsRef<'tcx>,

0 commit comments

Comments
 (0)