diff options
author | Florian Diebold <[email protected]> | 2020-02-21 18:05:27 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2020-02-22 10:09:21 +0000 |
commit | 0dfbbaf03b03618dcb7ba203ddc453533bb8d1b4 (patch) | |
tree | ef862c881d191030007f6b6ef40ce2250d45c916 /crates/ra_hir_ty/src/lib.rs | |
parent | de39d221a15c0a146ed8adbdb1616692180948bb (diff) |
Implement dyn Trait unsizing as well
Diffstat (limited to 'crates/ra_hir_ty/src/lib.rs')
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index 13c5e6c6b..15356ab37 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -661,6 +661,17 @@ impl Ty { | |||
661 | } | 661 | } |
662 | } | 662 | } |
663 | 663 | ||
664 | /// If this is a `dyn Trait` type, this returns the `Trait` part. | ||
665 | pub fn dyn_trait_ref(&self) -> Option<&TraitRef> { | ||
666 | match self { | ||
667 | Ty::Dyn(bounds) => bounds.get(0).and_then(|b| match b { | ||
668 | GenericPredicate::Implemented(trait_ref) => Some(trait_ref), | ||
669 | _ => None, | ||
670 | }), | ||
671 | _ => None, | ||
672 | } | ||
673 | } | ||
674 | |||
664 | fn builtin_deref(&self) -> Option<Ty> { | 675 | fn builtin_deref(&self) -> Option<Ty> { |
665 | match self { | 676 | match self { |
666 | Ty::Apply(a_ty) => match a_ty.ctor { | 677 | Ty::Apply(a_ty) => match a_ty.ctor { |