1
Fork 0

Rollup merge of #94849 - ouz-a:master4, r=oli-obk

Check var scope if it exist

Fixes #92893.

Added helper function to check the scope of a variable, if it doesn't have a scope call delay_span_bug, which avoids us trying to get a block/scope that doesn't exist.

Had to increase `ROOT_ENTRY_LIMIT` was getting tidy error
This commit is contained in:
Dylan DPC 2022-04-15 20:50:44 +02:00 committed by GitHub
commit a32e0f3041
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 41 additions and 15 deletions

View file

@ -362,12 +362,9 @@ impl ScopeTree {
self.parent_map.get(&id).cloned().map(|(p, _)| p)
}
/// Returns the lifetime of the local variable `var_id`
pub fn var_scope(&self, var_id: hir::ItemLocalId) -> Scope {
self.var_map
.get(&var_id)
.cloned()
.unwrap_or_else(|| bug!("no enclosing scope for id {:?}", var_id))
/// Returns the lifetime of the local variable `var_id`, if any.
pub fn var_scope(&self, var_id: hir::ItemLocalId) -> Option<Scope> {
self.var_map.get(&var_id).cloned()
}
/// Returns the scope when the temp created by `expr_id` will be cleaned up.