Function rustc::middle::ty::type_has_escaping_regionsUnstable [-] [+] [src]

pub fn type_has_escaping_regions(ty: Ty) -> bool

An "escaping region" is a bound region whose binder is not part of t.

So, for example, consider a type like the following, which has two binders:

for<'a> fn(x: for<'b> fn(&'a isize, &'b isize)) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ outer scope ~~~~~~~~~~~~~~~~~~~~~~~~~~~ inner scope

This type has bound regions ('a, 'b), but it does not have escaping regions, because the binders of both 'a and 'b are part of the type itself. However, if we consider the inner fn type, that type has an escaping region: 'a.

Note that what I'm calling an "escaping region" is often just called a "free region". However, we already use the term "free region". It refers to the regions that we use to represent bound regions on a fn definition while we are typechecking its body.

To clarify, conceptually there is no particular difference between an "escaping" region and a "free" region. However, there is a big difference in practice. Basically, when "entering" a binding level, one is generally required to do some sort of processing to a bound region, such as replacing it with a fresh/skolemized region, or making an entry in the environment to represent the scope to which it is attached, etc. An escaping region represents a bound region for which this processing has not yet been done.