rustc/infer: readability improvements
This commit is contained in:
parent
999d76812c
commit
70eeb05441
4 changed files with 21 additions and 25 deletions
|
|
@ -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),
|
||||
)),
|
||||
),
|
||||
|
||||
UnpackedKind::Type(t1) => Obligation::new(
|
||||
cause.clone(),
|
||||
param_env,
|
||||
ty::Predicate::TypeOutlives(ty::Binder::dummy(ty::OutlivesPredicate(
|
||||
t1, 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) => ty::Predicate::TypeOutlives(
|
||||
ty::Binder::dummy(ty::OutlivesPredicate(
|
||||
t1, r2
|
||||
)))
|
||||
}
|
||||
)
|
||||
})
|
||||
) as Box<dyn Iterator<Item = _>>
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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>)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue