aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/lib.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-04-26 16:38:36 +0100
committerGitHub <[email protected]>2020-04-26 16:38:36 +0100
commit99c287148e02d2e762b4a90925763f7e36302767 (patch)
tree088b0fda66e9012959a6e26e460c2811156d3e83 /crates/ra_hir_ty/src/lib.rs
parentef67e0a497a3f0b65c11bf443e0d35c8e51bd26f (diff)
parent497073abc66df21b178c931e91969fccd8afcdc3 (diff)
Merge #4159
4159: For associated type shorthand (T::Item), use the substs from the where clause r=matklad a=flodiebold So e.g. if we have `fn foo<T: SomeTrait<u32>>() -> T::Item`, we want to lower that to `<T as SomeTrait<u32>>::Item` and not `<T as SomeTrait<_>>::Item`. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/ra_hir_ty/src/lib.rs')
-rw-r--r--crates/ra_hir_ty/src/lib.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index 279c06d65..a8ef32ec5 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -487,6 +487,18 @@ impl<T> Binders<T> {
487 pub fn new(num_binders: usize, value: T) -> Self { 487 pub fn new(num_binders: usize, value: T) -> Self {
488 Self { num_binders, value } 488 Self { num_binders, value }
489 } 489 }
490
491 pub fn as_ref(&self) -> Binders<&T> {
492 Binders { num_binders: self.num_binders, value: &self.value }
493 }
494
495 pub fn map<U>(self, f: impl FnOnce(T) -> U) -> Binders<U> {
496 Binders { num_binders: self.num_binders, value: f(self.value) }
497 }
498
499 pub fn filter_map<U>(self, f: impl FnOnce(T) -> Option<U>) -> Option<Binders<U>> {
500 Some(Binders { num_binders: self.num_binders, value: f(self.value)? })
501 }
490} 502}
491 503
492impl<T: Clone> Binders<&T> { 504impl<T: Clone> Binders<&T> {