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?
貢獻指南
研究方向
The issue is in hir/src/ir/loops.rs, specifically the LoopInfo::has_loops method. Start by reading the current implementation and the doc comment. The fix is to change the logic to self.per_region.iter().any(|info| !info.forest.is_empty()). Verify by checking the LoopForest::is_empty method and region_has_loops to understand the semantics. Run any existing tests related to loops to ensure the fix works as expected.
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- rust
- 領域
- compilers
- Issue 類型
- 缺陷
- 難度
- 2/5
- 預估耗時
- 1-3 小時
- 活躍度
- 停滯
- 描述清晰度
- 描述清楚
- 新手友好度
- 75/100