diff options
| author | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-04-09 22:35:49 +0200 |
|---|---|---|
| committer | Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> | 2023-04-09 23:22:14 +0200 |
| commit | 5a90de8f5e08e736c24348eab1caa62cd57790b0 (patch) | |
| tree | 17457482d7ac7e1e86ee15eacdeb49a06c8b8e0b | |
| parent | 1c75724752077e53ddcb7fd19a55a929a5a8feae (diff) | |
| download | rust-5a90de8f5e08e736c24348eab1caa62cd57790b0.tar.gz rust-5a90de8f5e08e736c24348eab1caa62cd57790b0.zip | |
Delete useless loop
| -rw-r--r-- | compiler/rustc_middle/src/hir/map/mod.rs | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 89a485b47ca..9d97a75a2fa 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -74,18 +74,17 @@ impl<'hir> Iterator for ParentHirIterator<'hir> { if self.current_id == CRATE_HIR_ID { return None; } - loop { - // There are nodes that do not have entries, so we need to skip them. - let parent_id = self.map.parent_id(self.current_id); - if parent_id == self.current_id { - self.current_id = CRATE_HIR_ID; - return None; - } + // There are nodes that do not have entries, so we need to skip them. + let parent_id = self.map.parent_id(self.current_id); - self.current_id = parent_id; - return Some(parent_id); + if parent_id == self.current_id { + self.current_id = CRATE_HIR_ID; + return None; } + + self.current_id = parent_id; + return Some(parent_id); } } |
