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.
This commit is contained in:
@@ -730,6 +730,13 @@ impl Ty {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_never(&self) -> bool {
|
||||
match self {
|
||||
Ty::Apply(ApplicationTy { ctor: TypeCtor::Never, .. }) => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// If this is a `dyn Trait` type, this returns the `Trait` part.
|
||||
pub fn dyn_trait_ref(&self) -> Option<&TraitRef> {
|
||||
match self {
|
||||
|
||||
Reference in New Issue
Block a user