]> git.lizzy.rs Git - rust.git/commitdiff
Merge different function exits
authorLingMan <LingMan@users.noreply.github.com>
Sun, 10 Jan 2021 13:38:14 +0000 (14:38 +0100)
committerLingMan <LingMan@users.noreply.github.com>
Sun, 10 Jan 2021 13:38:14 +0000 (14:38 +0100)
compiler/rustc_middle/src/hir/map/mod.rs

index c2e99224d8b368ab6a6751bfc144b9daf207358f..eb6aded9cb3bd9dcf1050097467d433c64711044 100644 (file)
@@ -710,15 +710,10 @@ pub fn get_defining_scope(&self, id: HirId) -> HirId {
         let mut scope = id;
         loop {
             scope = self.get_enclosing_scope(scope).unwrap_or(CRATE_HIR_ID);
-            if scope == CRATE_HIR_ID {
-                return CRATE_HIR_ID;
-            }
-            match self.get(scope) {
-                Node::Block(_) => {}
-                _ => break,
+            if scope == CRATE_HIR_ID || !matches!(self.get(scope), Node::Block(_)) {
+                return scope;
             }
         }
-        scope
     }
 
     pub fn get_parent_did(&self, id: HirId) -> LocalDefId {