LoopInfo::has_loops returns true when there are no loops
- 主要语言
- Rust
- 星标
- 115
- 派生
- 84
- 平均合并
- 1 天 8 小时
- 30 天内合并 PR
- 15
描述
In the file hir/src/ir/loops.rs, the function LoopInfo::has_loops
```rust
impl LoopInfo {
/// Returns true if the op this info was derived from contains any loops
pub fn has_loops(&self) -> bool {
!self.per_region.is_empty() && !self.per_region.iter().any(|info| !info.forest.is_empty())
}
}
```
(currently: !self.per_region.is_empty() && !self.per_region.iter().any(|info| !info.forest.is_empty())) returns true when all regions of LoopForest are empty (i.e., there are no loops). This contradicts the doc comment for the method (“Returns true if the op this info was derived from contains any loops”), as well as how the presence of loops is determined in region_has_loops (!info.forest.is_empty()) and the semantics of LoopForest::is_empty() (“no loops”).
Correct: self.per_region.iter().any(|info| !info.forest.is_empty()). This way, the method returns true if there are loops in at least one region; on an empty per_region, .any(...) will return false, which is correct. This aligns the behavior with the documentation and with the logic of region_has_loops.
If you find it useful and worth, could you assing me to solve this if you dont mind?
贡献指南
评估
这个 Issue 还没有评估数据。