diff options
author | Florian Diebold <[email protected]> | 2019-05-04 17:41:48 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2019-05-04 17:41:48 +0100 |
commit | 19fbd919986e99287168f40aa11003a11aa43d3a (patch) | |
tree | 4e7f3e102fe9a956f715d7083c8db939131b3a51 /crates/ra_hir/src | |
parent | f43e69a64eea0caf8b9f5ced31e7f77dc0d33d65 (diff) |
Simplify subst / subst_bound_vars a bit
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/ty.rs | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index 6a79af35b..f2b37b208 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -411,11 +411,7 @@ impl Ty { | |||
411 | pub fn subst(self, substs: &Substs) -> Ty { | 411 | pub fn subst(self, substs: &Substs) -> Ty { |
412 | self.fold(&mut |ty| match ty { | 412 | self.fold(&mut |ty| match ty { |
413 | Ty::Param { idx, name } => { | 413 | Ty::Param { idx, name } => { |
414 | if (idx as usize) < substs.len() { | 414 | substs.get(idx as usize).cloned().unwrap_or(Ty::Param { idx, name }) |
415 | substs[idx as usize].clone() | ||
416 | } else { | ||
417 | Ty::Param { idx, name } | ||
418 | } | ||
419 | } | 415 | } |
420 | ty => ty, | 416 | ty => ty, |
421 | }) | 417 | }) |
@@ -424,13 +420,7 @@ impl Ty { | |||
424 | /// Substitutes `Ty::Bound` vars (as opposed to type parameters). | 420 | /// Substitutes `Ty::Bound` vars (as opposed to type parameters). |
425 | pub fn subst_bound_vars(self, substs: &Substs) -> Ty { | 421 | pub fn subst_bound_vars(self, substs: &Substs) -> Ty { |
426 | self.fold(&mut |ty| match ty { | 422 | self.fold(&mut |ty| match ty { |
427 | Ty::Bound(idx) => { | 423 | Ty::Bound(idx) => substs.get(idx as usize).cloned().unwrap_or(Ty::Bound(idx)), |
428 | if (idx as usize) < substs.len() { | ||
429 | substs[idx as usize].clone() | ||
430 | } else { | ||
431 | Ty::Bound(idx) | ||
432 | } | ||
433 | } | ||
434 | ty => ty, | 424 | ty => ty, |
435 | }) | 425 | }) |
436 | } | 426 | } |