diff options
author | Benjamin Coenen <[email protected]> | 2020-05-10 11:31:55 +0100 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-05-10 11:31:55 +0100 |
commit | e80903a96564c2239489a8c630a4748bf21a3659 (patch) | |
tree | 12b31a1fd12deb2120065cea5a558425c8c1984f /crates/ra_hir_ty/src/lib.rs | |
parent | 6203e9c4faee288f16d93dbb7dd0f1f8df487d83 (diff) | |
parent | 4578154b608fa075595103d0c933da60d55b25c8 (diff) |
Merge branch 'master' of github.com:rust-analyzer/rust-analyzer into feat_4348
Diffstat (limited to 'crates/ra_hir_ty/src/lib.rs')
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs index a6f56c661..e8f3482fe 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -683,6 +683,12 @@ impl Ty { | |||
683 | pub fn unit() -> Self { | 683 | pub fn unit() -> Self { |
684 | Ty::apply(TypeCtor::Tuple { cardinality: 0 }, Substs::empty()) | 684 | Ty::apply(TypeCtor::Tuple { cardinality: 0 }, Substs::empty()) |
685 | } | 685 | } |
686 | pub fn fn_ptr(sig: FnSig) -> Self { | ||
687 | Ty::apply( | ||
688 | TypeCtor::FnPtr { num_args: sig.params().len() as u16 }, | ||
689 | Substs(sig.params_and_return), | ||
690 | ) | ||
691 | } | ||
686 | 692 | ||
687 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { | 693 | pub fn as_reference(&self) -> Option<(&Ty, Mutability)> { |
688 | match self { | 694 | match self { |
@@ -730,6 +736,10 @@ impl Ty { | |||
730 | } | 736 | } |
731 | } | 737 | } |
732 | 738 | ||
739 | pub fn is_never(&self) -> bool { | ||
740 | matches!(self, Ty::Apply(ApplicationTy { ctor: TypeCtor::Never, .. })) | ||
741 | } | ||
742 | |||
733 | /// If this is a `dyn Trait` type, this returns the `Trait` part. | 743 | /// If this is a `dyn Trait` type, this returns the `Trait` part. |
734 | pub fn dyn_trait_ref(&self) -> Option<&TraitRef> { | 744 | pub fn dyn_trait_ref(&self) -> Option<&TraitRef> { |
735 | match self { | 745 | match self { |