Skip to content

Commit 26f7030

Browse files
committed
remove unused Option
1 parent 6f4b539 commit 26f7030

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

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

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
4646
{
4747
self.tcx.sess.perf_stats.queries_canonicalized.fetch_add(1, Ordering::Relaxed);
4848

49-
Canonicalizer::canonicalize(
50-
value,
51-
Some(self),
52-
self.tcx,
53-
&CanonicalizeAllFreeRegions,
54-
query_state,
55-
)
49+
Canonicalizer::canonicalize(value, self, self.tcx, &CanonicalizeAllFreeRegions, query_state)
5650
}
5751

5852
/// Canonicalizes a query *response* `V`. When we canonicalize a
@@ -87,7 +81,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
8781
let mut query_state = OriginalQueryValues::default();
8882
Canonicalizer::canonicalize(
8983
value,
90-
Some(self),
84+
self,
9185
self.tcx,
9286
&CanonicalizeQueryResponse,
9387
&mut query_state,
@@ -101,7 +95,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
10195
let mut query_state = OriginalQueryValues::default();
10296
Canonicalizer::canonicalize(
10397
value,
104-
Some(self),
98+
self,
10599
self.tcx,
106100
&CanonicalizeUserTypeAnnotation,
107101
&mut query_state,
@@ -133,7 +127,7 @@ impl<'cx, 'tcx> InferCtxt<'cx, 'tcx> {
133127

134128
Canonicalizer::canonicalize(
135129
value,
136-
Some(self),
130+
self,
137131
self.tcx,
138132
&CanonicalizeFreeRegionsOtherThanStatic,
139133
query_state,
@@ -275,7 +269,7 @@ impl CanonicalizeRegionMode for CanonicalizeFreeRegionsOtherThanStatic {
275269
}
276270

277271
struct Canonicalizer<'cx, 'tcx> {
278-
infcx: Option<&'cx InferCtxt<'cx, 'tcx>>,
272+
infcx: &'cx InferCtxt<'cx, 'tcx>,
279273
tcx: TyCtxt<'tcx>,
280274
variables: SmallVec<[CanonicalVarInfo<'tcx>; 8]>,
281275
query_state: &'cx mut OriginalQueryValues<'tcx>,
@@ -316,7 +310,6 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
316310
ty::ReVar(vid) => {
317311
let resolved_vid = self
318312
.infcx
319-
.unwrap()
320313
.inner
321314
.borrow_mut()
322315
.unwrap_region_constraints()
@@ -343,7 +336,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
343336
match *t.kind() {
344337
ty::Infer(ty::TyVar(vid)) => {
345338
debug!("canonical: type var found with vid {:?}", vid);
346-
match self.infcx.unwrap().probe_ty_var(vid) {
339+
match self.infcx.probe_ty_var(vid) {
347340
// `t` could be a float / int variable; canonicalize that instead.
348341
Ok(t) => {
349342
debug!("(resolved to {:?})", t);
@@ -429,7 +422,7 @@ impl<'cx, 'tcx> TypeFolder<'tcx> for Canonicalizer<'cx, 'tcx> {
429422
match ct.val {
430423
ty::ConstKind::Infer(InferConst::Var(vid)) => {
431424
debug!("canonical: const var found with vid {:?}", vid);
432-
match self.infcx.unwrap().probe_const_var(vid) {
425+
match self.infcx.probe_const_var(vid) {
433426
Ok(c) => {
434427
debug!("(resolved to {:?})", c);
435428
return self.fold_const(c);
@@ -476,7 +469,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
476469
/// `canonicalize_query` and `canonicalize_response`.
477470
fn canonicalize<V>(
478471
value: V,
479-
infcx: Option<&InferCtxt<'_, 'tcx>>,
472+
infcx: &InferCtxt<'_, 'tcx>,
480473
tcx: TyCtxt<'tcx>,
481474
canonicalize_region_mode: &dyn CanonicalizeRegionMode,
482475
query_state: &mut OriginalQueryValues<'tcx>,
@@ -610,7 +603,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
610603

611604
/// Returns the universe in which `vid` is defined.
612605
fn region_var_universe(&self, vid: ty::RegionVid) -> ty::UniverseIndex {
613-
self.infcx.unwrap().inner.borrow_mut().unwrap_region_constraints().var_universe(vid)
606+
self.infcx.inner.borrow_mut().unwrap_region_constraints().var_universe(vid)
614607
}
615608

616609
/// Creates a canonical variable (with the given `info`)
@@ -631,7 +624,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
631624
/// *that*. Otherwise, create a new canonical variable for
632625
/// `ty_var`.
633626
fn canonicalize_ty_var(&mut self, info: CanonicalVarInfo<'tcx>, ty_var: Ty<'tcx>) -> Ty<'tcx> {
634-
let infcx = self.infcx.expect("encountered ty-var without infcx");
627+
let infcx = self.infcx;
635628
let bound_to = infcx.shallow_resolve(ty_var);
636629
if bound_to != ty_var {
637630
self.fold_ty(bound_to)
@@ -650,7 +643,7 @@ impl<'cx, 'tcx> Canonicalizer<'cx, 'tcx> {
650643
info: CanonicalVarInfo<'tcx>,
651644
const_var: &'tcx ty::Const<'tcx>,
652645
) -> &'tcx ty::Const<'tcx> {
653-
let infcx = self.infcx.expect("encountered const-var without infcx");
646+
let infcx = self.infcx;
654647
let bound_to = infcx.shallow_resolve(const_var);
655648
if bound_to != const_var {
656649
self.fold_const(bound_to)

0 commit comments

Comments
 (0)