Rollup merge of #80923 - LingMan:exits, r=varkor

Merge different function exits

`@rustbot` modify labels +C-cleanup +T-compiler
This commit is contained in:
Yuki Okushi 2021-01-12 07:59:18 +09:00 committed by GitHub
commit 4e69c5d0fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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