mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-28 00:15:23 +00:00
Simplify subst / subst_bound_vars a bit
This commit is contained in:
parent
f43e69a64e
commit
19fbd91998
@ -411,11 +411,7 @@ impl Ty {
|
||||
pub fn subst(self, substs: &Substs) -> Ty {
|
||||
self.fold(&mut |ty| match ty {
|
||||
Ty::Param { idx, name } => {
|
||||
if (idx as usize) < substs.len() {
|
||||
substs[idx as usize].clone()
|
||||
} else {
|
||||
Ty::Param { idx, name }
|
||||
}
|
||||
substs.get(idx as usize).cloned().unwrap_or(Ty::Param { idx, name })
|
||||
}
|
||||
ty => ty,
|
||||
})
|
||||
@ -424,13 +420,7 @@ impl Ty {
|
||||
/// Substitutes `Ty::Bound` vars (as opposed to type parameters).
|
||||
pub fn subst_bound_vars(self, substs: &Substs) -> Ty {
|
||||
self.fold(&mut |ty| match ty {
|
||||
Ty::Bound(idx) => {
|
||||
if (idx as usize) < substs.len() {
|
||||
substs[idx as usize].clone()
|
||||
} else {
|
||||
Ty::Bound(idx)
|
||||
}
|
||||
}
|
||||
Ty::Bound(idx) => substs.get(idx as usize).cloned().unwrap_or(Ty::Bound(idx)),
|
||||
ty => ty,
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user