aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/lib.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2020-05-08 16:36:11 +0100
committerFlorian Diebold <[email protected]>2020-05-08 17:15:24 +0100
commitfe7bf993aa8d64668707e348f2ea69918cfda9a4 (patch)
tree9d3fc4f969dbd06d982dda6dadc6325a668e7eb1 /crates/ra_hir_ty/src/lib.rs
parentd3eb9d8eafbebca7da95fa8a4813b92eb5080500 (diff)
Implement better handling of divergence
Divergence here means that for some reason, the end of a block will not be reached. We tried to model this just using the never type, but that doesn't work fully (e.g. in `let x = { loop {}; "foo" };` x should still have type `&str`); so this introduces a `diverges` flag that the type checker keeps track of, like rustc does.
Diffstat (limited to 'crates/ra_hir_ty/src/lib.rs')
-rw-r--r--crates/ra_hir_ty/src/lib.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index a6f56c661..ac0ef1bfe 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -730,6 +730,13 @@ impl Ty {
730 } 730 }
731 } 731 }
732 732
733 pub fn is_never(&self) -> bool {
734 match self {
735 Ty::Apply(ApplicationTy { ctor: TypeCtor::Never, .. }) => true,
736 _ => false,
737 }
738 }
739
733 /// If this is a `dyn Trait` type, this returns the `Trait` part. 740 /// If this is a `dyn Trait` type, this returns the `Trait` part.
734 pub fn dyn_trait_ref(&self) -> Option<&TraitRef> { 741 pub fn dyn_trait_ref(&self) -> Option<&TraitRef> {
735 match self { 742 match self {