]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc/mir/mod.rs
Suggest that values are dropped in the opposite order they are defined
[rust.git] / src / librustc / mir / mod.rs
index 20a0df2a1717780c9c447f8cafead3cbb4dea256..b4a4e812e0335164b3842d3419f60529505ae71c 100644 (file)
@@ -302,6 +302,19 @@ pub fn source_info(&self, location: Location) -> &SourceInfo {
         }
     }
 
+    /// Check if `sub` is a sub scope of `sup`
+    pub fn is_sub_scope(&self, mut sub: SourceScope, sup: SourceScope) -> bool {
+        loop {
+            if sub == sup {
+                return true;
+            }
+            match self.source_scopes[sub].parent_scope {
+                None => return false,
+                Some(p) => sub = p,
+            }
+        }
+    }
+
     /// Return the return type, it always return first element from `local_decls` array
     pub fn return_ty(&self) -> Ty<'tcx> {
         self.local_decls[RETURN_PLACE].ty