Skip to content

Commit

Permalink
Rollup merge of #104891 - fee1-dead-contrib:escaping_bound_vars_docs,…
Browse files Browse the repository at this point in the history
… r=wesleywiser

Add documentation for `has_escaping_bound_vars`

Thanks to `@BoxyUwU` for explaining this to me. Adding docs with a helpful link if people get confused.
  • Loading branch information
matthiaskrgr authored Nov 28, 2022
2 parents 63ec33e + 815d370 commit 069f219
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion compiler/rustc_middle/src/ty/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,18 @@ pub trait TypeVisitable<'tcx>: fmt::Debug + Clone {
self.visit_with(&mut HasEscapingVarsVisitor { outer_index: binder }).is_break()
}

/// Returns `true` if this `self` has any regions that escape `binder` (and
/// Returns `true` if this type has any regions that escape `binder` (and
/// hence are not bound by it).
fn has_vars_bound_above(&self, binder: ty::DebruijnIndex) -> bool {
self.has_vars_bound_at_or_above(binder.shifted_in(1))
}

/// Return `true` if this type has regions that are not a part of the type.
/// For example, `for<'a> fn(&'a i32)` return `false`, while `fn(&'a i32)`
/// would return `true`. The latter can occur when traversing through the
/// former.
///
/// See [`HasEscapingVarsVisitor`] for more information.
fn has_escaping_bound_vars(&self) -> bool {
self.has_vars_bound_at_or_above(ty::INNERMOST)
}
Expand Down

0 comments on commit 069f219

Please sign in to comment.