From 70eeb054410031a0f23516be51bddaed5fe77276 Mon Sep 17 00:00:00 2001 From: ljedrz Date: Fri, 28 Sep 2018 17:35:31 +0200 Subject: [PATCH] rustc/infer: readability improvements --- src/librustc/infer/canonical/query_result.rs | 32 +++++++++---------- src/librustc/infer/equate.rs | 6 ++-- .../error_reporting/nice_region_error/util.rs | 4 +-- src/librustc/infer/resolve.rs | 4 +-- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/src/librustc/infer/canonical/query_result.rs b/src/librustc/infer/canonical/query_result.rs index f70064e071629..a327f1f5c9d50 100644 --- a/src/librustc/infer/canonical/query_result.rs +++ b/src/librustc/infer/canonical/query_result.rs @@ -499,24 +499,22 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> { let ty::OutlivesPredicate(k1, r2) = constraint.skip_binder(); // restored below let k1 = substitute_value(self.tcx, result_subst, k1); let r2 = substitute_value(self.tcx, result_subst, r2); - match k1.unpack() { - UnpackedKind::Lifetime(r1) => Obligation::new( - cause.clone(), - param_env, - ty::Predicate::RegionOutlives(ty::Binder::dummy( - ty::OutlivesPredicate(r1, r2), + + Obligation::new( + cause.clone(), + param_env, + match k1.unpack() { + UnpackedKind::Lifetime(r1) => ty::Predicate::RegionOutlives( + ty::Binder::dummy( + ty::OutlivesPredicate(r1, r2) )), - ), - - UnpackedKind::Type(t1) => Obligation::new( - cause.clone(), - param_env, - ty::Predicate::TypeOutlives(ty::Binder::dummy(ty::OutlivesPredicate( - t1, r2, - ))), - ), - } - }), + UnpackedKind::Type(t1) => ty::Predicate::TypeOutlives( + ty::Binder::dummy(ty::OutlivesPredicate( + t1, r2 + ))) + } + ) + }) ) as Box> } diff --git a/src/librustc/infer/equate.rs b/src/librustc/infer/equate.rs index 26eb2ffbf6aba..854960492c9bd 100644 --- a/src/librustc/infer/equate.rs +++ b/src/librustc/infer/equate.rs @@ -77,24 +77,22 @@ impl<'combine, 'infcx, 'gcx, 'tcx> TypeRelation<'infcx, 'gcx, 'tcx> match (&a.sty, &b.sty) { (&ty::Infer(TyVar(a_id)), &ty::Infer(TyVar(b_id))) => { infcx.type_variables.borrow_mut().equate(a_id, b_id); - Ok(a) } (&ty::Infer(TyVar(a_id)), _) => { self.fields.instantiate(b, RelationDir::EqTo, a_id, self.a_is_expected)?; - Ok(a) } (_, &ty::Infer(TyVar(b_id))) => { self.fields.instantiate(a, RelationDir::EqTo, b_id, self.a_is_expected)?; - Ok(a) } _ => { self.fields.infcx.super_combine_tys(self, a, b)?; - Ok(a) } } + + Ok(a) } fn regions(&mut self, a: ty::Region<'tcx>, b: ty::Region<'tcx>) diff --git a/src/librustc/infer/error_reporting/nice_region_error/util.rs b/src/librustc/infer/error_reporting/nice_region_error/util.rs index 76a780a5a055a..300bc54d64e13 100644 --- a/src/librustc/infer/error_reporting/nice_region_error/util.rs +++ b/src/librustc/infer/error_reporting/nice_region_error/util.rs @@ -137,8 +137,8 @@ impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> { pub(super) fn is_self_anon(&self, is_first: bool, scope_def_id: DefId) -> bool { is_first && self.tcx - .opt_associated_item(scope_def_id) - .map(|i| i.method_has_self_argument) == Some(true) + .opt_associated_item(scope_def_id) + .map(|i| i.method_has_self_argument) == Some(true) } } diff --git a/src/librustc/infer/resolve.rs b/src/librustc/infer/resolve.rs index be13fb9a2a5eb..0ef9761857264 100644 --- a/src/librustc/infer/resolve.rs +++ b/src/librustc/infer/resolve.rs @@ -153,8 +153,8 @@ impl<'a, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for FullTypeResolver<'a, 'gcx, 'tcx> fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> { if !t.needs_infer() && !ty::keep_local(&t) { t // micro-optimize -- if there is nothing in this type that this fold affects... - // ^ we need to have the `keep_local` check to un-default - // defaulted tuples. + // ^ we need to have the `keep_local` check to un-default + // defaulted tuples. } else { let t = self.infcx.shallow_resolve(t); match t.sty {