Skip to content

Commit 70eeb05

Browse files
committed
rustc/infer: readability improvements
1 parent 999d768 commit 70eeb05

File tree

4 files changed

+21
-25
lines changed

4 files changed

+21
-25
lines changed

src/librustc/infer/canonical/query_result.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -499,24 +499,22 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
499499
let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below
500500
let k1 = substitute_value(self.tcx, result_subst, k1);
501501
let r2 = substitute_value(self.tcx, result_subst, r2);
502-
match k1.unpack() {
503-
UnpackedKind::Lifetime(r1) => Obligation::new(
504-
cause.clone(),
505-
param_env,
506-
ty::Predicate::RegionOutlives(ty::Binder::dummy(
507-
ty::OutlivesPredicate(r1, r2),
502+
503+
Obligation::new(
504+
cause.clone(),
505+
param_env,
506+
match k1.unpack() {
507+
UnpackedKind::Lifetime(r1) => ty::Predicate::RegionOutlives(
508+
ty::Binder::dummy(
509+
ty::OutlivesPredicate(r1, r2)
508510
)),
509-
),
510-
511-
UnpackedKind::Type(t1) => Obligation::new(
512-
cause.clone(),
513-
param_env,
514-
ty::Predicate::TypeOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
515-
t1, r2,
516-
))),
517-
),
518-
}
519-
}),
511+
UnpackedKind::Type(t1) => ty::Predicate::TypeOutlives(
512+
ty::Binder::dummy(ty::OutlivesPredicate(
513+
t1, r2
514+
)))
515+
}
516+
)
517+
})
520518
) as Box<dyn Iterator<Item = _>>
521519
}
522520

src/librustc/infer/equate.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,22 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx>
7777
match (&a.sty, &b.sty) {
7878
(&ty::Infer(TyVar(a_id)), &ty::Infer(TyVar(b_id))) => {
7979
infcx.type_variables.borrow_mut().equate(a_id, b_id);
80-
Ok(a)
8180
}
8281

8382
(&ty::Infer(TyVar(a_id)), _) => {
8483
self.fields.instantiate(b, RelationDir::EqTo, a_id, self.a_is_expected)?;
85-
Ok(a)
8684
}
8785

8886
(_, &ty::Infer(TyVar(b_id))) => {
8987
self.fields.instantiate(a, RelationDir::EqTo, b_id, self.a_is_expected)?;
90-
Ok(a)
9188
}
9289

9390
_ => {
9491
self.fields.infcx.super_combine_tys(self, a, b)?;
95-
Ok(a)
9692
}
9793
}
94+
95+
Ok(a)
9896
}
9997

10098
fn regions(&mut self, a: ty::Region<'tcx>, b: ty::Region<'tcx>)

src/librustc/infer/error_reporting/nice_region_error/util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
137137
pub(super) fn is_self_anon(&self, is_first: bool, scope_def_id: DefId) -> bool {
138138
is_first
139139
&& self.tcx
140-
.opt_associated_item(scope_def_id)
141-
.map(|i| i.method_has_self_argument) == Some(true)
140+
.opt_associated_item(scope_def_id)
141+
.map(|i| i.method_has_self_argument) == Some(true)
142142
}
143143

144144
}

src/librustc/infer/resolve.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for FullTypeResolver<'a, 'gcx, 'tcx>
153153
fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
154154
if !t.needs_infer() && !ty::keep_local(&t) {
155155
t // micro-optimize -- if there is nothing in this type that this fold affects...
156-
// ^ we need to have the `keep_local` check to un-default
157-
// defaulted tuples.
156+
// ^ we need to have the `keep_local` check to un-default
157+
// defaulted tuples.
158158
} else {
159159
let t = self.infcx.shallow_resolve(t);
160160
match t.sty {

0 commit comments

Comments
 (0)